diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-09-01 08:47:55 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-09-01 08:47:55 +0300 |
commit | 6749d39a954c84bc4610acf6e5337c484afcde9a (patch) | |
tree | 0b5dd374810ca9d9ffbd1efc3aeda19ceb02f349 | |
parent | c02d61bc11ee06b6043e6db9a15d00b9f40bce1f (diff) | |
parent | 1b41a54fc98dab0e05523c36b53bd62d7e7f28b4 (diff) | |
download | mariadb-git-6749d39a954c84bc4610acf6e5337c484afcde9a.tar.gz |
Merge 10.2 into bb-10.2-ext
318 files changed, 12435 insertions, 1799 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index b036ff5645c..006136eb64e 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -574,15 +574,17 @@ struct st_replace *glob_replace= 0; void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, const char *from, int len); -static void cleanup_and_exit(int exit_code) __attribute__((noreturn)); +ATTRIBUTE_NORETURN +static void cleanup_and_exit(int exit_code); -void really_die(const char *msg) __attribute__((noreturn)); +ATTRIBUTE_NORETURN +void really_die(const char *msg); void report_or_die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -void die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) - __attribute__((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void die(const char *fmt, ...); static void make_error_message(char *buf, size_t len, const char *fmt, va_list args); -void abort_not_supported_test(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) - __attribute__((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void abort_not_supported_test(const char *fmt, ...); void verbose_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); void log_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); @@ -4022,7 +4024,25 @@ static int rmtree(const char *dir) strxnmov(path, sizeof(path), dir, sep, file->name, NULL); if (!MY_S_ISDIR(file->mystat->st_mode)) + { err= my_delete(path, 0); +#ifdef _WIN32 + /* + On Windows, check and possible reset readonly attribute. + my_delete(), or DeleteFile does not remove theses files. + */ + if (err) + { + DWORD attr= GetFileAttributes(path); + if (attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_READONLY)) + { + SetFileAttributes(path, attr &~ FILE_ATTRIBUTE_READONLY); + err= my_delete(path, 0); + } + } +#endif + } else err= rmtree(path); diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake.in index c77e28d882c..baa48847815 100644 --- a/cmake/create_initial_db.cmake.in +++ b/cmake/create_initial_db.cmake.in @@ -82,7 +82,3 @@ EXECUTE_PROCESS ( IF(NOT RESULT EQUAL 0) MESSAGE(FATAL_ERROR "Could not create initial database \n ${OUT} \n ${ERR}") ENDIF() - -EXECUTE_PROCESS ( - COMMAND "@CMAKE_COMMAND@" -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep -) diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 22f1ff7f30d..37fd204ed72 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -139,8 +139,8 @@ IF(MSVC) ENDIF() #TODO: update the code and remove the disabled warnings - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996 /we4700") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099 /we4700") ENDIF() diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake index 61eacba7c73..86e3d41eb77 100644 --- a/cmake/submodules.cmake +++ b/cmake/submodules.cmake @@ -2,8 +2,9 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" config --get cmake.update-submodules WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE cmake_update_submodules) - IF(cmake_update_submodules MATCHES no) + OUTPUT_VARIABLE cmake_update_submodules + RESULT_VARIABLE git_config_get_result) + IF(git_config_get_result EQUAL 128 OR cmake_update_submodules MATCHES no) SET(update_result 0) ELSEIF (cmake_update_submodules MATCHES force) MESSAGE("-- Updating submodules (forced)") diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake index be56a4c0772..e6d1379aea3 100644 --- a/cmake/wsrep.cmake +++ b/cmake/wsrep.cmake @@ -26,7 +26,7 @@ ENDIF() OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) # Set the patch version -SET(WSREP_PATCH_VERSION "19") +SET(WSREP_PATCH_VERSION "20") # Obtain wsrep API version FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/wsrep_api.h" WSREP_API_VERSION diff --git a/debian/patches/50_mysql-test__db_test.dpatch b/debian/patches/50_mysql-test__db_test.dpatch index 670afbf14ac..14c0fc4acf6 100755 --- a/debian/patches/50_mysql-test__db_test.dpatch +++ b/debian/patches/50_mysql-test__db_test.dpatch @@ -11,14 +11,14 @@ --- old/mysql-test/mysql-test-run.pl 2009-06-16 14:24:09.000000000 +0200 +++ new/mysql-test/mysql-test-run.pl 2009-07-04 00:03:34.000000000 +0200 @@ -3578,6 +3578,11 @@ sub mysql_install_db { - mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", - $bootstrap_sql_file); + mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", + $bootstrap_sql_file); -+ mtr_tofile($bootstrap_sql_file, "-- Debian removed the default privileges on the 'test' database\n"); -+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); -+ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test\\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); -+ ++ mtr_tofile($bootstrap_sql_file, "-- Debian removed the default privileges on the 'test' database\n"); ++ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); ++ mtr_tofile($bootstrap_sql_file, "INSERT INTO mysql.db VALUES ('%','test\\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');\n"); + - # Add test data for timezone - this is just a subset, on a real - # system these tables will be populated either by mysql_tzinfo_to_sql - # or by downloading the timezone table package from our website ++ + # Add test data for timezone - this is just a subset, on a real + # system these tables will be populated either by mysql_tzinfo_to_sql + # or by downloading the timezone table package from our website diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 7b78d1a4c39..8fe2e186919 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -113,6 +113,11 @@ xb_mysql_connect() (char *) &opt_secure_auth); } + if (xb_plugin_dir && *xb_plugin_dir){ + mysql_options(connection, MYSQL_PLUGIN_DIR, xb_plugin_dir); + } + mysql_options(connection, MYSQL_OPT_PROTOCOL, &opt_protocol); + msg_ts("Connecting to MySQL server host: %s, user: %s, password: %s, " "port: %s, socket: %s\n", opt_host ? opt_host : "localhost", opt_user ? opt_user : "not set", diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 160d9df1df9..702ac088557 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -119,6 +119,7 @@ my_bool xtrabackup_export; longlong xtrabackup_use_memory; +uint opt_protocol; long xtrabackup_throttle; /* 0:unlimited */ static lint io_ticket; static os_event_t wait_throttle; @@ -527,6 +528,7 @@ enum options_xtrabackup OPT_XTRA_TABLES_EXCLUDE, OPT_XTRA_DATABASES_EXCLUDE, + OPT_PROTOCOL }; struct my_option xb_client_options[] = @@ -759,6 +761,9 @@ struct my_option xb_client_options[] = 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"protocol", OPT_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"socket", 'S', "This option specifies the socket to use when " "connecting to the local database server with a UNIX domain socket. " "The option accepts a string argument. See mysql --help for details.", @@ -1290,8 +1295,13 @@ xb_get_one_option(int optid, start[1]=0 ; } break; - - + case OPT_PROTOCOL: + if (argument) + { + opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, + opt->name); + } + break; #include "sslopt-case.h" case '?': @@ -2588,10 +2598,6 @@ xb_load_single_table_tablespace( ut_free(name); - if (fil_space_crypt_t* crypt_info = file->get_crypt_info()) { - fil_space_destroy_crypt_data(&crypt_info); - } - delete file; if (err != DB_SUCCESS && err != DB_CORRUPTION && xtrabackup_backup) { diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index d1d1e8df29a..b226a9d1d83 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -43,6 +43,8 @@ extern char *xtrabackup_incremental_dir; extern char *xtrabackup_incremental_basedir; extern char *innobase_data_home_dir; extern char *innobase_buffer_pool_filename; +extern char *xb_plugin_dir; +extern uint opt_protocol; extern ds_ctxt_t *ds_meta; extern ds_ctxt_t *ds_data; diff --git a/include/my_compiler.h b/include/my_compiler.h index 000d4e42848..97e6f9ae106 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -148,6 +148,29 @@ struct my_aligned_storage #define MY_ALIGNED(size) #endif +#ifdef __GNUC__ +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +# if MY_GNUC_PREREQ(4,3) +/** Starting with GCC 4.3, the "cold" attribute is used to inform the +compiler that a function is unlikely executed. The function is +optimized for size rather than speed and on many targets it is placed +into special subsection of the text section so all cold functions +appears close together improving code locality of non-cold parts of +program. The paths leading to call of cold functions within code are +marked as unlikely by the branch prediction mechanism. optimize a +rarely invoked function for size instead for speed. */ +# define ATTRIBUTE_COLD __attribute__((cold)) +# endif +#elif defined _WIN32 +# define ATTRIBUTE_NORETURN __declspec(noreturn) +#else +# define ATTRIBUTE_NORETURN /* empty */ +#endif + +#ifndef ATTRIBUTE_COLD +# define ATTRIBUTE_COLD /* empty */ +#endif + #include <my_attribute.h> #endif /* MY_COMPILER_INCLUDED */ diff --git a/include/wsrep.h b/include/wsrep.h index 532e4339f10..0c06bb32b31 100644 --- a/include/wsrep.h +++ b/include/wsrep.h @@ -45,6 +45,10 @@ #define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) #define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) +#define WSREP_SYNC_WAIT(thd_, before_) \ + { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto error; } + #else #define IF_WSREP(A,B) B #define DBUG_ASSERT_IF_WSREP(A) @@ -55,6 +59,8 @@ #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) -#endif +#define WSREP_SYNC_WAIT(thd_, before_) + +#endif /* WITH_WSREP */ -#endif /* WSERP_INCLUDED */ +#endif /* WSREP_INCLUDED */ diff --git a/mysql-test/include/fail_start_mysqld.inc b/mysql-test/include/fail_start_mysqld.inc new file mode 100644 index 00000000000..bb1085b5dd7 --- /dev/null +++ b/mysql-test/include/fail_start_mysqld.inc @@ -0,0 +1,18 @@ +# ==== Usage ==== +# +# [--let $restart_parameters= --innodb-force-recovery=0 --innodb-read-only=1] +# [--let $mysqld_stub_cmd= $MYSQLD_LAST_CMD] +# [--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err] +# --source include/fail_restart_mysqld.inc + +# Evaluate the default of $error_log +if (!$error_log) +{ + --let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err +} + +--error 1 +--exec $mysqld_stub_cmd $restart_parameters >> $error_log 2>&1 + +# As the server is stopped +--disable_reconnect diff --git a/mysql-test/include/galera_cluster.inc b/mysql-test/include/galera_cluster.inc index bc652225722..c1834c3c26f 100644 --- a/mysql-test/include/galera_cluster.inc +++ b/mysql-test/include/galera_cluster.inc @@ -8,3 +8,5 @@ --let $galera_cluster_size = 2 --source include/galera_init.inc + +--source include/have_innodb.inc diff --git a/mysql-test/include/innodb_undo_tablespaces.combinations b/mysql-test/include/innodb_undo_tablespaces.combinations new file mode 100644 index 00000000000..0ac7a6e2d05 --- /dev/null +++ b/mysql-test/include/innodb_undo_tablespaces.combinations @@ -0,0 +1,5 @@ +[undo0] +innodb-undo-tablespaces=0 + +[undo3] +innodb-undo-tablespaces=3 diff --git a/mysql-test/include/innodb_undo_tablespaces.inc b/mysql-test/include/innodb_undo_tablespaces.inc new file mode 100644 index 00000000000..b109fcc4f0e --- /dev/null +++ b/mysql-test/include/innodb_undo_tablespaces.inc @@ -0,0 +1,3 @@ +# The goal of including this file is to enable innodb_undo_tablespaces combinations +# (see include/innodb_undo_tablespaces.combinations) + diff --git a/mysql-test/include/shutdown_mysqld.inc b/mysql-test/include/shutdown_mysqld.inc index c96e69fc158..c8ab6d00f0d 100644 --- a/mysql-test/include/shutdown_mysqld.inc +++ b/mysql-test/include/shutdown_mysqld.inc @@ -1,3 +1,17 @@ +# ==== Usage ==== +# +# [--let $shutdown_timeout= 30] +# [--let $allow_rpl_inited= 1] +# --source include/shutdown_mysqld.inc + +# The default value is empty +--let $server_shutdown_timeout= + +if ($shutdown_timeout) +{ + --let $server_shutdown_timeout= $shutdown_timeout +} + # This is the first half of include/restart_mysqld.inc. if ($rpl_inited) { diff --git a/mysql-test/include/start_mysqld.inc b/mysql-test/include/start_mysqld.inc index e31f26aad8c..04dff714d49 100644 --- a/mysql-test/include/start_mysqld.inc +++ b/mysql-test/include/start_mysqld.inc @@ -16,6 +16,9 @@ if (!$restart_parameters) # Call script that will poll the server waiting for it to be back online again --source include/wait_until_connected_again.inc +# Wait for wsrep +--source include/wait_wsrep_ready.inc + # Turn off reconnect again --disable_reconnect diff --git a/mysql-test/include/wait_wsrep_ready.inc b/mysql-test/include/wait_wsrep_ready.inc new file mode 100644 index 00000000000..2dd1ef7f1ab --- /dev/null +++ b/mysql-test/include/wait_wsrep_ready.inc @@ -0,0 +1,18 @@ +# +# If the wsrep plugin is loaded, wait until the wsrep provider becomes +# ready for use. +# + +--disable_query_log +--disable_result_log + +if (`SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'wsrep' AND PLUGIN_STATUS='ACTIVE'`) +{ + if (`SELECT @@GLOBAL.WSREP_ON`) + { + --source include/galera_wait_ready.inc + } +} + +--enable_query_log +--enable_result_log diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0365ec6f1f5..c58904f5d4e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -199,6 +199,7 @@ my @DEFAULT_SUITES= qw( unit- vcol- wsrep- + galera- ); my $opt_suites; @@ -3092,14 +3093,16 @@ sub mysql_install_db { mtr_add_arg($args, "--bootstrap"); mtr_add_arg($args, "--basedir=%s", $install_basedir); mtr_add_arg($args, "--datadir=%s", $install_datadir); + mtr_add_arg($args, "--plugin-dir=%s", $plugindir); mtr_add_arg($args, "--default-storage-engine=myisam"); - mtr_add_arg($args, "--skip-plugin-$_") for @optional_plugins; + mtr_add_arg($args, "--loose-skip-plugin-$_") for @optional_plugins; # starting from 10.0 bootstrap scripts require InnoDB mtr_add_arg($args, "--loose-innodb"); mtr_add_arg($args, "--loose-innodb-log-file-size=5M"); mtr_add_arg($args, "--disable-sync-frm"); mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/"); mtr_add_arg($args, "--core-file"); + mtr_add_arg($args, "--console"); if ( $opt_debug ) { @@ -3118,13 +3121,6 @@ sub mysql_install_db { mtr_add_arg($args, $extra_opt); } } - # InnoDB options can come not only from the command line, but also - # from option files or combinations - foreach my $extra_opt ( @$extra_opts ) { - if ($extra_opt =~ /--innodb/) { - mtr_add_arg($args, $extra_opt); - } - } # If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g., # configure --disable-grant-options), mysqld will not recognize the @@ -3139,98 +3135,108 @@ sub mysql_install_db { # ---------------------------------------------------------------------- $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args); - + # Extra options can come not only from the command line, but also + # from option files or combinations. We want them on a command line + # that is executed now, because otherwise the datadir might be + # incompatible with the test settings, but not on the general + # $MYSQLD_BOOTSTRAP_CMD line + foreach my $extra_opt ( @$extra_opts ) { + mtr_add_arg($args, $extra_opt); + } # ---------------------------------------------------------------------- # Create the bootstrap.sql file # ---------------------------------------------------------------------- - my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql"; + my $bootstrap_sql_file= "$opt_vardir/log/bootstrap.sql"; - if ($opt_boot_gdb) { - gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), - $bootstrap_sql_file); - } - if ($opt_boot_dbx) { - dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), - $bootstrap_sql_file); - } - if ($opt_boot_ddd) { - ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), - $bootstrap_sql_file); - } - - my $path_sql= my_find_file($install_basedir, - ["mysql", "sql/share", "share/mariadb", - "share/mysql", "share", "scripts"], - "mysql_system_tables.sql", - NOT_REQUIRED); - - if (-f $path_sql ) + if (! -e $bootstrap_sql_file) { - my $sql_dir= dirname($path_sql); - # Use the mysql database for system tables - mtr_tofile($bootstrap_sql_file, "use mysql;\n"); - - # Add the offical mysql system tables - # for a production system - mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql", - $bootstrap_sql_file); + if ($opt_boot_gdb) { + gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_dbx) { + dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_ddd) { + ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } - # Add the performance tables - # for a production system - mtr_appendfile_to_file("$sql_dir/mysql_performance_tables.sql", - $bootstrap_sql_file); + my $path_sql= my_find_file($install_basedir, + ["mysql", "sql/share", "share/mariadb", + "share/mysql", "share", "scripts"], + "mysql_system_tables.sql", + NOT_REQUIRED); - # Add the mysql system tables initial data - # for a production system - mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", - $bootstrap_sql_file); + if (-f $path_sql ) + { + my $sql_dir= dirname($path_sql); + # Use the mysql database for system tables + mtr_tofile($bootstrap_sql_file, "use mysql;\n"); + + # Add the offical mysql system tables + # for a production system + mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql", + $bootstrap_sql_file); + + # Add the performance tables + # for a production system + mtr_appendfile_to_file("$sql_dir/mysql_performance_tables.sql", + $bootstrap_sql_file); + + # Add the mysql system tables initial data + # for a production system + mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql", + $bootstrap_sql_file); + + # Add test data for timezone - this is just a subset, on a real + # system these tables will be populated either by mysql_tzinfo_to_sql + # or by downloading the timezone table package from our website + mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql", + $bootstrap_sql_file); + + # Fill help tables, just an empty file when running from bk repo + # but will be replaced by a real fill_help_tables.sql when + # building the source dist + mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql", + $bootstrap_sql_file); + + # mysql.gtid_slave_pos was created in InnoDB, but many tests + # run without InnoDB. Alter it to MyISAM now + mtr_tofile($bootstrap_sql_file, "ALTER TABLE gtid_slave_pos ENGINE=MyISAM;\n"); + } + else + { + # Install db from init_db.sql that exist in early 5.1 and 5.0 + # versions of MySQL + my $init_file= "$install_basedir/mysql-test/lib/init_db.sql"; + mtr_report(" - from '$init_file'"); + my $text= mtr_grab_file($init_file) or + mtr_error("Can't open '$init_file': $!"); + + mtr_tofile($bootstrap_sql_file, + sql_to_bootstrap($text)); + } - # Add test data for timezone - this is just a subset, on a real - # system these tables will be populated either by mysql_tzinfo_to_sql - # or by downloading the timezone table package from our website - mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql", - $bootstrap_sql_file); + # Remove anonymous users + mtr_tofile($bootstrap_sql_file, + "DELETE FROM mysql.user where user= '';\n"); - # Fill help tables, just an empty file when running from bk repo - # but will be replaced by a real fill_help_tables.sql when - # building the source dist - mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql", - $bootstrap_sql_file); + # Create mtr database + mtr_tofile($bootstrap_sql_file, + "CREATE DATABASE mtr CHARSET=latin1;\n"); - # mysql.gtid_slave_pos was created in InnoDB, but many tests - # run without InnoDB. Alter it to MyISAM now - mtr_tofile($bootstrap_sql_file, "ALTER TABLE gtid_slave_pos ENGINE=MyISAM;\n"); - } - else - { - # Install db from init_db.sql that exist in early 5.1 and 5.0 - # versions of MySQL - my $init_file= "$install_basedir/mysql-test/lib/init_db.sql"; - mtr_report(" - from '$init_file'"); - my $text= mtr_grab_file($init_file) or - mtr_error("Can't open '$init_file': $!"); + # Add help tables and data for warning detection and supression + mtr_tofile($bootstrap_sql_file, + sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql"))); + # Add procedures for checking server is restored after testcase mtr_tofile($bootstrap_sql_file, - sql_to_bootstrap($text)); + sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql"))); } - # Remove anonymous users - mtr_tofile($bootstrap_sql_file, - "DELETE FROM mysql.user where user= '';\n"); - - # Create mtr database - mtr_tofile($bootstrap_sql_file, - "CREATE DATABASE mtr CHARSET=latin1;\n"); - - # Add help tables and data for warning detection and supression - mtr_tofile($bootstrap_sql_file, - sql_to_bootstrap(mtr_grab_file("include/mtr_warnings.sql"))); - - # Add procedures for checking server is restored after testcase - mtr_tofile($bootstrap_sql_file, - sql_to_bootstrap(mtr_grab_file("include/mtr_check.sql"))); - # Log bootstrap command my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log"; mtr_tofile($path_bootstrap_log, @@ -5155,6 +5161,11 @@ sub mysqld_start ($$) { # Remember options used when starting $mysqld->{'started_opts'}= $extra_opts; + # "Dynamic" version of MYSQLD_CMD is reevaluated with each mysqld_start. + # Use it to restart the server at testing a failing server start (e.g + # due to incompatible options). + $ENV{'MYSQLD_LAST_CMD'}= "$exe @$args"; + return; } diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 92df7bc577e..f7f87b810ce 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -2125,6 +2125,58 @@ t1 CREATE TABLE `t1` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 DROP TABLE t1; # +# MDEV-8960 Can't refer the same column twice in one ALTER TABLE +# +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` SET DEFAULT 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` int(11) NOT NULL DEFAULT 2 +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +CREATE TABLE t1 ( +`a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT, +MODIFY COLUMN `consultant_id` BIGINT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `consultant_id` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +# # Start of 10.1 tests # # diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index ac7de538f86..7917199611a 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1234,7 +1234,7 @@ character-sets-dir MYSQL_CHARSETSDIR/ chroot (No default value) completion-type NO_CHAIN concurrent-insert AUTO -console FALSE +console TRUE date-format %Y-%m-%d datetime-format %Y-%m-%d %H:%i:%s deadlock-search-depth-long 15 diff --git a/mysql-test/r/tc_heuristic_recover.result b/mysql-test/r/tc_heuristic_recover.result new file mode 100644 index 00000000000..8fe3643b174 --- /dev/null +++ b/mysql-test/r/tc_heuristic_recover.result @@ -0,0 +1,39 @@ +call mtr.add_suppression("Can't init tc log"); +call mtr.add_suppression("Found 1 prepared transactions!"); +call mtr.add_suppression("Aborting"); +set debug_sync='RESET'; +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +FLUSH TABLES; +connect con1,localhost,root,,; +set debug_sync='ha_commit_trans_after_prepare WAIT_FOR go'; +INSERT INTO t1 VALUES (1);; +connection default; +# Prove that no COMMIT or ROLLBACK occurred yet. +SELECT * FROM t1; +i +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +i +1 +# Kill the server +FOUND 1 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +NOT FOUND /\[ERROR\] Can\'t init tc log/ in mysqld.1.err +FOUND 2 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +FOUND 1 /\[ERROR\] Can\'t init tc log/ in mysqld.1.err +FOUND 1 /Please restart mysqld without --tc-heuristic-recover/ in mysqld.1.err +FOUND 3 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +FOUND 2 /\[ERROR\] Can\'t init tc log/ in mysqld.1.err +FOUND 2 /Please restart mysqld without --tc-heuristic-recover/ in mysqld.1.err +FOUND 3 /was in the XA prepared state/ in mysqld.1.err +FOUND 1 /Found 1 prepared transactions!/ in mysqld.1.err +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT * FROM t1; +i +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +i +DROP TABLE t1; diff --git a/mysql-test/r/wait_timeout.result b/mysql-test/r/wait_timeout.result index aa145ecf39b..8e5e5147f8b 100644 --- a/mysql-test/r/wait_timeout.result +++ b/mysql-test/r/wait_timeout.result @@ -35,3 +35,9 @@ SELECT 3; SET @@global.wait_timeout= <start_value>; disconnect con1; connect default,localhost,root,,test,,; +set global log_warnings=2; +connect foo,localhost,root; +set @@wait_timeout=1; +connection default; +FOUND 1 /Aborted.*Got timeout reading communication packets/ in mysqld.1.err +set global log_warnings=@@log_warnings; diff --git a/mysql-test/r/wait_timeout_not_windows.result b/mysql-test/r/wait_timeout_not_windows.result deleted file mode 100644 index f31dec1b4ba..00000000000 --- a/mysql-test/r/wait_timeout_not_windows.result +++ /dev/null @@ -1,6 +0,0 @@ -set global log_warnings=2; -connect foo,localhost,root; -set @@wait_timeout=1; -connection default; -FOUND 1 /Aborted.*Got timeout reading communication packets/ in mysqld.1.err -set global log_warnings=@@log_warnings; diff --git a/mysql-test/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index d92d3495cb8..abbb82d51f6 100644 --- a/mysql-test/suite/encryption/disabled.def +++ b/mysql-test/suite/encryption/disabled.def @@ -12,3 +12,4 @@ innodb_scrub : MDEV-8139 scrubbing does not work reliably innodb_scrub_background : MDEV-8139 scrubbing does not work reliably + diff --git a/mysql-test/suite/encryption/r/innodb-first-page-read.result b/mysql-test/suite/encryption/r/innodb-first-page-read.result index 9b57b9de5f9..6df80e8223d 100644 --- a/mysql-test/suite/encryption/r/innodb-first-page-read.result +++ b/mysql-test/suite/encryption/r/innodb-first-page-read.result @@ -1,5 +1,6 @@ SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; +FLUSH STATUS; create database innodb_test; use innodb_test; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; @@ -50,40 +51,48 @@ insert into innodb_datadir1 select * from innodb_normal; insert into innodb_datadir2 select * from innodb_normal; insert into innodb_datadir3 select * from innodb_normal; commit; +FLUSH STATUS; # Restart server and see how many page 0's are read -# result should be less than actual number of tables -# i.e. < 23 + 3 = 26 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +# result should actual number of tables except remote tables could be read twice +# i.e. < 23 + 3*2 = 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 set global innodb_encrypt_tables=OFF; # wait until tables are decrypted -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +# result should be actual number of tables except remote tables could be read twice +# i.e. < 23 + 3*2 = 29 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 +FLUSH STATUS; # restart and see number read page 0 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; +VARIABLE_VALUE <= 29 +1 drop database innodb_test; -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 26 +FLUSH STATUS; diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index a642ad20183..680db692c17 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -2,9 +2,6 @@ SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_ NAME SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME -mysql/innodb_table_stats -mysql/innodb_index_stats -innodb_system create database enctests; use enctests; create table t1(a int not null primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/encryption/r/innodb-redo-badkey.result b/mysql-test/suite/encryption/r/innodb-redo-badkey.result index 8c441d64d9c..ee803261b90 100644 --- a/mysql-test/suite/encryption/r/innodb-redo-badkey.result +++ b/mysql-test/suite/encryption/r/innodb-redo-badkey.result @@ -1,6 +1,6 @@ call mtr.add_suppression("Plugin 'file_key_management'"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); -call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file test/t[1-4] cannot be decrypted"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file .*test/t[1-4]\\.ibd cannot be decrypted"); call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]"); call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]"); call mtr.add_suppression("InnoDB: Plugin initialization aborted"); diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result index 26c77499d25..72f2632ba26 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_encryption.result @@ -6,25 +6,26 @@ innodb_encrypt_tables ON innodb_encryption_rotate_key_age 15 innodb_encryption_rotation_iops 100 innodb_encryption_threads 4 -DESCRIBE INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; -Field Type Null Key Default Extra -SPACE int(11) unsigned NO 0 -NAME varchar(655) YES NULL -ENCRYPTION_SCHEME int(11) unsigned NO 0 -KEYSERVER_REQUESTS int(11) unsigned NO 0 -MIN_KEY_VERSION int(11) unsigned NO 0 -CURRENT_KEY_VERSION int(11) unsigned NO 0 -KEY_ROTATION_PAGE_NUMBER bigint(21) unsigned YES NULL -KEY_ROTATION_MAX_PAGE_NUMBER bigint(21) unsigned YES NULL -CURRENT_KEY_ID int(11) unsigned NO 0 -ROTATING_OR_FLUSHING int(1) unsigned NO 0 -# Wait max 5 min for key encryption threads to encrypt one space -# Success! -# Wait max 10 min for key encryption threads to encrypt all space +SET GLOBAL innodb_encrypt_tables = ON; +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +innodb_system # Success! # Now turn off encryption and wait for threads to decrypt everything SET GLOBAL innodb_encrypt_tables = off; -# Wait max 10 min for key encryption threads to decrypt all space +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +innodb_system +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME # Success! # Shutdown innodb_encryption_threads SET GLOBAL innodb_encryption_threads=0; @@ -32,16 +33,24 @@ SET GLOBAL innodb_encryption_threads=0; # since threads are off tables should remain unencrypted SET GLOBAL innodb_encrypt_tables = on; # Wait 15s to check that nothing gets encrypted +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +innodb_system +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME # Success! # Startup innodb_encryption_threads SET GLOBAL innodb_encryption_threads=@start_global_value; -# Wait 1 min to check that it start encrypting again -# Success! -# -# Check that restart with encryption turned off works -# even if spaces are encrypted -# -# First wait max 10 min for key encryption threads to encrypt all spaces +# Wait max 10 min for key encryption threads to encrypt all spaces +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +innodb_system # Success! # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 SHOW VARIABLES LIKE 'innodb_encrypt%'; @@ -51,9 +60,10 @@ innodb_encrypt_tables OFF innodb_encryption_rotate_key_age 15 innodb_encryption_rotation_iops 100 innodb_encryption_threads 0 -SELECT COUNT(*) > 0 as should_be_1 -FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION -WHERE MIN_KEY_VERSION <> 0; -should_be_1 -1 -# Restart mysqld again...with default options +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +NAME +mysql/innodb_table_stats +mysql/innodb_index_stats +innodb_system +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +NAME diff --git a/mysql-test/suite/encryption/r/innodb_lotoftables.result b/mysql-test/suite/encryption/r/innodb_lotoftables.result index cf5724b527a..da07a52f8c3 100644 --- a/mysql-test/suite/encryption/r/innodb_lotoftables.result +++ b/mysql-test/suite/encryption/r/innodb_lotoftables.result @@ -17,10 +17,9 @@ commit work; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +# should be empty +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; +NAME create database innodb_encrypted_2; use innodb_encrypted_2; show status like 'innodb_pages0_read%'; @@ -32,14 +31,112 @@ set autocommit=1; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +# should contain 0 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME create database innodb_encrypted_3; use innodb_encrypted_3; show status like 'innodb_pages0_read%'; @@ -51,33 +148,626 @@ set autocommit=1; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +# should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 use test; show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encryption_threads=4; -# Wait until all encrypted tables have been encrypted -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 3 @@ -127,26 +817,416 @@ Innodb_pages0_read 303 show status like 'innodb_pages0_read%'; Variable_name Value Innodb_pages0_read 303 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encryption_threads=4; -# Wait until all default encrypted tables have been decrypted -# should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -100 -# should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -COUNT(*) -200 -show status like 'innodb_pages0_read%'; -Variable_name Value -Innodb_pages0_read 303 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_2/t_1 +innodb_encrypted_2/t_10 +innodb_encrypted_2/t_100 +innodb_encrypted_2/t_11 +innodb_encrypted_2/t_12 +innodb_encrypted_2/t_13 +innodb_encrypted_2/t_14 +innodb_encrypted_2/t_15 +innodb_encrypted_2/t_16 +innodb_encrypted_2/t_17 +innodb_encrypted_2/t_18 +innodb_encrypted_2/t_19 +innodb_encrypted_2/t_2 +innodb_encrypted_2/t_20 +innodb_encrypted_2/t_21 +innodb_encrypted_2/t_22 +innodb_encrypted_2/t_23 +innodb_encrypted_2/t_24 +innodb_encrypted_2/t_25 +innodb_encrypted_2/t_26 +innodb_encrypted_2/t_27 +innodb_encrypted_2/t_28 +innodb_encrypted_2/t_29 +innodb_encrypted_2/t_3 +innodb_encrypted_2/t_30 +innodb_encrypted_2/t_31 +innodb_encrypted_2/t_32 +innodb_encrypted_2/t_33 +innodb_encrypted_2/t_34 +innodb_encrypted_2/t_35 +innodb_encrypted_2/t_36 +innodb_encrypted_2/t_37 +innodb_encrypted_2/t_38 +innodb_encrypted_2/t_39 +innodb_encrypted_2/t_4 +innodb_encrypted_2/t_40 +innodb_encrypted_2/t_41 +innodb_encrypted_2/t_42 +innodb_encrypted_2/t_43 +innodb_encrypted_2/t_44 +innodb_encrypted_2/t_45 +innodb_encrypted_2/t_46 +innodb_encrypted_2/t_47 +innodb_encrypted_2/t_48 +innodb_encrypted_2/t_49 +innodb_encrypted_2/t_5 +innodb_encrypted_2/t_50 +innodb_encrypted_2/t_51 +innodb_encrypted_2/t_52 +innodb_encrypted_2/t_53 +innodb_encrypted_2/t_54 +innodb_encrypted_2/t_55 +innodb_encrypted_2/t_56 +innodb_encrypted_2/t_57 +innodb_encrypted_2/t_58 +innodb_encrypted_2/t_59 +innodb_encrypted_2/t_6 +innodb_encrypted_2/t_60 +innodb_encrypted_2/t_61 +innodb_encrypted_2/t_62 +innodb_encrypted_2/t_63 +innodb_encrypted_2/t_64 +innodb_encrypted_2/t_65 +innodb_encrypted_2/t_66 +innodb_encrypted_2/t_67 +innodb_encrypted_2/t_68 +innodb_encrypted_2/t_69 +innodb_encrypted_2/t_7 +innodb_encrypted_2/t_70 +innodb_encrypted_2/t_71 +innodb_encrypted_2/t_72 +innodb_encrypted_2/t_73 +innodb_encrypted_2/t_74 +innodb_encrypted_2/t_75 +innodb_encrypted_2/t_76 +innodb_encrypted_2/t_77 +innodb_encrypted_2/t_78 +innodb_encrypted_2/t_79 +innodb_encrypted_2/t_8 +innodb_encrypted_2/t_80 +innodb_encrypted_2/t_81 +innodb_encrypted_2/t_82 +innodb_encrypted_2/t_83 +innodb_encrypted_2/t_84 +innodb_encrypted_2/t_85 +innodb_encrypted_2/t_86 +innodb_encrypted_2/t_87 +innodb_encrypted_2/t_88 +innodb_encrypted_2/t_89 +innodb_encrypted_2/t_9 +innodb_encrypted_2/t_90 +innodb_encrypted_2/t_91 +innodb_encrypted_2/t_92 +innodb_encrypted_2/t_93 +innodb_encrypted_2/t_94 +innodb_encrypted_2/t_95 +innodb_encrypted_2/t_96 +innodb_encrypted_2/t_97 +innodb_encrypted_2/t_98 +innodb_encrypted_2/t_99 +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +NAME +innodb_encrypted_3/t_1 +innodb_encrypted_3/t_10 +innodb_encrypted_3/t_100 +innodb_encrypted_3/t_11 +innodb_encrypted_3/t_12 +innodb_encrypted_3/t_13 +innodb_encrypted_3/t_14 +innodb_encrypted_3/t_15 +innodb_encrypted_3/t_16 +innodb_encrypted_3/t_17 +innodb_encrypted_3/t_18 +innodb_encrypted_3/t_19 +innodb_encrypted_3/t_2 +innodb_encrypted_3/t_20 +innodb_encrypted_3/t_21 +innodb_encrypted_3/t_22 +innodb_encrypted_3/t_23 +innodb_encrypted_3/t_24 +innodb_encrypted_3/t_25 +innodb_encrypted_3/t_26 +innodb_encrypted_3/t_27 +innodb_encrypted_3/t_28 +innodb_encrypted_3/t_29 +innodb_encrypted_3/t_3 +innodb_encrypted_3/t_30 +innodb_encrypted_3/t_31 +innodb_encrypted_3/t_32 +innodb_encrypted_3/t_33 +innodb_encrypted_3/t_34 +innodb_encrypted_3/t_35 +innodb_encrypted_3/t_36 +innodb_encrypted_3/t_37 +innodb_encrypted_3/t_38 +innodb_encrypted_3/t_39 +innodb_encrypted_3/t_4 +innodb_encrypted_3/t_40 +innodb_encrypted_3/t_41 +innodb_encrypted_3/t_42 +innodb_encrypted_3/t_43 +innodb_encrypted_3/t_44 +innodb_encrypted_3/t_45 +innodb_encrypted_3/t_46 +innodb_encrypted_3/t_47 +innodb_encrypted_3/t_48 +innodb_encrypted_3/t_49 +innodb_encrypted_3/t_5 +innodb_encrypted_3/t_50 +innodb_encrypted_3/t_51 +innodb_encrypted_3/t_52 +innodb_encrypted_3/t_53 +innodb_encrypted_3/t_54 +innodb_encrypted_3/t_55 +innodb_encrypted_3/t_56 +innodb_encrypted_3/t_57 +innodb_encrypted_3/t_58 +innodb_encrypted_3/t_59 +innodb_encrypted_3/t_6 +innodb_encrypted_3/t_60 +innodb_encrypted_3/t_61 +innodb_encrypted_3/t_62 +innodb_encrypted_3/t_63 +innodb_encrypted_3/t_64 +innodb_encrypted_3/t_65 +innodb_encrypted_3/t_66 +innodb_encrypted_3/t_67 +innodb_encrypted_3/t_68 +innodb_encrypted_3/t_69 +innodb_encrypted_3/t_7 +innodb_encrypted_3/t_70 +innodb_encrypted_3/t_71 +innodb_encrypted_3/t_72 +innodb_encrypted_3/t_73 +innodb_encrypted_3/t_74 +innodb_encrypted_3/t_75 +innodb_encrypted_3/t_76 +innodb_encrypted_3/t_77 +innodb_encrypted_3/t_78 +innodb_encrypted_3/t_79 +innodb_encrypted_3/t_8 +innodb_encrypted_3/t_80 +innodb_encrypted_3/t_81 +innodb_encrypted_3/t_82 +innodb_encrypted_3/t_83 +innodb_encrypted_3/t_84 +innodb_encrypted_3/t_85 +innodb_encrypted_3/t_86 +innodb_encrypted_3/t_87 +innodb_encrypted_3/t_88 +innodb_encrypted_3/t_89 +innodb_encrypted_3/t_9 +innodb_encrypted_3/t_90 +innodb_encrypted_3/t_91 +innodb_encrypted_3/t_92 +innodb_encrypted_3/t_93 +innodb_encrypted_3/t_94 +innodb_encrypted_3/t_95 +innodb_encrypted_3/t_96 +innodb_encrypted_3/t_97 +innodb_encrypted_3/t_98 +innodb_encrypted_3/t_99 use test; drop database innodb_encrypted_1; drop database innodb_encrypted_2; diff --git a/mysql-test/suite/encryption/t/innodb-first-page-read.test b/mysql-test/suite/encryption/t/innodb-first-page-read.test index 1fc07159e05..d661e4565d2 100644 --- a/mysql-test/suite/encryption/t/innodb-first-page-read.test +++ b/mysql-test/suite/encryption/t/innodb-first-page-read.test @@ -7,6 +7,8 @@ SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; --enable_warnings +FLUSH STATUS; + create database innodb_test; use innodb_test; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; @@ -63,16 +65,19 @@ insert into innodb_datadir2 select * from innodb_normal; insert into innodb_datadir3 select * from innodb_normal; commit; +FLUSH STATUS; + --echo # Restart server and see how many page 0's are read --source include/restart_mysqld.inc ---echo # result should be less than actual number of tables ---echo # i.e. < 23 + 3 = 26 -show status like 'innodb_pages0_read%'; +--echo # result should actual number of tables except remote tables could be read twice +--echo # i.e. < 23 + 3*2 = 29 + +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; set global innodb_encrypt_tables=OFF; @@ -80,18 +85,25 @@ set global innodb_encrypt_tables=OFF; --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 --source include/wait_condition.inc -show status like 'innodb_pages0_read%'; +--echo # result should be actual number of tables except remote tables could be read twice +--echo # i.e. < 23 + 3*2 = 29 + +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; + +FLUSH STATUS; --echo # restart and see number read page 0 -- source include/restart_mysqld.inc -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use innodb_test; -show status like 'innodb_pages0_read%'; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; use test; +SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; drop database innodb_test; -show status like 'innodb_pages0_read%'; +FLUSH STATUS; diff --git a/mysql-test/suite/encryption/t/innodb-redo-badkey.test b/mysql-test/suite/encryption/t/innodb-redo-badkey.test index 7f855cba5a9..be8555584bb 100644 --- a/mysql-test/suite/encryption/t/innodb-redo-badkey.test +++ b/mysql-test/suite/encryption/t/innodb-redo-badkey.test @@ -5,7 +5,7 @@ call mtr.add_suppression("Plugin 'file_key_management'"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); -call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file test/t[1-4] cannot be decrypted"); +call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file .*test/t[1-4]\\.ibd cannot be decrypted"); call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]"); call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]"); call mtr.add_suppression("InnoDB: Plugin initialization aborted"); diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test index 50aca2a7260..35c2b3695a9 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_encryption.test @@ -3,6 +3,7 @@ # -- source include/have_innodb.inc -- source include/have_example_key_management_plugin.inc +-- source include/innodb_undo_tablespaces.inc # embedded does not support restart -- source include/not_embedded.inc @@ -11,78 +12,29 @@ SET @start_global_value = @@global.innodb_encryption_threads; SHOW VARIABLES LIKE 'innodb_encrypt%'; -DESCRIBE INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - ---echo # Wait max 5 min for key encryption threads to encrypt one space -let $cnt=300; -while ($cnt) -{ - let $success=`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} ---echo # Success! +SET GLOBAL innodb_encrypt_tables = ON; + +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= 3 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; ---echo # Wait max 10 min for key encryption threads to encrypt all space -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} --echo # Success! --echo # Now turn off encryption and wait for threads to decrypt everything SET GLOBAL innodb_encrypt_tables = off; ---echo # Wait max 10 min for key encryption threads to decrypt all space -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + --echo # Success! --echo # Shutdown innodb_encryption_threads @@ -93,84 +45,32 @@ SET GLOBAL innodb_encryption_threads=0; SET GLOBAL innodb_encrypt_tables = on; --echo # Wait 15s to check that nothing gets encrypted -let $cnt=15; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - real_sleep 1; - dec $cnt; - } - if (!$success) - { - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - -- die Failure, tablespace getting encrypted even if innodb_encryption_threads=0 - } -} +--let $wait_timeout= 15 +--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; + --echo # Success! --echo # Startup innodb_encryption_threads SET GLOBAL innodb_encryption_threads=@start_global_value; ---echo # Wait 1 min to check that it start encrypting again -let $cnt=60; -while ($cnt) -{ - let $success=`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 OR KEY_ROTATION_PAGE_NUMBER IS NOT NULL`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} ---echo # Success! +--echo # Wait max 10 min for key encryption threads to encrypt all spaces +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >=3 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; ---echo # ---echo # Check that restart with encryption turned off works ---echo # even if spaces are encrypted ---echo # ---echo # First wait max 10 min for key encryption threads to encrypt all spaces -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} --echo # Success! --echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0 -- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0 -- source include/restart_mysqld.inc SHOW VARIABLES LIKE 'innodb_encrypt%'; -SELECT COUNT(*) > 0 as should_be_1 -FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION -WHERE MIN_KEY_VERSION <> 0; ---echo # Restart mysqld again...with default options --- let $restart_parameters= --- source include/restart_mysqld.inc +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; diff --git a/mysql-test/suite/encryption/t/innodb_lotoftables.test b/mysql-test/suite/encryption/t/innodb_lotoftables.test index 6e87c93df4b..cd3c6a30c07 100644 --- a/mysql-test/suite/encryption/t/innodb_lotoftables.test +++ b/mysql-test/suite/encryption/t/innodb_lotoftables.test @@ -48,9 +48,8 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 - -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; +--echo # should be empty +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%'; # # This will create 100 tables that are encrypted always @@ -84,10 +83,10 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +--echo # should contain 0 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; # # This will create 100 tables that are not encrypted @@ -121,45 +120,26 @@ show status like 'innodb_pages0_read%'; # # Verify # ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +--echo # should contain 100 tables +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; use test; show status like 'innodb_pages0_read%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; SET GLOBAL innodb_encrypt_tables = on; SET GLOBAL innodb_encryption_threads=4; ---echo # Wait until all encrypted tables have been encrypted -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; show status like 'innodb_pages0_read%'; --echo # Success! @@ -226,40 +206,19 @@ while ($tables) show status like 'innodb_pages0_read%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; SET GLOBAL innodb_encrypt_tables = off; SET GLOBAL innodb_encryption_threads=4; ---echo # Wait until all default encrypted tables have been decrypted -let $cnt=600; -while ($cnt) -{ - let $success=`SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`; - if ($success) - { - let $cnt=0; - } - if (!$success) - { - real_sleep 1; - dec $cnt; - } -} -if (!$success) -{ - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; - SHOW STATUS LIKE 'innodb_encryption%'; - -- die Timeout waiting for encryption threads -} +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) = 100 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc ---echo # should be 100 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%'; ---echo # should be 200 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%'; -show status like 'innodb_pages0_read%'; + +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%' ORDER BY NAME; # # Cleanup diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 5a10d161211..423c83208f8 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -1,47 +1,58 @@ -galera_wsrep_provider_unset_set : lp1379204 'Unsupported protocol downgrade: incremental data collection disabled. Expect abort.' -galera_kill_nochanges : mysql-wsrep#24 Galera server does not restart properly if killed -galera_bf_abort_for_update : mysql-wsrep#26 SELECT FOR UPDATE sometimes allowed to proceed in the face of a concurrent update -galera_toi_ddl_fk_insert : qa#39 galera_toi_ddl_fk_insert fails sporadically -galera_binlog_row_image : MDEV-7471 - Enable binlog_row_image parameter in MariaDB -galera_binlog_rows_query_log_events : Unknown system variable 'binlog_rows_query_log_events' (see annotate_rows_log_event) - -galera_ist_mysqldump : Lost connection to MySQL server during query -galera_ist_xtrabackup-v2 : mysqltest failed but provided no output -galera_ist_innodb_flush_logs : mysqltest failed but provided no output -galera_sst_mysqldump : query 'show status' failed with wrong errno 1927 -galera_as_master_gtid : Needs to be re-worked -galera_as_master_gtid_change_master : Needs to be re-worked -galera_migrate : query 'let $success= `$wait_condition`' failed: 1146 -galera_var_notify_cmd : Result content mismatch -query_cache : Fails intermittently due to content mismatch. Needs to be investigated -basic : Fails intermittently without providing any output. Needs to be investigated -galera_var_auto_inc_control_on : Failing sporadically with content mismatch -galera_parallel_simple : Failing sporadically -galera_bf_abort : Failing sporadically -galera_log_output_csv : Failing sporadically -galera_as_slave_preordered : wsrep-preordered is not available in MariaDB Galera cluster -galera_gra_log : TODO: investigate -galera_as_slave_replication_bundle : TODO: investigate -galera_ssl_upgrade : TODO: investigate -mysql-wsrep#90 : TODO: investigate -galera_flush : mysql-wsrep/issues/229 -galera_transaction_read_only : mysql-wsrep/issues/229 -galera_gcs_fragment : Incorrect arguments to SET -galera_flush_local : Fails sporadically -galera_binlog_stmt_autoinc : TODO: investigate -galera_concurrent_ctas : Test times out, investigate -MW-286 : TODO: investigate -galera_sst_xtrabackup-v2-options : TODO: Fix test case -galera_sst_xtrabackup-v2 : MDEV-11208 -galera_sst_xtrabackup-v2_encrypt_with_key : MDEV-11208 -mysql-wsrep#33 : TODO: investigate +############################################################################## +# +# List the test cases that are to be disabled temporarily. +# +# Separate the test case name and the comment with ':'. +# +# <testcasename> : MDEV-<xxxx> <comment> +# +# Do not use any TAB characters for whitespace. +# +############################################################################## +MW-336 : MDEV-13549 Galera test failures +galera_gra_log : MDEV-13549 Galera test failures +galera_flush_local : MDEV-13549 Galera test failures +galera_flush : MDEV-13549 Galera test failures +MW-329 : MDEV-13549 Galera test failures +galera_account_management : MariaDB 10.0 does not support ALTER USER +galera_binlog_row_image : MariaDB 10.0 does not support binlog_row_image +galera_binlog_rows_query_log_events: MariaDB does not support binlog_rows_query_log_events +GAL-419 : MDEV-13549 Galera test failures +galera_toi_ddl_fk_insert : MDEV-13549 Galera test failures +galera_var_notify_cmd : MDEV-13549 Galera test failures +galera_var_slave_threads : MDEV-13549 Galera test failures +mysql-wsrep#90 : MDEV-13549 Galera test failures +galera_as_master_gtid : Requires MySQL GTID +galera_as_master_gtid_change_master : Requires MySQL GTID +galera_as_slave_replication_bundle : MDEV-13549 Galera test failures +galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB +galera_gcs_fragment : MDEV-13549 Galera test failures +galera_gcache_recover : MDEV-13549 Galera test failures +galera_gcache_recover_full_gcache : MDEV-13549 Galera test failures +galera_gcache_recover_manytrx : MDEV-13549 Galera test failures +galera_ist_mysqldump : MDEV-13549 Galera test failures +mysql-wsrep#31 : MDEV-13549 Galera test failures +galera_migrate : MariaDB 10.0 does not support START SLAVE USER +galera_concurrent_ctas : MDEV-13549 Galera test failures +galera_bf_abort_for_update : MDEV-13549 Galera test failures +galera_wsrep_desync_wsrep_on : MDEV-13549 Galera test failures +galera_ssl_upgrade : MDEV-13549 Galera test failures +mysql-wsrep#33 : MDEV-13549 Galera test failures +galera_var_auto_inc_control_on : MDEV-13549 Galera test failures +MW-44 : MDEV-13549 Galera test failures +galera_var_retry_autocommit : MDEV-13549 Galera test failures +pxc-421 : MDEV-13549 Galera test failures +lp1376747-2 : MDEV-13549 Galera test failures +lp1376747 : MDEV-13549 Galera test failures +galera_toi_ddl_nonconflicting : MDEV-13549 Galera test failures +galera_parallel_simple : MDEV-13549 Galera test failures +galera_admin : MDEV-13549 Galera test failures +galera_var_max_ws_rows : MDEV-13549 Galera test failures 10.1 +MW-286 : MDEV-13549 Galera test failures 10.1 +galera_as_master: MDEV-13549 Galera test failures 10.1 +galera_pc_ignore_sb : MDEV-13549 Galera test failures 10.1 +galera_lock_table : MDEV-13549 Galera test failures 10.1 +MW-284 : MDEV-13549 Galera test failures 10.1 +galera_as_slave : MDEV-13549 Galera test failures 10.1 galera_var_innodb_disallow_writes : MDEV-10949 -MW-258 : MDEV-11229 -galera_as_master : MDEV-11229 -MW-44 : MDEV-11229 -galera_gcs_fc_limit : MDEV-11229 -galera_roles : MDEV-11229 -galera_lock_table : MDEV-11229 -GAL-480 : Investigate -galera_fk_no_pk :Investigate -galera_account_management : Investigate +galera_kill_applier : race condition at the start of the test diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index f120775d433..b24f3603894 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -9,7 +9,7 @@ default-storage-engine=innodb wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 # enforce read-committed characteristics across the cluster -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.1] #galera_port=@OPT.port @@ -29,7 +29,7 @@ wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#gale # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_master.cnf b/mysql-test/suite/galera/galera_2nodes_as_master.cnf index 68c0cca29a2..33bfc475721 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_master.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_master.cnf @@ -29,7 +29,7 @@ wsrep_node_address=127.0.0.1 wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.2] #galera_port=@OPT.port @@ -48,7 +48,7 @@ wsrep_node_address=127.0.0.1 wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.3] server-id=3 diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf index 716a790fea6..f68fe524904 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_master_slave.cnf @@ -29,7 +29,7 @@ wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = P # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port @@ -49,7 +49,7 @@ wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = P # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf index 5f0af2e58e5..d5490280ab2 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_master_with_repl_filter.cnf @@ -23,7 +23,7 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port' # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port @@ -49,7 +49,7 @@ wsrep_provider_options='base_port=@mysqld.2.#galera_port' # enforce read-committed characteristics across the cluster wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 wsrep_node_address=127.0.0.1 wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port diff --git a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf index 6d71649c274..4d9e39d2aae 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf @@ -33,7 +33,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=2 [mysqld.3] @@ -57,7 +57,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=3 [ENV] diff --git a/mysql-test/suite/galera/galera_3nodes_as_slave.cnf b/mysql-test/suite/galera/galera_3nodes_as_slave.cnf index aed33ba365b..ac1ca34e242 100644 --- a/mysql-test/suite/galera/galera_3nodes_as_slave.cnf +++ b/mysql-test/suite/galera/galera_3nodes_as_slave.cnf @@ -30,7 +30,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=2 [mysqld.3] @@ -51,7 +51,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=3 [mysqld.4] @@ -72,7 +72,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port' # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 server-id=4 [ENV] diff --git a/mysql-test/suite/galera/galera_4nodes.cnf b/mysql-test/suite/galera/galera_4nodes.cnf index c93282e6c47..1c195afd54b 100644 --- a/mysql-test/suite/galera/galera_4nodes.cnf +++ b/mysql-test/suite/galera/galera_4nodes.cnf @@ -10,7 +10,7 @@ wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.1] #galera_port=@OPT.port diff --git a/mysql-test/suite/galera/r/GAL-401.result b/mysql-test/suite/galera/r/GAL-401.result index b2ecd1c2bfa..3b55b7589b7 100644 --- a/mysql-test/suite/galera/r/GAL-401.result +++ b/mysql-test/suite/galera/r/GAL-401.result @@ -2,15 +2,18 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; connection node_2; SET @@global.wsrep_desync = 1; SET SESSION wsrep_dirty_reads=1; +SET SESSION wsrep_sync_wait=0; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); connection node_2; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +SET wsrep_dirty_reads=0; SHOW STATUS LIKE 'wsrep_desync_count'; Variable_name Value wsrep_desync_count 0 SET @@global.wsrep_desync = 0; +SET SESSION wsrep_sync_wait=15; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/GAL-480.result b/mysql-test/suite/galera/r/GAL-480.result index b762e07423e..143f48a69e3 100644 --- a/mysql-test/suite/galera/r/GAL-480.result +++ b/mysql-test/suite/galera/r/GAL-480.result @@ -1,3 +1,4 @@ +connection node_1; CREATE TABLE t1 (f1 CHAR(10), f0 integer) ENGINE=InnoDB; FLUSH TABLE t1 FOR EXPORT; UNLOCK TABLES; diff --git a/mysql-test/suite/galera/r/MW-284.result b/mysql-test/suite/galera/r/MW-284.result index a4c08bc7a93..bfb1301f7bd 100644 --- a/mysql-test/suite/galera/r/MW-284.result +++ b/mysql-test/suite/galera/r/MW-284.result @@ -17,7 +17,7 @@ INSERT INTO t1 VALUES (1); connection node_3; connection node_1; DROP TABLE t1; -SET global wsrep_sync_wait=7; +SET global wsrep_sync_wait=15; connection node_3; STOP SLAVE; RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/MW-329.result b/mysql-test/suite/galera/r/MW-329.result index 73796b5f868..af57bc4b056 100644 --- a/mysql-test/suite/galera/r/MW-329.result +++ b/mysql-test/suite/galera/r/MW-329.result @@ -26,3 +26,4 @@ connection node_1b; connection node_1; DROP PROCEDURE proc_insert; DROP TABLE t1; +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/r/MW-336.result b/mysql-test/suite/galera/r/MW-336.result new file mode 100644 index 00000000000..9bdb61c1a9c --- /dev/null +++ b/mysql-test/suite/galera/r/MW-336.result @@ -0,0 +1,42 @@ +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 1; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_slave_threads = 10; +SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +COUNT(*) = 11 +1 +SET GLOBAL wsrep_slave_threads = 20; +SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +COUNT(*) = 21 +1 +SET GLOBAL wsrep_slave_threads = 1; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 0; +Warnings: +Warning 1292 Truncated incorrect wsrep_slave_threads value: '0' +INSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (11); +INSERT INTO t1 VALUES (12); +INSERT INTO t1 VALUES (13); +INSERT INTO t1 VALUES (14); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (18); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (20); +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +COUNT(*) = 2 +1 +SET GLOBAL wsrep_slave_threads = 1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/MW-357.result b/mysql-test/suite/galera/r/MW-357.result new file mode 100644 index 00000000000..35855e21233 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-357.result @@ -0,0 +1,9 @@ +connection node_2; +SET GLOBAL wsrep_slave_threads = 0; +Warnings: +Warning 1292 Truncated incorrect wsrep_slave_threads value: '0' +connection node_1; +CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; +connection node_1; +INSERT INTO t1 VALUES (1); +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/MW-86-wait1.result b/mysql-test/suite/galera/r/MW-86-wait1.result new file mode 100644 index 00000000000..00010eaedcb --- /dev/null +++ b/mysql-test/suite/galera/r/MW-86-wait1.result @@ -0,0 +1,51 @@ +connection node_2; +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' +SET SESSION wsrep_sync_wait = 1; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +connection node_1; +CREATE TABLE t_wait1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t_wait1 VALUES (1); +connection node_2; +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +SHOW BINARY LOGS; +SHOW BINLOG EVENTS; +SHOW COLUMNS FROM t1; +SHOW CREATE EVENT e1; +SHOW CREATE FUNCTION f1; +SHOW CREATE PROCEDURE p1; +SHOW CREATE TABLE t1; +SHOW CREATE TRIGGER tr1; +SHOW CREATE VIEW v1; +SHOW DATABASES; +SHOW ENGINE InnoDB STATUS; +SHOW FUNCTION CODE f1; +SHOW FUNCTION STATUS; +SHOW GRANTS FOR 'root'@'localhost'; +SHOW INDEX FROM t1; +SHOW OPEN TABLES; +SHOW PROCEDURE CODE p1; +SHOW PROCEDURE STATUS; +SHOW PRIVILEGES; +SHOW STATUS LIKE 'wsrep_cluster_size'; +SHOW TABLE STATUS; +SHOW TABLES; +SHOW TRIGGERS; +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; +SHOW WARNINGS; +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET SESSION debug_sync = "now SIGNAL signal.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = default; +DROP TABLE t_wait1; +SET GLOBAL debug = NULL; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET debug_sync='RESET'; +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' diff --git a/mysql-test/suite/galera/r/MW-86-wait8.result b/mysql-test/suite/galera/r/MW-86-wait8.result new file mode 100644 index 00000000000..47e0ebc1342 --- /dev/null +++ b/mysql-test/suite/galera/r/MW-86-wait8.result @@ -0,0 +1,53 @@ +connection node_2; +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' +SET SESSION wsrep_sync_wait = 8; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +connection node_1; +CREATE TABLE t_wait8 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t_wait8 VALUES (1); +connection node_2; +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +SHOW BINARY LOGS; +SHOW BINLOG EVENTS; +SHOW COLUMNS FROM t1; +SHOW CREATE DATABASE db1; +SHOW CREATE EVENT e1; +SHOW CREATE FUNCTION f1; +SHOW CREATE PROCEDURE p1; +SHOW CREATE TABLE t1; +SHOW CREATE TRIGGER tr1; +SHOW CREATE VIEW v1; +SHOW DATABASES; +SHOW ENGINE InnoDB STATUS; +SHOW FUNCTION CODE f1; +SHOW FUNCTION STATUS; +SHOW GRANTS FOR 'root'@'localhost'; +SHOW INDEX FROM t1; +SHOW OPEN TABLES; +SHOW PROCEDURE CODE p1; +SHOW PROCEDURE STATUS; +SHOW PRIVILEGES; +SHOW STATUS LIKE 'wsrep_cluster_size'; +SHOW TABLE STATUS; +SHOW TABLES; +SHOW TRIGGERS; +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; +SHOW WARNINGS; +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET SESSION wsrep_sync_wait = default; +DROP TABLE t_wait8; +SET GLOBAL debug = NULL; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET debug_sync='RESET'; +SELECT @@debug_sync; +@@debug_sync +ON - current signal: '' diff --git a/mysql-test/suite/galera/r/basic.result b/mysql-test/suite/galera/r/basic.result index d4efe348b61..e85c805253f 100644 --- a/mysql-test/suite/galera/r/basic.result +++ b/mysql-test/suite/galera/r/basic.result @@ -10,6 +10,7 @@ c1 5 # On node_1 +connection node_1; SELECT * FROM test.t1; c1 1 @@ -19,6 +20,7 @@ c1 5 # On node_2 +connection node_2; SELECT * FROM test.t1; c1 1 @@ -27,4 +29,6 @@ c1 4 5 DROP TABLE t1; +disconnect node_2; +disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result index 18dcc55d5d4..a6607906661 100644 --- a/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result +++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table.result @@ -13,7 +13,7 @@ COUNT(*) = 0 1 connection node_1; UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 diff --git a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result index 1cf88dbf5d3..9711100d155 100644 --- a/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result +++ b/mysql-test/suite/galera/r/galera_applier_ftwrl_table_alter.result @@ -15,7 +15,7 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use COUNT(*) = 1 1 UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result index ac01ea100a0..60f3216aa9c 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_autoinc.result +++ b/mysql-test/suite/galera/r/galera_as_slave_autoinc.result @@ -38,11 +38,9 @@ i c show variables like 'binlog_format'; Variable_name Value binlog_format STATEMENT -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; Variable_name Value auto_increment_increment 7 -auto_increment_offset 5 -wsrep_auto_increment_control ON connection node_2; select * from t1; i c diff --git a/mysql-test/suite/galera/r/galera_bf_abort.result b/mysql-test/suite/galera/r/galera_bf_abort.result index cc750f05050..f7af382d8e2 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort.result +++ b/mysql-test/suite/galera/r/galera_bf_abort.result @@ -1,10 +1,15 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(6)) ENGINE=InnoDB; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (1,'node_2'); +connection node_1; INSERT INTO t1 VALUES (1,'node_1'); +connection node_2a; +connection node_2; INSERT INTO t1 VALUES (2, 'node_2'); -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction wsrep_local_aborts_increment 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result index 91b3c9ecaa8..7b98c807efb 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_flush_for_export.result @@ -9,7 +9,7 @@ SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result b/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result index ce3ac6ab2cb..2a4a786cca4 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_get_lock.result @@ -10,7 +10,7 @@ SELECT GET_LOCK("foo", 1000);; connection node_1; INSERT INTO t1 VALUES (1); connection node_2; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction wsrep_local_aborts_increment 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_sleep.result b/mysql-test/suite/galera/r/galera_bf_abort_sleep.result index f069198dff6..2982e40f9ae 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_sleep.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_sleep.result @@ -6,7 +6,7 @@ SELECT SLEEP(1000);; connection node_1; INSERT INTO t1 VALUES (1); connection node_2; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction wsrep_local_aborts_increment 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ddl_multiline.result b/mysql-test/suite/galera/r/galera_ddl_multiline.result new file mode 100644 index 00000000000..339a91125eb --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ddl_multiline.result @@ -0,0 +1,89 @@ +connection node_1; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_1; +CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t4 (f1 INTEGER) ENGINE=InnoDB;; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_2; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_1; +INSERT INTO t1 VALUES (1); +CREATE TABLE t5 (f1 INTEGER) ENGINE=InnoDB; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_2; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_1; +CREATE TABLE t6 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t2 VALUES (1);; +SELECT COUNT(*) = 1 FROM t2; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection node_2; +SELECT COUNT(*) = 1 FROM t2; +COUNT(*) = 1 +1 +SHOW CREATE TABLE t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +include/diff_servers.inc [servers=1 2] +connection node_1; +DROP TABLE t1, t2, t3, t4, t5, t6; diff --git a/mysql-test/suite/galera/r/galera_defaults.result b/mysql-test/suite/galera/r/galera_defaults.result index 9a0cd03d153..28c3f4dd104 100644 --- a/mysql-test/suite/galera/r/galera_defaults.result +++ b/mysql-test/suite/galera/r/galera_defaults.result @@ -50,8 +50,8 @@ WSREP_SST_AUTH WSREP_SST_DONOR WSREP_SST_DONOR_REJECTS_QUERIES OFF WSREP_SST_METHOD rsync -WSREP_SYNC_WAIT 7 -<BASE_DIR>; <BASE_HOST>; <BASE_PORT>; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; <GCACHE_DIR>; gcache.keep_pages_size = 0; gcache.mem_size = 0; <GCACHE_NAME>; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; <GCS_RECV_Q_HARD_LIMIT>; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; <GMCAST_LISTEN_ADDR>; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; <IST_RECV_ADDR>; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; +WSREP_SYNC_WAIT 15 +<BASE_DIR>; <BASE_HOST>; <BASE_PORT>; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; <GCACHE_DIR>; gcache.keep_pages_size = 0; gcache.mem_size = 0; <GCACHE_NAME>; gcache.page_size = 128M; gcache.recover = no; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; <GCS_RECV_Q_HARD_LIMIT>; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; <GMCAST_LISTEN_ADDR>; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; <IST_RECV_ADDR>; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992; SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep_%' AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; diff --git a/mysql-test/suite/galera/r/galera_enum.result b/mysql-test/suite/galera/r/galera_enum.result index 1bac7dc9388..ad0ee92a8e5 100644 --- a/mysql-test/suite/galera/r/galera_enum.result +++ b/mysql-test/suite/galera/r/galera_enum.result @@ -38,7 +38,7 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction connection node_1; SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 'three'; COUNT(*) = 1 diff --git a/mysql-test/suite/galera/r/galera_fk_conflict.result b/mysql-test/suite/galera/r/galera_fk_conflict.result index d9919c0348b..97e8a47fa6c 100644 --- a/mysql-test/suite/galera/r/galera_fk_conflict.result +++ b/mysql-test/suite/galera/r/galera_fk_conflict.result @@ -22,6 +22,6 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction DROP TABLE child; DROP TABLE parent; diff --git a/mysql-test/suite/galera/r/galera_insert_ignore.result b/mysql-test/suite/galera/r/galera_insert_ignore.result index d21fb2b02d0..7057affaa0e 100644 --- a/mysql-test/suite/galera/r/galera_insert_ignore.result +++ b/mysql-test/suite/galera/r/galera_insert_ignore.result @@ -1,6 +1,6 @@ -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; connection node_2; -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); diff --git a/mysql-test/suite/galera/r/galera_insert_multi.result b/mysql-test/suite/galera/r/galera_insert_multi.result index 38bb5c26d20..71921134b03 100644 --- a/mysql-test/suite/galera/r/galera_insert_multi.result +++ b/mysql-test/suite/galera/r/galera_insert_multi.result @@ -51,7 +51,7 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction ROLLBACK; INSERT INTO t1 VALUES (1), (2); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' diff --git a/mysql-test/suite/galera/r/galera_ist_progress.result b/mysql-test/suite/galera/r/galera_ist_progress.result new file mode 100644 index 00000000000..9fc7febbea5 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_progress.result @@ -0,0 +1,19 @@ +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +SET SESSION wsrep_on = OFF; +SET SESSION wsrep_on = ON; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +INSERT INTO t1 VALUES (10); +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; +include/assert_grep.inc [Receiving IST: 11 writesets, seqnos] +include/assert_grep.inc [Receiving IST\.\.\. 0\.0% \( 0/11 events\) complete] +include/assert_grep.inc [Receiving IST\.\.\.100\.0% \(11/11 events\) complete] +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_ist_restart_joiner.result b/mysql-test/suite/galera/r/galera_ist_restart_joiner.result index 78fc5b2baf3..c81cecfae1c 100644 --- a/mysql-test/suite/galera/r/galera_ist_restart_joiner.result +++ b/mysql-test/suite/galera/r/galera_ist_restart_joiner.result @@ -9,20 +9,15 @@ connection node_1; UPDATE t1 SET f2 = 'b' WHERE f1 > 1; UPDATE t1 SET f2 = 'c' WHERE f1 > 2; connection node_2; -SET GLOBAL wsrep_provider_options = 'dbug=d,recv_IST_after_apply_trx'; -SET SESSION wsrep_sync_wait = 0; Loading wsrep_provider ... -SHOW STATUS LIKE 'wsrep_debug_sync_waiters'; -Variable_name Value -wsrep_debug_sync_waiters recv_IST_after_apply_trx +SET SESSION wsrep_on=OFF; +SET SESSION wsrep_on=ON; connection node_1; connection node_1; UPDATE t1 SET f2 = 'd' WHERE f1 > 3; -CREATE TABLE t2 (f1 INTEGER); connection node_2; connection node_1; UPDATE t1 SET f2 = 'e' WHERE f1 > 4; -CREATE TABLE t3 (f1 INTEGER); connection node_2; Performing --wsrep-recover ... Starting server ... @@ -46,13 +41,7 @@ f1 f2 4 d 5 e 6 f -SELECT COUNT(*) = 0 FROM t2; -COUNT(*) = 0 -1 -SELECT COUNT(*) = 0 FROM t3; -COUNT(*) = 0 -1 connection node_1; -DROP TABLE t1, t2, t3; +DROP TABLE t1; disconnect node_2; disconnect node_1; diff --git a/mysql-test/suite/galera/r/galera_kill_nochanges.result b/mysql-test/suite/galera/r/galera_kill_nochanges.result index db3c75e2886..a307dde0527 100644 --- a/mysql-test/suite/galera/r/galera_kill_nochanges.result +++ b/mysql-test/suite/galera/r/galera_kill_nochanges.result @@ -1,6 +1,9 @@ +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; Killing server ... +connection node_2a; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_log_output_csv.result b/mysql-test/suite/galera/r/galera_log_output_csv.result index cdb5ee49f3e..5cb61b36332 100644 --- a/mysql-test/suite/galera/r/galera_log_output_csv.result +++ b/mysql-test/suite/galera/r/galera_log_output_csv.result @@ -9,10 +9,12 @@ SELECT 1 = 1 FROM t1; SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 1 = 1 FROM t1'; COUNT(*) = 1 1 +connection node_2; SELECT 2 = 2 FROM t1; 2 = 2 1 SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 2 = 2 FROM t1'; COUNT(*) = 1 1 +connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_many_indexes.result b/mysql-test/suite/galera/r/galera_many_indexes.result index 59d0194687f..7b935eb66ba 100644 --- a/mysql-test/suite/galera/r/galera_many_indexes.result +++ b/mysql-test/suite/galera/r/galera_many_indexes.result @@ -129,5 +129,5 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_many_rows.result b/mysql-test/suite/galera/r/galera_many_rows.result index ab43b961458..6f9e76f010e 100644 --- a/mysql-test/suite/galera/r/galera_many_rows.result +++ b/mysql-test/suite/galera/r/galera_many_rows.result @@ -7,7 +7,7 @@ CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoD INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; connection node_2; SET SESSION wsrep_sync_wait = 0; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H'; SELECT COUNT(*) = 100000 FROM t1; COUNT(*) = 100000 diff --git a/mysql-test/suite/galera/r/galera_mdl_race.result b/mysql-test/suite/galera/r/galera_mdl_race.result index 0c83ead931e..79f1ccead0a 100644 --- a/mysql-test/suite/galera/r/galera_mdl_race.result +++ b/mysql-test/suite/galera/r/galera_mdl_race.result @@ -28,7 +28,7 @@ SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; UNLOCK TABLES; connection node_1; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_nopk_bit.result b/mysql-test/suite/galera/r/galera_nopk_bit.result index 7662c15c672..b670781c9be 100644 --- a/mysql-test/suite/galera/r/galera_nopk_bit.result +++ b/mysql-test/suite/galera/r/galera_nopk_bit.result @@ -28,6 +28,6 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_nopk_blob.result b/mysql-test/suite/galera/r/galera_nopk_blob.result index a7570c2cfee..55d369e3077 100644 --- a/mysql-test/suite/galera/r/galera_nopk_blob.result +++ b/mysql-test/suite/galera/r/galera_nopk_blob.result @@ -28,6 +28,6 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_nopk_large_varchar.result b/mysql-test/suite/galera/r/galera_nopk_large_varchar.result index 08cffaa2bd1..720e93fc42c 100644 --- a/mysql-test/suite/galera/r/galera_nopk_large_varchar.result +++ b/mysql-test/suite/galera/r/galera_nopk_large_varchar.result @@ -31,6 +31,6 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/galera_nopk_unicode.result b/mysql-test/suite/galera/r/galera_nopk_unicode.result index 882a91a29b5..8b7a094edf2 100644 --- a/mysql-test/suite/galera/r/galera_nopk_unicode.result +++ b/mysql-test/suite/galera/r/galera_nopk_unicode.result @@ -19,7 +19,7 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction SELECT f1 = 'текÑÑ‚2' FROM t1; f1 = 'текÑÑ‚2' 1 diff --git a/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result b/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result index 90349f493bd..ab56a8a2aa6 100644 --- a/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result +++ b/mysql-test/suite/galera/r/galera_parallel_apply_lock_table.result @@ -23,7 +23,7 @@ COUNT(*) = 0 connection node_2; UNLOCK TABLES; connection node_2a; -SET SESSION wsrep_sync_wait = 7;; +SET SESSION wsrep_sync_wait = 15;; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 diff --git a/mysql-test/suite/galera/r/galera_parallel_simple.result b/mysql-test/suite/galera/r/galera_parallel_simple.result index 6d023c38a57..3b10815c63d 100644 --- a/mysql-test/suite/galera/r/galera_parallel_simple.result +++ b/mysql-test/suite/galera/r/galera_parallel_simple.result @@ -16,7 +16,7 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 10 FROM t1; COUNT(*) = 10 0 diff --git a/mysql-test/suite/galera/r/galera_pk_bigint_signed.result b/mysql-test/suite/galera/r/galera_pk_bigint_signed.result index 27bb3c50733..f0d8586b27b 100644 --- a/mysql-test/suite/galera/r/galera_pk_bigint_signed.result +++ b/mysql-test/suite/galera/r/galera_pk_bigint_signed.result @@ -27,6 +27,6 @@ COMMIT; SET AUTOCOMMIT=ON; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction SET AUTOCOMMIT=ON; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result b/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result index f586fe2f589..9c878c1a1a1 100644 --- a/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result +++ b/mysql-test/suite/galera/r/galera_pk_bigint_unsigned.result @@ -24,6 +24,6 @@ COMMIT; SET AUTOCOMMIT=ON; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction SET AUTOCOMMIT=ON; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result index 2a37d62698a..8c9cece9097 100644 --- a/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_query_cache_sync_wait.result @@ -5,7 +5,6 @@ SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) 1 @@ -19,7 +18,6 @@ Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; FLUSH QUERY CACHE; -SET SESSION wsrep_sync_wait = 7; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; Warnings: Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead @@ -36,11 +34,9 @@ SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; connection node_1; INSERT INTO t1 VALUES (4); connection node_2; -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; MAX(id) 4 -SET SESSION wsrep_sync_wait = 7; FLUSH STATUS; SELECT MAX(id) FROM t1; MAX(id) @@ -54,7 +50,6 @@ Warning 1287 '@@debug' is deprecated and will be removed in a future release. Pl connection node_1; INSERT INTO t1 VALUES (5); connection node_2; -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1 ; connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; connection node_2a; diff --git a/mysql-test/suite/galera/r/galera_serializable.result b/mysql-test/suite/galera/r/galera_serializable.result index e81c3911b7d..f82adbbd1db 100644 --- a/mysql-test/suite/galera/r/galera_serializable.result +++ b/mysql-test/suite/galera/r/galera_serializable.result @@ -9,7 +9,7 @@ connection node_2; INSERT INTO t1 VALUES (1,1); connection node_1; SELECT * FROM t1; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction ROLLBACK; DELETE FROM t1; connection node_1; @@ -22,7 +22,7 @@ connection node_2; UPDATE t1 SET f2 = 2; connection node_1; UPDATE t1 SET f2 = 3; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction ROLLBACK; DELETE FROM t1; connection node_1; @@ -33,5 +33,5 @@ connection node_2; INSERT INTO t1 VALUES (1,2); connection node_1; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_split_brain.result b/mysql-test/suite/galera/r/galera_split_brain.result index 1f9b67eeff3..7c669e5516a 100644 --- a/mysql-test/suite/galera/r/galera_split_brain.result +++ b/mysql-test/suite/galera/r/galera_split_brain.result @@ -6,7 +6,7 @@ connection node_2; Killing server ... connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: WSREP replication failed. Check your wsrep connection state and retry the query. connection node_2; connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; disconnect node_2; diff --git a/mysql-test/suite/galera/r/galera_suspend_slave.result b/mysql-test/suite/galera/r/galera_suspend_slave.result index 380ecb395c3..384d91f1d49 100644 --- a/mysql-test/suite/galera/r/galera_suspend_slave.result +++ b/mysql-test/suite/galera/r/galera_suspend_slave.result @@ -9,9 +9,12 @@ Suspending node_2 ... INSERT INTO t1 VALUES (1); Got one of the listed errors Resuming node_2 ... +SET SESSION wsrep_sync_wait = 1; INSERT INTO t1 VALUES (1); connection node_2a; +SET SESSION wsrep_sync_wait = 1; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 +SET SESSION wsrep_sync_wait = 15; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result index e0783e42174..def771ff88d 100644 --- a/mysql-test/suite/galera/r/galera_sync_wait_show.result +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -1,5 +1,5 @@ connection node_2; -SET SESSION wsrep_sync_wait = 1; +SET SESSION wsrep_sync_wait = 8; connection node_1; CREATE DATABASE db1; connection node_2; @@ -35,7 +35,7 @@ CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; connection node_2; SHOW FUNCTION CODE f1; Pos Instruction -0 freturn 3 123 +0 freturn int 123 DROP FUNCTION f1; connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; diff --git a/mysql-test/suite/galera/r/galera_toi_drop_database.result b/mysql-test/suite/galera/r/galera_toi_drop_database.result index c36d4d3eedd..e61e73806e2 100644 --- a/mysql-test/suite/galera/r/galera_toi_drop_database.result +++ b/mysql-test/suite/galera/r/galera_toi_drop_database.result @@ -14,9 +14,9 @@ INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, te connection node_2; DROP DATABASE database1;; connection node_1; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction connection node_1a; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction connection node_2; connection node_1; SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1'; diff --git a/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result b/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result index c13b689f82b..5aba1eae2e8 100644 --- a/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result +++ b/mysql-test/suite/galera/r/galera_toi_lock_exclusive.result @@ -8,7 +8,7 @@ connection node_2a; ALTER TABLE t1 ADD COLUMN f2 INTEGER, LOCK=EXCLUSIVE; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction connection node_1; INSERT INTO t1 VALUES (2, 2); SELECT COUNT(*) = 2 FROM t1; diff --git a/mysql-test/suite/galera/r/galera_toi_truncate.result b/mysql-test/suite/galera/r/galera_toi_truncate.result index aa407ba7610..a53261eafd5 100644 --- a/mysql-test/suite/galera/r/galera_toi_truncate.result +++ b/mysql-test/suite/galera/r/galera_toi_truncate.result @@ -9,7 +9,7 @@ connection node_1; TRUNCATE TABLE t1;; connection node_1; connection node_2; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction connection node_2; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 diff --git a/mysql-test/suite/galera/r/galera_transaction_read_only.result b/mysql-test/suite/galera/r/galera_transaction_read_only.result index 3cd1076a285..b388f195fb1 100644 --- a/mysql-test/suite/galera/r/galera_transaction_read_only.result +++ b/mysql-test/suite/galera/r/galera_transaction_read_only.result @@ -1,21 +1,30 @@ +connection node_1; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +connection node_2; +connection node_1; SET AUTOCOMMIT=OFF; START TRANSACTION; COMMIT; +connection node_2; wsrep_last_committed_diff 1 +connection node_2; +connection node_1; START TRANSACTION READ ONLY; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 COMMIT; +connection node_2; wsrep_last_committed_diff 1 +connection node_1; START TRANSACTION; SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 COMMIT; +connection node_2; wsrep_last_committed_diff 1 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_unicode_identifiers.result b/mysql-test/suite/galera/r/galera_unicode_identifiers.result index 146cc052152..5eb13a83df9 100644 --- a/mysql-test/suite/galera/r/galera_unicode_identifiers.result +++ b/mysql-test/suite/galera/r/galera_unicode_identifiers.result @@ -1,6 +1,6 @@ -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; connection node_2; -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; connection node_1; CREATE DATABASE `database with space`; USE `database with space`; diff --git a/mysql-test/suite/galera/r/galera_unicode_pk.result b/mysql-test/suite/galera/r/galera_unicode_pk.result index 2711e44b7cb..20e903c7778 100644 --- a/mysql-test/suite/galera/r/galera_unicode_pk.result +++ b/mysql-test/suite/galera/r/galera_unicode_pk.result @@ -18,7 +18,7 @@ connection node_1; COMMIT; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction SELECT f1 = 'текÑÑ‚2' FROM t1; f1 = 'текÑÑ‚2' 1 @@ -35,6 +35,6 @@ connection node_2; COMMIT; connection node_1; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction COMMIT; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result b/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result index 15bbe7c508a..bdc4ecb0225 100644 --- a/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result +++ b/mysql-test/suite/galera/r/galera_var_auto_inc_control_off.result @@ -59,7 +59,7 @@ connection node_1a; COMMIT; connection node_2a; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction connection node_1a; SELECT * FROM t1; f1 node diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index 0bc30f4092c..beb47be1747 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -6,10 +6,6 @@ INSERT INTO t1 VALUES(1); SELECT * FROM t1; i 1 -create user user1; -grant all privileges on *.* to user1; -create user user2; -grant all privileges on *.* to user2; SET @@global.wsrep_cluster_address = ''; SET @@session.wsrep_dirty_reads=OFF; SET SESSION wsrep_sync_wait=0; @@ -21,87 +17,36 @@ Variable_name Value wsrep_cluster_status non-Primary SELECT * FROM t1; ERROR 08S01: WSREP has not yet prepared node for application use -SELECT @@wsrep_dirty_reads; -@@wsrep_dirty_reads -0 -SELECT 2; -2 -2 -SELECT 2+2 FROM DUAL; -2+2 -4 +SELECT 1 FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; i 1 -connect con1, localhost, user1,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2; -SET SESSION wsrep_sync_wait=0; -set session wsrep_dirty_reads=1; -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; -set session wsrep_dirty_reads=0; -execute stmt_show; -ERROR 08S01: WSREP has not yet prepared node for application use -execute stmt_select; -ERROR 08S01: WSREP has not yet prepared node for application use -execute stmt_insert; -ERROR 08S01: WSREP has not yet prepared node for application use -SET wsrep_dirty_reads=ON; -select @@session.wsrep_dirty_reads; -@@session.wsrep_dirty_reads -1 -execute stmt_show; +SELECT 1 FROM t1; 1 1 -execute stmt_select; -i -1 -execute stmt_insert; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; +i variable_name variable_value +1 WSREP_DIRTY_READS ON +SET @@session.wsrep_dirty_reads=OFF; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; ERROR 08S01: WSREP has not yet prepared node for application use -SET @@global.wsrep_dirty_reads=ON; -connect con2, localhost, user2,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2; -select @@session.wsrep_dirty_reads; -@@session.wsrep_dirty_reads +SELECT 1; 1 -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; -execute stmt_show; 1 -1 -execute stmt_select; -i -1 -execute stmt_insert; +USE information_schema; ERROR 08S01: WSREP has not yet prepared node for application use -SET SESSION wsrep_sync_wait=1; -execute stmt_show; -1 -1 -execute stmt_select; -i -1 -execute stmt_insert; +SELECT * FROM information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads"; ERROR 08S01: WSREP has not yet prepared node for application use -SET SESSION wsrep_sync_wait=7; -execute stmt_show; -1 -1 -execute stmt_select; -i -1 -execute stmt_insert; +SELECT COUNT(*) >= 10 FROM performance_schema.events_statements_history; ERROR 08S01: WSREP has not yet prepared node for application use -connection node_2; -SET @@global.wsrep_dirty_reads=OFF; connection node_1; +USE test; SELECT * FROM t1; i 1 DROP TABLE t1; -drop user user1; -drop user user2; disconnect node_2; disconnect node_1; # End of test diff --git a/mysql-test/suite/galera/r/galera_var_node_address.result b/mysql-test/suite/galera/r/galera_var_node_address.result index c9c9b52d9cb..8ce6a5e01a1 100644 --- a/mysql-test/suite/galera/r/galera_var_node_address.result +++ b/mysql-test/suite/galera/r/galera_var_node_address.result @@ -1,4 +1,5 @@ call mtr.add_suppression("WSREP: Stray state UUID msg: .* current group state WAIT_STATE_UUID .*"); +call mtr.add_suppression("WSREP: Protocol violation. JOIN message sender .* is not in state transfer (.*). Message ignored."); SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 diff --git a/mysql-test/suite/galera/r/galera_var_sync_wait.result b/mysql-test/suite/galera/r/galera_var_sync_wait.result index 7f3afa77ecd..3dfe902767c 100644 --- a/mysql-test/suite/galera/r/galera_var_sync_wait.result +++ b/mysql-test/suite/galera/r/galera_var_sync_wait.result @@ -3,7 +3,7 @@ # SELECT @@global.wsrep_sync_wait; @@global.wsrep_sync_wait -7 +15 SELECT @@global.wsrep_causal_reads; @@global.wsrep_causal_reads 1 @@ -11,9 +11,6 @@ connection node_1; CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; connection node_2; SET GLOBAL wsrep_sync_wait = 1; -SHOW TABLES LIKE '%t1'; -Tables_in_test (%t1) -t1 SELECT COUNT(*) = 0 FROM t1; COUNT(*) = 0 1 @@ -31,7 +28,7 @@ UPDATE t3 SET f1 = 2; affected rows: 1 info: Rows matched: 1 Changed: 1 Warnings: 0 connection node_2; -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; diff --git a/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result b/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result index 18a857d4471..4c33d9ac6ce 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result +++ b/mysql-test/suite/galera/r/galera_wsrep_log_conficts.result @@ -20,6 +20,6 @@ connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; connection node_2a; connection node_2; COMMIT; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR 40001: wsrep aborted transaction include/assert_grep.inc [cluster conflict due to high priority abort for threads] DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result b/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result index 681e4606b38..d56d9340474 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result +++ b/mysql-test/suite/galera/r/galera_wsrep_provider_unset_set.result @@ -1,12 +1,20 @@ +connection node_1; +connection node_2; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); +connection node_2; SET GLOBAL wsrep_provider='none'; INSERT INTO t1 VALUES (2); +connection node_1; INSERT INTO t1 VALUES (3); +connection node_2; +SET SESSION wsrep_sync_wait = 0; INSERT INTO t1 VALUES (4); SELECT COUNT(*) = 4 FROM t1; COUNT(*) = 4 1 +connection node_1; SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 1 diff --git a/mysql-test/suite/galera/r/mysql-wsrep#198.result b/mysql-test/suite/galera/r/mysql-wsrep#198.result index afc2a07fb30..33f36d407db 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#198.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#198.result @@ -1,6 +1,9 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; connection node_2; +SELECT 1 FROM DUAL; +1 +1 LOCK TABLE t2 WRITE; connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; connection node_2a; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#201.result b/mysql-test/suite/galera/r/mysql-wsrep#201.result index 0f2980eddd2..fe5725cab27 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#201.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#201.result @@ -2,4 +2,3 @@ CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; INSERT INTO t1 VALUES (DEFAULT); connection node_2; SET GLOBAL query_cache_size=1355776; -SET SESSION wsrep_sync_wait = 7; diff --git a/mysql-test/suite/galera/r/partition.result b/mysql-test/suite/galera/r/partition.result index 824572065c1..3835de514aa 100644 --- a/mysql-test/suite/galera/r/partition.result +++ b/mysql-test/suite/galera/r/partition.result @@ -56,10 +56,10 @@ t1 CREATE TABLE `t1` ( `i` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`i`) ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 - PARTITION BY RANGE (i) -(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, - PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, - PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) + PARTITION BY RANGE (`i`) +(PARTITION `p1` VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION `p2` VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION `pMax` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) SHOW CREATE TABLE p1; Table Create Table p1 CREATE TABLE `p1` ( @@ -93,9 +93,9 @@ t1 CREATE TABLE `t1` ( `i` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`i`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 - PARTITION BY RANGE (i) -(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, - PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) + PARTITION BY RANGE (`i`) +(PARTITION `p1` VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION `pMax` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) # On node_2 connection node_2; @@ -105,9 +105,9 @@ t1 CREATE TABLE `t1` ( `i` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`i`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 - PARTITION BY RANGE (i) -(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, - PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) + PARTITION BY RANGE (`i`) +(PARTITION `p1` VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION `pMax` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) DROP TABLE t1, p1; # # MDEV-5146: Bulk loads into partitioned table not working diff --git a/mysql-test/suite/galera/r/pxc-421.result b/mysql-test/suite/galera/r/pxc-421.result index 4fde5a26819..38bf64f20c5 100644 --- a/mysql-test/suite/galera/r/pxc-421.result +++ b/mysql-test/suite/galera/r/pxc-421.result @@ -10,6 +10,7 @@ INSERT INTO t1 VALUES (2); connection node_1; INSERT INTO t1 VALUES (3); connection node_2; +set SESSION wsrep_sync_wait=0; INSERT INTO t1 VALUES (4); set GLOBAL wsrep_slave_threads=5; SELECT COUNT(*) = 5 FROM t1; @@ -31,6 +32,7 @@ SET GLOBAL wsrep_slave_threads = 1; SELECT COUNT(*) FROM t1; COUNT(*) 16 +SET GLOBAL auto_increment_offset = 2; connection node_1; SELECT COUNT(*) FROM t1; COUNT(*) @@ -40,3 +42,4 @@ Variable_name Value wsrep_slave_threads 12 SET GLOBAL wsrep_slave_threads = 1; DROP TABLE t1; +SET GLOBAL auto_increment_offset = 1; diff --git a/mysql-test/suite/galera/r/query_cache.result b/mysql-test/suite/galera/r/query_cache.result index 4b1b950e5c3..4aaae2997f3 100644 --- a/mysql-test/suite/galera/r/query_cache.result +++ b/mysql-test/suite/galera/r/query_cache.result @@ -1,6 +1,7 @@ # Execute FLUSH/RESET commands. # On node-1 +connection node_1; SET @query_cache_size_saved=@@GLOBAL.query_cache_size; SET @query_cache_type_saved=@@GLOBAL.query_cache_type; set GLOBAL query_cache_size=1355776; @@ -8,6 +9,7 @@ flush query cache; reset query cache; flush status; # On node-2 +connection node_2; SET @query_cache_size_saved=@@GLOBAL.query_cache_size; SET @query_cache_type_saved=@@GLOBAL.query_cache_type; set GLOBAL query_cache_size=1355776; @@ -15,6 +17,7 @@ flush query cache; reset query cache; flush status; # On node-1 +connection node_1; create table t1 (a int not null) engine=innodb; insert into t1 values (1),(2),(3); select * from t1; @@ -47,6 +50,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; select * from t1; a 1 @@ -77,6 +81,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; delete from t1 where a=1; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -85,6 +90,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -92,6 +98,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; select * from t1; a 2 @@ -103,6 +110,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; select * from t1; a 2 @@ -114,6 +122,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; update t1 set a=1 where a=3; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -122,6 +131,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -129,6 +139,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; select * from t1; a 2 @@ -140,6 +151,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; select * from t1; a 2 @@ -151,6 +163,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; drop table t1; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -159,6 +172,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -167,6 +181,7 @@ Variable_name Value Qcache_hits 1 # On node-1 +connection node_1; create table t1 (a int not null) ENGINE=MyISAM; insert into t1 values (1),(2),(3); create table t2 (a int not null) ENGINE=MyISAM; @@ -323,6 +338,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 3 # On node-2 +connection node_2; select * from t3; a select * from t3; @@ -338,6 +354,7 @@ Variable_name Value Qcache_hits 2 drop table t1, t2, t3; # On node-1 +connection node_1; set query_cache_type=demand; create table t1 (a int not null) engine=innodb; insert into t1 values (1),(2),(3); @@ -371,6 +388,7 @@ Variable_name Value Qcache_queries_in_cache 1 set query_cache_type=on; # On node-2 +connection node_2; set query_cache_type=demand; select * from t1; a @@ -402,6 +420,7 @@ Variable_name Value Qcache_queries_in_cache 1 set query_cache_type=on; # On node-1 +connection node_1; reset query cache; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -410,6 +429,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; reset query cache; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -418,6 +438,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 3 # On node-1 +connection node_1; select sql_no_cache * from t1; a 1 @@ -430,6 +451,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; select sql_no_cache * from t1; a 1 @@ -443,6 +465,7 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create table t1 (a text not null) engine=innodb; select CONNECTION_ID() from t1; CONNECTION_ID() @@ -483,6 +506,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; select CONNECTION_ID() from t1; CONNECTION_ID() select FOUND_ROWS(); @@ -523,6 +547,7 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create database mysqltest; create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)) engine=innodb; @@ -548,6 +573,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; select * from t1; a show status like "Qcache_queries_in_cache"; @@ -574,10 +600,9 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create table t1 (a char(1) not null collate koi8r_general_ci) engine=innodb; -insert into t1 values(_koi8r"á"); -Warnings: -Warning 1265 Data truncated for column 'a' at row 1 +insert into t1 values(_koi8r 0xc3); set CHARACTER SET koi8r; select * from t1; a @@ -594,6 +619,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 # On node-2 +connection node_2; set CHARACTER SET koi8r; select * from t1; a @@ -611,6 +637,7 @@ Variable_name Value Qcache_hits 3 drop table t1; # On node-1 +connection node_1; create database if not exists mysqltest; create table mysqltest.t1 (i int not null) engine=innodb; create table t1 (i int not null) engine=innodb; @@ -637,6 +664,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 6 # On node-2 +connection node_2; select * from t1; i 2 @@ -660,6 +688,7 @@ Qcache_hits 5 drop database mysqltest; drop table t1; # On node-1 +connection node_1; create table t1 (i int not null) engine=innodb; insert into t1 (i) values (1),(2),(3),(4); select SQL_CALC_FOUND_ROWS * from t1 limit 2; @@ -713,6 +742,7 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 # On node-2 +connection node_2; select SQL_CALC_FOUND_ROWS * from t1 limit 2; i 1 @@ -765,9 +795,11 @@ Variable_name Value Qcache_queries_in_cache 2 drop table t1; # On node-2 +connection node_2; flush query cache; reset query cache; # On node-1 +connection node_1; flush query cache; reset query cache; create table t1 (a int not null) ENGINE=MYISAM; @@ -802,6 +834,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 9 # On node-2 +connection node_2; select * from t1; a select * from t1; @@ -830,6 +863,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 8 # On node-1 +connection node_1; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -837,6 +871,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 9 # On node-2 +connection node_2; show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 @@ -847,6 +882,7 @@ show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 1000 # On node-1 +connection node_1; show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 @@ -887,6 +923,7 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 # On node-2 +connection node_2; select * from t1; a 1 @@ -935,6 +972,7 @@ show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 # On node-1 +connection node_1; select a from t2; a 1 @@ -957,6 +995,7 @@ show global variables like "query_cache_min_res_unit"; Variable_name Value query_cache_min_res_unit 4096 # On node-1 +connection node_1; create table t1 (a int not null) engine=innodb; insert into t1 values (1); select "aaa" from t1; @@ -972,6 +1011,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-2 +connection node_2; select "aaa" from t1; aaa aaa @@ -986,6 +1026,7 @@ Variable_name Value Qcache_hits 11 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; set GLOBAL query_cache_size=1000; Warnings: @@ -1052,6 +1093,7 @@ query_cache_size 102400 select * from t1; a # On node-2 +connection node_2; set GLOBAL query_cache_size=1000; Warnings: Warning 1292 Truncated incorrect query_cache_size value: '1000' @@ -1118,6 +1160,7 @@ select * from t1; a drop table t1; # On node-1 +connection node_1; set GLOBAL query_cache_size=1048576; create table t1 (i int not null) engine=innodb; create table t2 (i int not null) engine=innodb; @@ -1149,6 +1192,7 @@ Qcache_hits 12 update t1 set i=(select distinct 1 from (select * from t2) a); drop table t3; # On node-2 +connection node_2; set GLOBAL query_cache_size=1048576; select * from t1; i @@ -1168,6 +1212,7 @@ Variable_name Value Qcache_hits 11 drop table t1, t2; # On node-1 +connection node_1; use mysql; select * from db; show status like "Qcache_queries_in_cache"; @@ -1185,6 +1230,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-1 +connection node_1; create table t1(id int auto_increment primary key) engine=innodb; insert into t1 values (1), (2), (3); select * from t1; @@ -1199,6 +1245,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-2 +connection node_2; select * from t1; id 1 @@ -1211,6 +1258,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 11 # On node-1 +connection node_1; alter table t1 rename to t2; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist @@ -1221,6 +1269,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 12 # On node-2 +connection node_2; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist show status like "Qcache_queries_in_cache"; @@ -1231,6 +1280,7 @@ Variable_name Value Qcache_hits 11 drop table t2; # On node-1 +connection node_1; create table t1 (word char(20) not null) engine=innodb; select * from t1; word @@ -1251,6 +1301,7 @@ select count(*) from t1; count(*) 70 # On node-2 +connection node_2; select count(*) from t1; count(*) 70 @@ -1272,6 +1323,7 @@ count(*) 140 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; insert into t1 values (1),(2),(3); show status like "Qcache_queries_in_cache"; @@ -1292,6 +1344,7 @@ Variable_name Value Qcache_hits 12 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; insert into t1 values (1),(2); show status like "Qcache_queries_in_cache"; @@ -1316,6 +1369,7 @@ Variable_name Value Qcache_hits 12 SET SQL_SELECT_LIMIT=DEFAULT; # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -1339,6 +1393,7 @@ Qcache_hits 11 SET SQL_SELECT_LIMIT=DEFAULT; drop table t1; # On node-1 +connection node_1; create table t1 (a int not null) engine=innodb; create table t2 (a int not null) engine=innodb; set query_cache_wlock_invalidate=1; @@ -1380,6 +1435,7 @@ unlock table; drop view v1; set query_cache_wlock_invalidate=default; # On node-2 +connection node_2; set query_cache_wlock_invalidate=1; create view v1 as select * from t1; select * from t1; @@ -1420,6 +1476,7 @@ drop view v1; set query_cache_wlock_invalidate=default; drop table t1,t2; # On node-1 +connection node_1; create table t1 (id int primary key) engine=innodb; insert into t1 values (1),(2),(3); select * from t1; @@ -1433,12 +1490,10 @@ a drop table t1; drop table t1; # On node-1 +connection node_1; SET NAMES koi8r; CREATE TABLE t1 (a char(1) character set koi8r) engine=innodb; -INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Ã'); -Warnings: -Warning 1265 Data truncated for column 'a' at row 1 -Warning 1265 Data truncated for column 'a' at row 2 +INSERT INTO t1 VALUES (_koi8r 0xc3),(_koi8r 0xc3); SELECT a,'Â','â'='Â' FROM t1; a  'â'='Â' à  0 @@ -1484,6 +1539,7 @@ Variable_name Value Qcache_queries_in_cache 4 SET NAMES default; # On node-2 +connection node_2; SELECT a,'Â','â'='Â' FROM t1; a  'â'='Â' ?  0 @@ -1529,6 +1585,7 @@ Variable_name Value Qcache_queries_in_cache 4 drop table t1; # On node-1 +connection node_1; create table t1 (a int) engine=innodb; show status like "Qcache_queries_in_cache"; Variable_name Value @@ -1553,6 +1610,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 13 # On node-2 +connection node_2; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 @@ -1577,6 +1635,7 @@ Variable_name Value Qcache_hits 12 drop table t1; # On node-1 +connection node_1; set session query_cache_type = 2; create table t1(a int) engine=innodb; select table_name from information_schema.tables @@ -1614,6 +1673,7 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 14 # On node-2 +connection node_2; select a from t1; a select a from t1; @@ -1636,10 +1696,12 @@ Qcache_hits 13 drop table t1; # Restore original settings. # On node-1 +connection node_1; SET GLOBAL query_cache_size=@query_cache_size_saved; SET GLOBAL query_cache_type=@query_cache_type_saved; # On node-2 +connection node_2; SET GLOBAL query_cache_size=@query_cache_size_saved; SET GLOBAL query_cache_type=@query_cache_type_saved; # End of test diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index a161301d8ff..361743f1243 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -19,6 +19,9 @@ $ENV{WSREP_PROVIDER} = $provider; my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir; return "No SST scripts" unless $spath; +my ($cpath) = grep { -f "$_/mysql"; } "$::bindir/scripts", $::path_client_bindir; +return "No scritps" unless $cpath; + my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir; return "No my_print_defaults" unless $epath; @@ -65,13 +68,19 @@ push @::global_suppressions, qr(WSREP: TO isolation failed for: .*), qr|WSREP: gcs_caused\(\) returned .*|, qr|WSREP: Protocol violation. JOIN message sender .* is not in state transfer \(SYNCED\). Message ignored.|, + qr|WSREP: Protocol violation. JOIN message sender .* is not in state transfer \(JOINED\). Message ignored.|, + qr|WSREP: Unsupported protocol downgrade: incremental data collection disabled. Expect abort.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), qr(WSREP: discarding established .*), + qr|WSREP: .*core_handle_uuid_msg.*|, + qr(WSREP: --wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=0. WSREP_SYNC_WAIT_BEFORE_READ is on), + qr|WSREP: JOIN message from member .* in non-primary configuration. Ignored.|, ); $ENV{PATH}="$epath:$ENV{PATH}"; $ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath; +$ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; bless { }; diff --git a/mysql-test/suite/galera/t/GAL-401.test b/mysql-test/suite/galera/t/GAL-401.test index 66015f970c9..06ce37dc81f 100644 --- a/mysql-test/suite/galera/t/GAL-401.test +++ b/mysql-test/suite/galera/t/GAL-401.test @@ -10,6 +10,7 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; --connection node_2 SET @@global.wsrep_desync = 1; SET SESSION wsrep_dirty_reads=1; +SET SESSION wsrep_sync_wait=0; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; --let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --source include/wait_condition.inc @@ -27,10 +28,13 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); # Reconnect node 2 to the PC: --connection node_2 SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +SET wsrep_dirty_reads=0; --let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --source include/wait_condition.inc --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc # Must return 0: SHOW STATUS LIKE 'wsrep_desync_count'; @@ -41,6 +45,7 @@ SET @@global.wsrep_desync = 0; --let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; --source include/wait_condition.inc +SET SESSION wsrep_sync_wait=15; SHOW CREATE TABLE t1; DROP TABLE t1; CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored."); diff --git a/mysql-test/suite/galera/t/MW-286.test b/mysql-test/suite/galera/t/MW-286.test index 1b2e322f078..08deb317fbe 100644 --- a/mysql-test/suite/galera/t/MW-286.test +++ b/mysql-test/suite/galera/t/MW-286.test @@ -25,6 +25,7 @@ SET wsrep_on = FALSE; --error ER_QUERY_INTERRUPTED ALTER TABLE t1 ADD PRIMARY KEY (f1); +SET SESSION wsrep_sync_wait = 0; SET wsrep_on = TRUE; SET GLOBAL wsrep_desync = FALSE; diff --git a/mysql-test/suite/galera/t/MW-329.test b/mysql-test/suite/galera/t/MW-329.test index 5a48352da9b..b3b4e8e921f 100644 --- a/mysql-test/suite/galera/t/MW-329.test +++ b/mysql-test/suite/galera/t/MW-329.test @@ -82,3 +82,6 @@ SELECT VARIABLE_VALUE > 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --connection node_1 DROP PROCEDURE proc_insert; DROP TABLE t1; + +# Due to MW-330, Multiple "conflict state 3 after post commit" warnings if table is dropped while SP is running +CALL mtr.add_suppression("conflict state 3 after post commit"); diff --git a/mysql-test/suite/galera/t/MW-336.test b/mysql-test/suite/galera/t/MW-336.test new file mode 100644 index 00000000000..79d8951a822 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-336.test @@ -0,0 +1,64 @@ +# +# MW-336 Slave threads may leak if variable wsrep_slave_threads is set repeatedly +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +--connection node_1 +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 1; + +--connection node_2 +INSERT INTO t1 VALUES (1); + +--connection node_1 +--sleep 0.5 +SET GLOBAL wsrep_slave_threads = 10; +--sleep 0.5 +SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + +SET GLOBAL wsrep_slave_threads = 20; +--sleep 0.5 +SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + + +SET GLOBAL wsrep_slave_threads = 1; + +--connection node_2 +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); + + +--connection node_1 +SET GLOBAL wsrep_slave_threads = 10; +SET GLOBAL wsrep_slave_threads = 0; + +--connection node_2 +INSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (11); +INSERT INTO t1 VALUES (12); +INSERT INTO t1 VALUES (13); +INSERT INTO t1 VALUES (14); +INSERT INTO t1 VALUES (15); +INSERT INTO t1 VALUES (16); +INSERT INTO t1 VALUES (17); +INSERT INTO t1 VALUES (18); +INSERT INTO t1 VALUES (19); +INSERT INTO t1 VALUES (20); + +--connection node_1 +--sleep 0.5 +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + +SET GLOBAL wsrep_slave_threads = 1; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-357.test b/mysql-test/suite/galera/t/MW-357.test new file mode 100644 index 00000000000..d13cf058aeb --- /dev/null +++ b/mysql-test/suite/galera/t/MW-357.test @@ -0,0 +1,13 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_2 +SET GLOBAL wsrep_slave_threads = 0; + +--connection node_1 +CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; + +--connection node_1 +INSERT INTO t1 VALUES (1); + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-369.test b/mysql-test/suite/galera/t/MW-369.test index bfb9460b411..720d6daf518 100644 --- a/mysql-test/suite/galera/t/MW-369.test +++ b/mysql-test/suite/galera/t/MW-369.test @@ -244,4 +244,3 @@ SELECT * FROM c; DROP TABLE c; DROP TABLE p; ---sleep 3 diff --git a/mysql-test/suite/galera/t/MW-86-wait1-master.opt b/mysql-test/suite/galera/t/MW-86-wait1-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-wait1-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates diff --git a/mysql-test/suite/galera/t/MW-86-wait1.test b/mysql-test/suite/galera/t/MW-86-wait1.test new file mode 100644 index 00000000000..6c0982ad8b3 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-wait1.test @@ -0,0 +1,106 @@ +# +# SHOW commands no longer obey wsrep_sync_wait = 1 (WSREP_SYNC_WAIT_BEFORE_READ) +# (they do not wait for the background INSERT in the applier in node_2 to +# complete) +# +--source include/galera_cluster.inc +--source include/have_binlog_format_row.inc +--source include/have_debug_sync.inc + +--connection node_2 +# Make sure no signals have been leftover from previous tests to surprise us. +SELECT @@debug_sync; + +SET SESSION wsrep_sync_wait = 1; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; + +--connection node_1 +CREATE TABLE t_wait1 (f1 INTEGER) ENGINE=InnoDB; +# This will complete in node_1 but will start a background apply in node_2 +# which will stop because of sync.wsrep_apply_cb we set above. +INSERT INTO t_wait1 VALUES (1); + +--connection node_2 + +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +--disable_result_log + +SHOW BINARY LOGS; + +SHOW BINLOG EVENTS; + +--error ER_NO_SUCH_TABLE +SHOW COLUMNS FROM t1; + +--error ER_EVENT_DOES_NOT_EXIST +SHOW CREATE EVENT e1; + +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE FUNCTION f1; + +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE PROCEDURE p1; + +--error ER_NO_SUCH_TABLE +SHOW CREATE TABLE t1; + +--error ER_TRG_DOES_NOT_EXIST +SHOW CREATE TRIGGER tr1; + +--error ER_NO_SUCH_TABLE +SHOW CREATE VIEW v1; + +SHOW DATABASES; + +SHOW ENGINE InnoDB STATUS; + +--error ER_SP_DOES_NOT_EXIST +SHOW FUNCTION CODE f1; + +SHOW FUNCTION STATUS; + +SHOW GRANTS FOR 'root'@'localhost'; + +--error ER_NO_SUCH_TABLE +SHOW INDEX FROM t1; + +SHOW OPEN TABLES; + +--error ER_SP_DOES_NOT_EXIST +SHOW PROCEDURE CODE p1; + +SHOW PROCEDURE STATUS; + +SHOW PRIVILEGES; + +SHOW STATUS LIKE 'wsrep_cluster_size'; + +SHOW TABLE STATUS; + +SHOW TABLES; + +SHOW TRIGGERS; + +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; + +--error 0 +SHOW WARNINGS; + +--enable_result_log + +# Unblock the background INSERT and remove the sync point. +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +SET SESSION debug_sync = "now SIGNAL signal.wsrep_apply_cb"; + +SET SESSION wsrep_sync_wait = default; + +# This will wait for the background INSERT to complete before we quit +# from the test. +DROP TABLE t_wait1; + +SET GLOBAL debug = NULL; +SET debug_sync='RESET'; + +# Make sure no pending signals are leftover to surprise subsequent tests. +SELECT @@debug_sync; diff --git a/mysql-test/suite/galera/t/MW-86-wait8-master.opt b/mysql-test/suite/galera/t/MW-86-wait8-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-wait8-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates diff --git a/mysql-test/suite/galera/t/MW-86-wait8.test b/mysql-test/suite/galera/t/MW-86-wait8.test new file mode 100644 index 00000000000..65e612c5c8e --- /dev/null +++ b/mysql-test/suite/galera/t/MW-86-wait8.test @@ -0,0 +1,128 @@ +# +# SHOW commands now obey wsrep_sync_wait = 8 (WSREP_SYNC_WAIT_BEFORE_SHOW) +# +--source include/galera_cluster.inc +--source include/have_binlog_format_row.inc +--source include/have_debug_sync.inc + +--connection node_2 +# Make sure no signals have been leftover from previous tests to surprise us. +SELECT @@debug_sync; + +SET SESSION wsrep_sync_wait = 8; +SET GLOBAL debug = "+d,sync.wsrep_apply_cb"; + +--connection node_1 +CREATE TABLE t_wait8 (f1 INTEGER) ENGINE=InnoDB; +# This will complete in node_1 but will start a background apply in node_2 +# which will stop because of sync.wsrep_apply_cb we set above. +INSERT INTO t_wait8 VALUES (1); + +--connection node_2 + +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT0.1S"; + +SET SESSION debug_sync = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +--disable_result_log + +--error ER_LOCK_WAIT_TIMEOUT +SHOW BINARY LOGS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW BINLOG EVENTS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW COLUMNS FROM t1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE DATABASE db1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE EVENT e1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE FUNCTION f1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE PROCEDURE p1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE TABLE t1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE TRIGGER tr1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW CREATE VIEW v1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW DATABASES; + +--error 0 +SHOW ENGINE InnoDB STATUS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW FUNCTION CODE f1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW FUNCTION STATUS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW GRANTS FOR 'root'@'localhost'; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW INDEX FROM t1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW OPEN TABLES; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW PROCEDURE CODE p1; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW PROCEDURE STATUS; + +--error 0 +SHOW PRIVILEGES; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW TABLE STATUS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW TABLES; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW TRIGGERS; + +--error ER_LOCK_WAIT_TIMEOUT +SHOW GLOBAL VARIABLES LIKE 'foo_bar'; + +--error 0 +SHOW WARNINGS; + +--enable_result_log + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig" +--enable_query_log + +# Unblock the background INSERT and remove the sync point. +SET GLOBAL debug = "-d,sync.wsrep_apply_cb"; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +SET SESSION wsrep_sync_wait = default; + +# This will wait for the background INSERT to complete before we quit +# from the test. +DROP TABLE t_wait8; + +SET GLOBAL debug = NULL; +SET debug_sync='RESET'; + +# Make sure no pending signals are leftover to surprise subsequent tests. +SELECT @@debug_sync; diff --git a/mysql-test/suite/galera/t/galera#414.test b/mysql-test/suite/galera/t/galera#414.test index dccb28e4054..de10898df42 100644 --- a/mysql-test/suite/galera/t/galera#414.test +++ b/mysql-test/suite/galera/t/galera#414.test @@ -6,6 +6,11 @@ --source include/have_innodb.inc --source include/galera_cluster.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # We perform the shutdown/restart sequence in here. If there was a crash during shutdown, MTR will detect it --connection node_2 @@ -35,3 +40,4 @@ CALL mtr.add_suppression("Failed to set packet size"); --source include/wait_condition.inc CALL mtr.add_suppression("Failed to set packet size"); +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test b/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test index 6747977812b..97819384a75 100644 --- a/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test +++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table.test @@ -28,7 +28,7 @@ SELECT COUNT(*) = 0 FROM t1; --connection node_1 UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 2 FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test index 99c45c04ba0..67f2108d263 100644 --- a/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test +++ b/mysql-test/suite/galera/t/galera_applier_ftwrl_table_alter.test @@ -29,7 +29,7 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system use UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SHOW CREATE TABLE t1; SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'; diff --git a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test index 9292badc480..59483d0591c 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_autoinc.test +++ b/mysql-test/suite/galera/t/galera_as_slave_autoinc.test @@ -48,7 +48,7 @@ insert into t1(i) values(null), (null), (null); select * from t1; show variables like 'binlog_format'; -show variables like '%auto_increment%'; +show variables like 'auto_increment_increment'; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test index e32089ce21e..fde783e2cef 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_flush_for_export.test @@ -27,7 +27,7 @@ UNLOCK TABLES; COMMIT; SET AUTOCOMMIT=ON; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 1 FROM t1; --let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` diff --git a/mysql-test/suite/galera/t/galera_ddl_multiline.test b/mysql-test/suite/galera/t/galera_ddl_multiline.test new file mode 100644 index 00000000000..c7155d066fa --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ddl_multiline.test @@ -0,0 +1,54 @@ +# +# Test that Galera works correctly with multiline statements, in particular involving DDLs +# + +--source include/galera_cluster.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; + +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; + +--connection node_2 +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; + +--connection node_1 +--send CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; CREATE TABLE t4 (f1 INTEGER) ENGINE=InnoDB; +--reap + +SHOW CREATE TABLE t3; +SHOW CREATE TABLE t4; + +--connection node_2 +SHOW CREATE TABLE t3; +SHOW CREATE TABLE t4; + +--connection node_1 +INSERT INTO t1 VALUES (1); CREATE TABLE t5 (f1 INTEGER) ENGINE=InnoDB; + +SELECT COUNT(*) = 1 FROM t1; +SHOW CREATE TABLE t5; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SHOW CREATE TABLE t5; + +--connection node_1 +--send CREATE TABLE t6 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t2 VALUES (1); +--reap + +SELECT COUNT(*) = 1 FROM t2; +SHOW CREATE TABLE t6; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t2; +SHOW CREATE TABLE t6; + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +--connection node_1 +DROP TABLE t1, t2, t3, t4, t5, t6; + diff --git a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test index dc65a452d7c..61576a39316 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test +++ b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test @@ -21,11 +21,11 @@ LOCK TABLE t1 WRITE; --connection node_1 --sleep 1 INSERT INTO t1 VALUES (2); ---sleep 1 +--sleep 2 INSERT INTO t1 VALUES (3); ---sleep 1 +--sleep 2 INSERT INTO t1 VALUES (4); ---sleep 1 +--sleep 2 # This query will hang because flow control will kick in --send diff --git a/mysql-test/suite/galera/t/galera_insert_ignore.test b/mysql-test/suite/galera/t/galera_insert_ignore.test index 4b4b0a6e9fb..027f70e96d9 100644 --- a/mysql-test/suite/galera/t/galera_insert_ignore.test +++ b/mysql-test/suite/galera/t/galera_insert_ignore.test @@ -2,10 +2,10 @@ --source include/have_innodb.inc --let $wsrep_sync_wait_orig = (SELECT @@wsrep_sync_wait) -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; --connection node_2 -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; # diff --git a/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf b/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf index db6b7d5e129..357c8678658 100644 --- a/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf +++ b/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf @@ -9,3 +9,4 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_progress.cnf b/mysql-test/suite/galera/t/galera_ist_progress.cnf new file mode 100644 index 00000000000..0a26f6d6c83 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_progress.cnf @@ -0,0 +1,5 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_progress.test b/mysql-test/suite/galera/t/galera_ist_progress.test new file mode 100644 index 00000000000..3ba63415c28 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_progress.test @@ -0,0 +1,76 @@ +# +# Test progress output during IST +# + +--source include/galera_cluster.inc +# This could cause out of storage if run /dev/shm +--source include/big_test.inc + +# Isolate node #2 +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +SET SESSION wsrep_on = OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +SET SESSION wsrep_on = ON; + +# Node #2 is now isolated. Run some transactions to accumulate writesets for IST + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +INSERT INTO t1 VALUES (10); + +# Restore node #2, IST is performed + +--connection node_2 +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +# +# Grep for expected IST output in joiner log +# + +--connection node_1 + +--let $assert_count = 1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_only_after = Need state transfer + +--let $assert_text = Receiving IST: 11 writesets, seqnos +--let $assert_select = Receiving IST: 11 writesets, seqnos +--source include/assert_grep.inc + +--let $assert_text = Receiving IST\.\.\. 0\.0% \( 0/11 events\) complete +--let $assert_select = Receiving IST\.\.\. 0\.0% \( 0/11 events\) complete +--source include/assert_grep.inc + +--let $assert_text = Receiving IST\.\.\.100\.0% \(11/11 events\) complete +--let $assert_select = Receiving IST\.\.\.100\.0% \(11/11 events\) complete +--source include/assert_grep.inc + +# Cleanup + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_ist_recv_bind.test b/mysql-test/suite/galera/t/galera_ist_recv_bind.test index cb7329073ad..a339684c158 100644 --- a/mysql-test/suite/galera/t/galera_ist_recv_bind.test +++ b/mysql-test/suite/galera/t/galera_ist_recv_bind.test @@ -5,6 +5,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/big_test.inc --connection node_1 SELECT @@wsrep_provider_options LIKE '%ist.recv_bind = 127.0.0.1%'; diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index 931daaad30d..633318629a6 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -8,6 +8,8 @@ --source include/have_innodb.inc --source include/have_debug_sync.inc --source suite/galera/include/galera_have_debug_sync.inc +# This could cause out of storage if run /dev/shm +--source include/big_test.inc # Save original auto_increment_offset values. --let $node_1=node_1 @@ -31,13 +33,6 @@ UPDATE t1 SET f2 = 'b' WHERE f1 > 1; UPDATE t1 SET f2 = 'c' WHERE f1 > 2; --connection node_2 -# Make sure IST will block ... ---let $galera_sync_point = recv_IST_after_apply_trx ---source include/galera_set_sync_point.inc - -SET SESSION wsrep_sync_wait = 0; - - # Write file to make mysql-test-run.pl expect the crash, but don't start it --let $_server_id= `SELECT @@server_id` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect @@ -48,21 +43,23 @@ SET SESSION wsrep_sync_wait = 0; # ... and restart provider to force IST --echo Loading wsrep_provider ... --disable_query_log +# base_port setting is lost for some reason when unloading provider, so we need to restore it +--eval SET GLOBAL wsrep_provider_options= 'base_port=$NODE_GALERAPORT_2'; --eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig'; +# Make sure IST will block ... +--let $galera_sync_point = recv_IST_after_apply_trx +--source include/galera_set_sync_point.inc --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log -# We can not use a wait_condition on SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS as such queries are blocked during IST -# so we perform a simple sleep and SHOW instead - ---sleep 5 -SHOW STATUS LIKE 'wsrep_debug_sync_waiters'; +SET SESSION wsrep_on=OFF; +--let $wait_condition = SELECT VARIABLE_VALUE = 'recv_IST_after_apply_trx' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters'; +--source include/wait_condition.inc +SET SESSION wsrep_on=ON; --connection node_1 -# Perform DML and DDL while IST is in progress ---connection node_1 +# Perform DML while IST is in progress UPDATE t1 SET f2 = 'd' WHERE f1 > 3; -CREATE TABLE t2 (f1 INTEGER); # Kill node #2 while IST is in progress --connection node_2 @@ -85,9 +82,8 @@ EOF --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' --source include/wait_condition.inc -# Perform DML and DDL while node #2 is down +# Perform DML while node #2 is down UPDATE t1 SET f2 = 'e' WHERE f1 > 4; -CREATE TABLE t3 (f1 INTEGER); --connection node_2 @@ -106,11 +102,9 @@ SELECT * FROM t1; --connection node_2 SELECT * FROM t1; -SELECT COUNT(*) = 0 FROM t2; -SELECT COUNT(*) = 0 FROM t3; --connection node_1 -DROP TABLE t1, t2, t3; +DROP TABLE t1; # Restore original auto_increment_offset values. --source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ist_rsync.cnf b/mysql-test/suite/galera/t/galera_ist_rsync.cnf index bbe0f6047fb..797e3651967 100644 --- a/mysql-test/suite/galera/t/galera_ist_rsync.cnf +++ b/mysql-test/suite/galera/t/galera_ist_rsync.cnf @@ -5,7 +5,9 @@ wsrep_sst_method=rsync [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' +wsrep_sync_wait=1 [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' +wsrep_sync_wait=1 diff --git a/mysql-test/suite/galera/t/galera_ist_rsync.test b/mysql-test/suite/galera/t/galera_ist_rsync.test index 41d1a0c1fc2..1da79cd4214 100644 --- a/mysql-test/suite/galera/t/galera_ist_rsync.test +++ b/mysql-test/suite/galera/t/galera_ist_rsync.test @@ -2,7 +2,12 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --source suite/galera/include/galera_st_disconnect_slave.inc --source suite/galera/include/galera_st_shutdown_slave.inc --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_kill_applier.test b/mysql-test/suite/galera/t/galera_kill_applier.test index 6e3d7ea65d2..d04b72bce0a 100644 --- a/mysql-test/suite/galera/t/galera_kill_applier.test +++ b/mysql-test/suite/galera/t/galera_kill_applier.test @@ -6,7 +6,7 @@ --source include/have_innodb.inc --connection node_1 ---sleep 1 +--sleep 2 --let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE IS NULL LIMIT 1` --disable_query_log diff --git a/mysql-test/suite/galera/t/galera_many_rows.test b/mysql-test/suite/galera/t/galera_many_rows.test index 653dc2dd75a..58ba85e1b9e 100644 --- a/mysql-test/suite/galera/t/galera_many_rows.test +++ b/mysql-test/suite/galera/t/galera_many_rows.test @@ -16,7 +16,7 @@ INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4 --connection node_2 SET SESSION wsrep_sync_wait = 0; --let $wsrep_provider_options_node2 = `SELECT @@wsrep_provider_options` -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H'; diff --git a/mysql-test/suite/galera/t/galera_migrate.cnf b/mysql-test/suite/galera/t/galera_migrate.cnf index 47bdf53afef..ed48f208e52 100644 --- a/mysql-test/suite/galera/t/galera_migrate.cnf +++ b/mysql-test/suite/galera/t/galera_migrate.cnf @@ -13,7 +13,7 @@ log-bin=mysqld-bin wsrep_node_address=127.0.0.1 wsrep_causal_reads=ON -wsrep_sync_wait = 7 +wsrep_sync_wait = 15 [mysqld.1] #galera_port=@OPT.port diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test index e078a342c16..41cd0c8e6fa 100644 --- a/mysql-test/suite/galera/t/galera_parallel_simple.test +++ b/mysql-test/suite/galera/t/galera_parallel_simple.test @@ -45,7 +45,7 @@ SET SESSION wsrep_sync_wait = 0; UNLOCK TABLES; -SET SESSION wsrep_sync_wait = 7; +SET SESSION wsrep_sync_wait = 15; SELECT COUNT(*) = 10 FROM t1; SELECT COUNT(*) = 10 FROM t2; diff --git a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test index 6b14118d5fc..87afc2d7bb2 100644 --- a/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test +++ b/mysql-test/suite/galera/t/galera_query_cache_sync_wait.test @@ -10,7 +10,6 @@ INSERT INTO t1 VALUES (1); --let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; # first lookup miss # @@ -27,7 +26,6 @@ SET GLOBAL DEBUG = ""; SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; FLUSH QUERY CACHE; -SET SESSION wsrep_sync_wait = 7; SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; SET DEBUG_SYNC = "RESET"; @@ -52,9 +50,7 @@ SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; INSERT INTO t1 VALUES (4); --connection node_2 -SET SESSION wsrep_sync_wait = 7; SELECT MAX(id) FROM t1; -SET SESSION wsrep_sync_wait = 7; # # Query cache hit @@ -73,7 +69,6 @@ SET GLOBAL DEBUG = "d,sync.wsrep_apply_cb"; INSERT INTO t1 VALUES (5); --connection node_2 -SET SESSION wsrep_sync_wait = 7; --send SELECT MAX(id) FROM t1 --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 diff --git a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test index a8246e94591..ed7f106c123 100644 --- a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test +++ b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test @@ -154,3 +154,5 @@ DROP TABLE t1; } EOF --remove_file $TEST_LOG.copy + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ssl.test b/mysql-test/suite/galera/t/galera_ssl.test index 8dc94dc1966..e6346aa2151 100644 --- a/mysql-test/suite/galera/t/galera_ssl.test +++ b/mysql-test/suite/galera/t/galera_ssl.test @@ -8,6 +8,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/big_test.inc SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; diff --git a/mysql-test/suite/galera/t/galera_ssl_compression.test b/mysql-test/suite/galera/t/galera_ssl_compression.test index cdecf4807d4..75f92c5b2f4 100644 --- a/mysql-test/suite/galera/t/galera_ssl_compression.test +++ b/mysql-test/suite/galera/t/galera_ssl_compression.test @@ -7,6 +7,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/big_test.inc SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test index 353a7c38a73..dcc4a8d14c3 100644 --- a/mysql-test/suite/galera/t/galera_suspend_slave.test +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -41,6 +41,7 @@ INSERT INTO t1 VALUES (1); exit(0); EOF +SET SESSION wsrep_sync_wait = 1; --sleep 10 --source include/wait_until_ready.inc INSERT INTO t1 VALUES (1); @@ -50,9 +51,11 @@ INSERT INTO t1 VALUES (1); --source include/galera_connect.inc --connection node_2a +SET SESSION wsrep_sync_wait = 1; --source include/wait_until_ready.inc SELECT COUNT(*) = 1 FROM t1; +SET SESSION wsrep_sync_wait = 15; DROP TABLE t1; # Restore original auto_increment_offset values. diff --git a/mysql-test/suite/galera/t/galera_sync_wait_show.test b/mysql-test/suite/galera/t/galera_sync_wait_show.test index 3707b7ebaf1..edad2840da2 100644 --- a/mysql-test/suite/galera/t/galera_sync_wait_show.test +++ b/mysql-test/suite/galera/t/galera_sync_wait_show.test @@ -7,7 +7,8 @@ --source include/have_debug.inc --connection node_2 -SET SESSION wsrep_sync_wait = 1; +# MW-86 SHOW commands have now bitmap value 8 +SET SESSION wsrep_sync_wait = 8; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_unicode_identifiers.test b/mysql-test/suite/galera/t/galera_unicode_identifiers.test index 9adac1aa555..f3df60a6415 100644 --- a/mysql-test/suite/galera/t/galera_unicode_identifiers.test +++ b/mysql-test/suite/galera/t/galera_unicode_identifiers.test @@ -6,10 +6,10 @@ --source include/have_innodb.inc --let $wsrep_sync_wait_orig = (SELECT @@wsrep_sync_wait) -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; --connection node_2 -SET GLOBAL wsrep_sync_wait = 7; +SET GLOBAL wsrep_sync_wait = 15; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 1fd30c69a7b..cba8488b879 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -17,15 +17,10 @@ CREATE TABLE t1(i INT) ENGINE=INNODB; INSERT INTO t1 VALUES(1); SELECT * FROM t1; -create user user1; -grant all privileges on *.* to user1; -create user user2; -grant all privileges on *.* to user2; - SET @@global.wsrep_cluster_address = ''; SET @@session.wsrep_dirty_reads=OFF; -# Set wsrep_sync_wait to avoid ER_LOCK_WAIT_TIMEOUT (MDEV-6832). +# Set wsrep_sync_wait to avoid ER_LOCK_WAIT_TIMEOUT. SET SESSION wsrep_sync_wait=0; # Must return 'OFF' @@ -37,75 +32,31 @@ SHOW STATUS LIKE 'wsrep_cluster_status'; --error ER_UNKNOWN_COM_ERROR SELECT * FROM t1; -#Select query which does not access table should be allowed MDEV-11016 -SELECT @@wsrep_dirty_reads; -SELECT 2; -SELECT 2+2 FROM DUAL; +--error ER_UNKNOWN_COM_ERROR +SELECT 1 FROM t1; SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; +SELECT 1 FROM t1; ---enable_connect_log ---connect (con1, localhost, user1,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2) -#Just test the session behavior -SET SESSION wsrep_sync_wait=0; - -set session wsrep_dirty_reads=1; -#Prepared statement creation should be allowed MDEV-11479 -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; -set session wsrep_dirty_reads=0; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; -#No Preapare stmt/proceure will be allowed ---error ER_UNKNOWN_COM_ERROR -execute stmt_show; ---error ER_UNKNOWN_COM_ERROR -execute stmt_select; ---error ER_UNKNOWN_COM_ERROR -execute stmt_insert; +SET @@session.wsrep_dirty_reads=OFF; -SET wsrep_dirty_reads=ON; -select @@session.wsrep_dirty_reads; -#Only prepare statement which does not change data should be allowed -execute stmt_show; -execute stmt_select; --error ER_UNKNOWN_COM_ERROR -execute stmt_insert; -SET @@global.wsrep_dirty_reads=ON; - ---connect (con2, localhost, user2,,test,$NODE_MYPORT_2,$NODE_MYSOCK_2) -#Just test the session behavior -select @@session.wsrep_dirty_reads; +SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; -prepare stmt_show from 'select 1'; -prepare stmt_select from 'select * from t1'; -prepare stmt_insert from 'insert into t1 values(1)'; +SELECT 1; -#Only prepare statement which does not change data should be allowed -execute stmt_show; -execute stmt_select; --error ER_UNKNOWN_COM_ERROR -execute stmt_insert; - -#wsrep_dirty_read should work when wsrep_sync_wait is 1 or non zero -#because we already are disconnected , So It does not make any sense -#to wait for other nodes -SET SESSION wsrep_sync_wait=1; -execute stmt_show; -execute stmt_select; ---error ER_UNKNOWN_COM_ERROR -execute stmt_insert; +USE information_schema; -SET SESSION wsrep_sync_wait=7; -execute stmt_show; -execute stmt_select; --error ER_UNKNOWN_COM_ERROR -execute stmt_insert; +SELECT * FROM information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads"; ---connection node_2 -SET @@global.wsrep_dirty_reads=OFF; +--error ER_UNKNOWN_COM_ERROR +SELECT COUNT(*) >= 10 FROM performance_schema.events_statements_history; --disable_query_log --eval SET @@global.wsrep_cluster_address = '$wsrep_cluster_address_saved' @@ -113,13 +64,11 @@ SET @@global.wsrep_dirty_reads=OFF; --source include/wait_until_connected_again.inc --connection node_1 +USE test; SELECT * FROM t1; # Cleanup DROP TABLE t1; -drop user user1; -drop user user2; -# Restore original auto_increment_offset values. --source include/auto_increment_offset_restore.inc --source include/galera_end.inc diff --git a/mysql-test/suite/galera/t/galera_var_node_address.test b/mysql-test/suite/galera/t/galera_var_node_address.test index c2105823326..3353652d8b9 100644 --- a/mysql-test/suite/galera/t/galera_var_node_address.test +++ b/mysql-test/suite/galera/t/galera_var_node_address.test @@ -7,6 +7,8 @@ --source include/have_innodb.inc call mtr.add_suppression("WSREP: Stray state UUID msg: .* current group state WAIT_STATE_UUID .*"); +call mtr.add_suppression("WSREP: Protocol violation. JOIN message sender .* is not in state transfer (.*). Message ignored."); + SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_var_sync_wait.test b/mysql-test/suite/galera/t/galera_var_sync_wait.test index 288ad62226f..ecb0d92b891 100644 --- a/mysql-test/suite/galera/t/galera_var_sync_wait.test +++ b/mysql-test/suite/galera/t/galera_var_sync_wait.test @@ -20,7 +20,10 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; --connection node_2 SET GLOBAL wsrep_sync_wait = 1; # Those statements should see the table -SHOW TABLES LIKE '%t1'; + +# MW-86 SHOW commands have now their own bitmask +# SHOW TABLES LIKE '%t1'; + SELECT COUNT(*) = 0 FROM t1; --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test b/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test index fe4c358bd89..7f91495fcc4 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test +++ b/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test @@ -6,6 +6,11 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + --connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); @@ -26,6 +31,8 @@ INSERT INTO t1 VALUES (3); --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log +SET SESSION wsrep_sync_wait = 0; + --source include/wait_until_connected_again.inc --source include/galera_wait_ready.inc @@ -39,3 +46,5 @@ SELECT COUNT(*) = 4 FROM t1; SELECT COUNT(*) = 3 FROM t1; DROP TABLE t1; + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test index be56ee5edc1..0c707d6d681 100644 --- a/mysql-test/suite/galera/t/lp1376747-4.test +++ b/mysql-test/suite/galera/t/lp1376747-4.test @@ -45,7 +45,7 @@ SHOW CREATE TABLE t1; --connection node_2a --reap UNLOCK TABLES; ---sleep 1 +--sleep 2 SHOW CREATE TABLE t1; SELECT * from t1; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#198.test b/mysql-test/suite/galera/t/mysql-wsrep#198.test index 2b05c4ff4d9..a80d030a8b0 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#198.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#198.test @@ -5,6 +5,9 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; --connection node_2 +# Ensure that the tables have been created on node #2 +SELECT 1 FROM DUAL; + LOCK TABLE t2 WRITE; --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 diff --git a/mysql-test/suite/galera/t/mysql-wsrep#201.test b/mysql-test/suite/galera/t/mysql-wsrep#201.test index e9327540195..21cf05db008 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#201.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#201.test @@ -8,7 +8,6 @@ INSERT INTO t1 VALUES (DEFAULT); --connection node_2 --let $qcache_size_orig = `SELECT @@GLOBAL.query_cache_size` SET GLOBAL query_cache_size=1355776; -SET SESSION wsrep_sync_wait = 7; --disable_query_log diff --git a/mysql-test/suite/galera/t/pxc-421.test b/mysql-test/suite/galera/t/pxc-421.test index 8a360b12f4c..381f9bb4494 100644 --- a/mysql-test/suite/galera/t/pxc-421.test +++ b/mysql-test/suite/galera/t/pxc-421.test @@ -31,6 +31,7 @@ INSERT INTO t1 VALUES (3); --eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; --enable_query_log +set SESSION wsrep_sync_wait=0; --source include/wait_until_connected_again.inc --source include/galera_wait_ready.inc @@ -53,8 +54,12 @@ show global variables like 'wsrep_slave_threads'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_2 SELECT COUNT(*) FROM t1; +SET GLOBAL auto_increment_offset = 2; + --connection node_1 SELECT COUNT(*) FROM t1; show global variables like 'wsrep_slave_threads'; --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_1 DROP TABLE t1; + +SET GLOBAL auto_increment_offset = 1; diff --git a/mysql-test/suite/galera/t/query_cache.opt b/mysql-test/suite/galera/t/query_cache.opt new file mode 100644 index 00000000000..a00258bc48c --- /dev/null +++ b/mysql-test/suite/galera/t/query_cache.opt @@ -0,0 +1 @@ +--query_cache_type=1 diff --git a/mysql-test/suite/galera/t/query_cache.test b/mysql-test/suite/galera/t/query_cache.test index 24ed8ecd077..e024b308fab 100644 --- a/mysql-test/suite/galera/t/query_cache.test +++ b/mysql-test/suite/galera/t/query_cache.test @@ -323,7 +323,7 @@ drop table t1; --echo # On node-1 --connection node_1 create table t1 (a char(1) not null collate koi8r_general_ci) engine=innodb; -insert into t1 values(_koi8r"á"); +insert into t1 values(_koi8r 0xc3); set CHARACTER SET koi8r; select * from t1; set CHARACTER SET cp1251_koi8; @@ -861,7 +861,7 @@ drop table t1; --connection node_1 SET NAMES koi8r; CREATE TABLE t1 (a char(1) character set koi8r) engine=innodb; -INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Ã'); +INSERT INTO t1 VALUES (_koi8r 0xc3),(_koi8r 0xc3); # # Run select # diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index 502e7bfba68..a9b9b00b40c 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -1,8 +1,3 @@ -galera_garbd : Fix the test case -galera_evs_suspect_timeout : TODO: investigate -galera_innobackupex_backup : TODO: investigate galera_slave_options_do :MDEV-8798 galera_slave_options_ignore : MDEV-8798 -galera_pc_bootstrap : TODO: Investigate: Timeout in wait_condition.inc -galera_pc_weight : Test times out -galera_safe_to_bootstrap : I Really dont know :( + diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf index 305bdaaae3a..fe3bcb1e8ff 100644 --- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf +++ b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf @@ -11,7 +11,7 @@ wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 # enforce read-committed characteristics across the cluster wsrep-causal-reads=ON -wsrep-sync-wait=7 +wsrep-sync-wait=15 [mysqld.1] wsrep-cluster-address='gcomm://' diff --git a/mysql-test/suite/galera_3nodes/r/GAL-501.result b/mysql-test/suite/galera_3nodes/r/GAL-501.result new file mode 100644 index 00000000000..a2bf5f4d98c --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/GAL-501.result @@ -0,0 +1,14 @@ +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 3 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result b/mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result new file mode 100644 index 00000000000..f519654952b --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_ipv6_mysqldump.result @@ -0,0 +1,26 @@ +GRANT ALL PRIVILEGES ON *.* TO 'sst'; +SET GLOBAL wsrep_sst_auth = 'sst:'; +SET GLOBAL wsrep_sst_method = 'mysqldump'; +Unloading wsrep provider ... +SET GLOBAL wsrep_provider = 'none'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +Loading wsrep provider ... +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); +DROP USER sst; +CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); +CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found"); +CALL mtr.add_suppression("InnoDB: New log files created"); +CALL mtr.add_suppression("InnoDB: Creating foreign key constraint system tables"); +CALL mtr.add_suppression("Can't open and lock time zone table"); +CALL mtr.add_suppression("Can't open and lock privilege tables"); +CALL mtr.add_suppression("Info table is not ready to be used"); +CALL mtr.add_suppression("Native table .* has the wrong structure"); +CALL mtr.add_suppression("Unsupported protocol downgrade: incremental data collection disabled. Expect abort"); diff --git a/mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result b/mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result new file mode 100644 index 00000000000..a2bf5f4d98c --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_ipv6_rsync.result @@ -0,0 +1,14 @@ +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 3 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result b/mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result new file mode 100644 index 00000000000..53e35939a79 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_ipv6_xtrabackup-v2.result @@ -0,0 +1,18 @@ +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +VARIABLE_VALUE LIKE '%[::1]%' +1 +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE = 3 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +DROP TABLE t1; +include/assert_grep.inc [Streaming the backup to joiner at \[::1\]] +include/assert_grep.inc [async IST sender starting to serve tcp://\[::1\]:] +include/assert_grep.inc [IST receiver addr using tcp://\[::1\]] +include/assert_grep.inc [Prepared IST receiver, listening at: tcp://\[::1\]] diff --git a/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result b/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result new file mode 100644 index 00000000000..88780a2c87f --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result @@ -0,0 +1,48 @@ +CREATE TABLE t1 (f1 INTEGER); +INSERT INTO t1 VALUES (1); +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +SET SESSION wsrep_sync_wait = 0; +SET SESSION wsrep_dirty_reads = 1; +SELECT f1 FROM t1; +f1 +1 +USE test; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +LOCK TABLE t1 WRITE; +UNLOCK TABLES; +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +PREPARE stmt_select FROM 'SELECT f1 FROM t1'; +EXECUTE stmt_select; +f1 +1 +PREPARE stmt_update FROM 'UPDATE t1 SET f1 = f1 + f1'; +SET GLOBAL wsrep_dirty_reads = 1; +SET GLOBAL wsrep_sync_wait = 0; +SET GLOBAL wsrep_dirty_reads = 0; +SET GLOBAL wsrep_sync_wait = 15; +SET SESSION wsrep_dirty_reads = 1; +INSERT INTO t1 SELECT * FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +DELETE FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +UPDATE t1 SET f1 = f1 + 1; +ERROR 08S01: WSREP has not yet prepared node for application use +DROP TABLE t1; +ERROR 08S01: WSREP has not yet prepared node for application use +EXECUTE stmt_update; +ERROR 08S01: WSREP has not yet prepared node for application use +SET SESSION wsrep_dirty_reads = 0; +SELECT * FROM t1; +ERROR 08S01: WSREP has not yet prepared node for application use +EXECUTE stmt_select; +ERROR 08S01: WSREP has not yet prepared node for application use +SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST; +COUNT(*) > 0 +1 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/GAL-501.cnf b/mysql-test/suite/galera_3nodes/t/GAL-501.cnf new file mode 100644 index 00000000000..7002cb5bdfd --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/GAL-501.cnf @@ -0,0 +1,26 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_node_address=[::1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_node_address=[::1] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_node_address=[::1] +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' diff --git a/mysql-test/suite/galera_3nodes/t/GAL-501.test b/mysql-test/suite/galera_3nodes/t/GAL-501.test new file mode 100644 index 00000000000..60ed5989227 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/GAL-501.test @@ -0,0 +1,38 @@ +# +# Test GAL-501 Improved URI parsing for IPv6 addresses +# The .cnf file contains +# wsrep_node_address=[::1] +# ist.recv_addr=[::1] + +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Force IST + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf new file mode 100644 index 00000000000..3728e1ce005 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.cnf @@ -0,0 +1,22 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]:@mysqld.1.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]:@mysqld.2.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]:@mysqld.3.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test new file mode 100644 index 00000000000..5b06e617eef --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_mysqldump.test @@ -0,0 +1,56 @@ +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +--connection node_1 +GRANT ALL PRIVILEGES ON *.* TO 'sst'; + +--let $wsrep_sst_auth_orig = `SELECT @@wsrep_sst_auth` +SET GLOBAL wsrep_sst_auth = 'sst:'; + +--connection node_2 +--source include/wait_until_connected_again.inc +--let $wsrep_sst_method_orig = `SELECT @@wsrep_sst_method` +--let $wsrep_sst_receive_address_orig = `SELECT @@wsrep_sst_receive_address` + +--disable_query_log +--eval SET GLOBAL wsrep_sst_receive_address = '[::1]:$NODE_MYPORT_2'; +--enable_query_log +SET GLOBAL wsrep_sst_method = 'mysqldump'; + + +# +# Force mysqldump SST +# + +--connection node_2 +--source suite/galera/include/galera_unload_provider.inc +--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + + +--connection node_2 +--source suite/galera/include/galera_load_provider.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; + +--source suite/galera/include/galera_sst_restore.inc +--connection node_2 +CALL mtr.add_suppression("Unsupported protocol downgrade: incremental data collection disabled. Expect abort"); diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf new file mode 100644 index 00000000000..3728e1ce005 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.cnf @@ -0,0 +1,22 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]:@mysqld.1.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]:@mysqld.2.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]:@mysqld.3.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test new file mode 100644 index 00000000000..7ee209d8e72 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_rsync.test @@ -0,0 +1,32 @@ +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Force IST + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf new file mode 100644 index 00000000000..8a80be0d2a9 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.cnf @@ -0,0 +1,26 @@ +!include ../galera_3nodes.cnf + +[mysqld] +wsrep_sst_method=xtrabackup-v2 +wsrep_sst_auth="root:" + +[mysqld.1] +wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_host=[::1];base_port=@mysqld.1.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.1.#galera_port;ist.recv_addr=[::1]:@mysqld.1.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.1.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.1.port' + +[mysqld.2] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_host=[::1];base_port=@mysqld.2.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.2.#galera_port;ist.recv_addr=[::1]:@mysqld.2.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.2.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.2.port' + +[mysqld.3] +wsrep_cluster_address='gcomm://[::1]:@mysqld.1.#galera_port' +wsrep_provider_options='base_host=[::1];base_port=@mysqld.3.#galera_port;gmcast.listen_addr=tcp://[::]:@mysqld.3.#galera_port;ist.recv_addr=[::1]:@mysqld.3.#ist_port' +wsrep_sst_receive_address='[::1]:@mysqld.3.#sst_port' +wsrep_node_incoming_address='[::1]:@mysqld.3.port' + +[SST] +sockopt=",pf=ip6" diff --git a/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test new file mode 100644 index 00000000000..84eee017700 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_ipv6_xtrabackup-v2.test @@ -0,0 +1,62 @@ +--source include/galera_cluster.inc +--source include/have_ipv6.inc + +# Confirm that initial handshake happened over ipv6 + +SELECT VARIABLE_VALUE LIKE '%[::1]%' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_incoming_addresses'; +SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# Force IST + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +# Confirm that key messages around SST and IST reference IPv6 + +--connection node_1 +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err +--let $assert_only_after = CURRENT_TEST + +--let $assert_count = 2 +--let $assert_text = Streaming the backup to joiner at \[::1\] +--let $assert_select = Streaming the backup to joiner at \[::1\] +--source include/assert_grep.inc + +--let $assert_count = 1 +--let $assert_text = async IST sender starting to serve tcp://\[::1\]: +--let $assert_select = async IST sender starting to serve tcp://\[::1\]: +--source include/assert_grep.inc + +--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err + +--let $assert_text = IST receiver addr using tcp://\[::1\] +--let $assert_select = IST receiver addr using tcp://\[::1\] +--source include/assert_grep.inc + +--let $assert_text = Prepared IST receiver, listening at: tcp://\[::1\] +--let $assert_select = Prepared IST receiver, listening at: tcp://\[::1\] +--source include/assert_grep.inc + + + + diff --git a/mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test b/mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test new file mode 100644 index 00000000000..129ba2e1f38 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_var_dirty_reads2.test @@ -0,0 +1,112 @@ +# +# Additional tests for wsrep_dirty_reads +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER); +INSERT INTO t1 VALUES (1); + +--connection node_2 +SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; + +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +SET SESSION wsrep_dirty_reads = 1; + +# Those statements should succeed + +--error 0 +SELECT f1 FROM t1; + +--error 0 +USE test; + +--error 0 +SHOW CREATE TABLE t1; + +--error 0 +LOCK TABLE t1 WRITE; + +--error 0 +UNLOCK TABLES; + +--error 0 +FLUSH TABLES WITH READ LOCK; + +--error 0 +UNLOCK TABLES; + +--error 0 +PREPARE stmt_select FROM 'SELECT f1 FROM t1'; + +--error 0 +EXECUTE stmt_select; + +--error 0 +PREPARE stmt_update FROM 'UPDATE t1 SET f1 = f1 + f1'; + +# Mysqldump should succeed + +SET GLOBAL wsrep_dirty_reads = 1; +SET GLOBAL wsrep_sync_wait = 0; +--error 0 +--exec $MYSQL_DUMP -u root -S $NODE_MYSOCK_2 test >/dev/null +SET GLOBAL wsrep_dirty_reads = 0; +SET GLOBAL wsrep_sync_wait = 15; + +# Those statements should fail + +SET SESSION wsrep_dirty_reads = 1; + +--error ER_UNKNOWN_COM_ERROR +INSERT INTO t1 SELECT * FROM t1; + +--error ER_UNKNOWN_COM_ERROR +DELETE FROM t1; + +--error ER_UNKNOWN_COM_ERROR +UPDATE t1 SET f1 = f1 + 1; + +--error ER_UNKNOWN_COM_ERROR +DROP TABLE t1; + +--error ER_UNKNOWN_COM_ERROR +EXECUTE stmt_update; + +# With wsrep_dirty_reads = 0 , even SELECTS are not allowed + +SET SESSION wsrep_dirty_reads = 0; + +--error ER_UNKNOWN_COM_ERROR +SELECT * FROM t1; + +--error ER_UNKNOWN_COM_ERROR +EXECUTE stmt_select; + +# But reads from INFORMATION_SCHEMA are allowed + +--error 0 +SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST; + +# Restore cluster +SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/disabled.def b/mysql-test/suite/innodb/disabled.def index 16a8051bd1e..9a92e99df2e 100644 --- a/mysql-test/suite/innodb/disabled.def +++ b/mysql-test/suite/innodb/disabled.def @@ -19,3 +19,5 @@ innodb.innodb_defragment : MDEV-11336 Fix and enable innodb_defragment innodb.innodb_defragment_fill_factor : MDEV-11336 Fix and enable innodb_defragment innodb.innodb_defragment_small : MDEV-11336 Fix and enable innodb_defragment innodb.innodb_defrag_binlog : MDEV-11336 Fix and enable innodb_defragment +innodb-wl5980-alter : MDEV-9469 / MDEV-13668 extra crash in 10.2 +create-index-debug : MDEV-13680 InnoDB may crash when btr_page_alloc() fails diff --git a/mysql-test/suite/innodb/include/import.inc b/mysql-test/suite/innodb/include/import.inc new file mode 100644 index 00000000000..e8265cb3db6 --- /dev/null +++ b/mysql-test/suite/innodb/include/import.inc @@ -0,0 +1,40 @@ +# Export Table and Import from saved files .cfg and .ibd +# Caller should create t1 table definition and populate table + +let $MYSQLD_DATADIR = `SELECT @@datadir`; + +if(!$source_db) { + let $source_db = test; +} + +if(!$dest_db) { + let $dest_db = test; +} + +eval FLUSH TABLES $source_db.t1 FOR EXPORT; + +--copy_file $MYSQLD_DATADIR/$source_db/t1.cfg $MYSQLD_DATADIR/t1.cfg_back +--copy_file $MYSQLD_DATADIR/$source_db/t1.ibd $MYSQLD_DATADIR/t1.ibd_back + +UNLOCK TABLES; + +if($source_db != $dest_db) { + eval USE $dest_db; + let $create1 = query_get_value(SHOW CREATE TABLE $source_db.t1, Create Table, 1); + eval $create1; +} + +eval ALTER TABLE $dest_db.t1 DISCARD TABLESPACE; + +--move_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/$dest_db/t1.cfg +--move_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/$dest_db/t1.ibd + +eval ALTER TABLE $dest_db.t1 IMPORT TABLESPACE; + +eval CHECK TABLE $dest_db.t1; +eval SHOW CREATE TABLE $dest_db.t1; +eval SELECT * FROM $dest_db.t1; + +if($source_db != $dest_db) { + eval DROP TABLE $dest_db.t1; +} diff --git a/mysql-test/suite/innodb/include/innodb_dict.inc b/mysql-test/suite/innodb/include/innodb_dict.inc new file mode 100644 index 00000000000..1e05181272d --- /dev/null +++ b/mysql-test/suite/innodb/include/innodb_dict.inc @@ -0,0 +1,9 @@ +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; diff --git a/mysql-test/suite/innodb/r/alter_rename_existing.result b/mysql-test/suite/innodb/r/alter_rename_existing.result new file mode 100644 index 00000000000..881518595de --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_rename_existing.result @@ -0,0 +1,96 @@ +# +# Show what happens during ALTER TABLE when an existing file +# exists in the target location. +# +# Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE, +# BUT CAN ALTER ENGINE=INNODB +# +CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); +# +# Create a file called MYSQLD_DATADIR/test/t1.ibd +# Directory listing of test/*.ibd +# +t1.ibd +ALTER TABLE t1 ENGINE = InnoDB; +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists") +# +# Move the file to InnoDB as t2 +# +ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `b` char(10) DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +SELECT * from t2; +a b +1 one +2 two +3 three +ALTER TABLE t2 RENAME TO t1; +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists") +# +# Create another t1, but in the system tablespace. +# +SET GLOBAL innodb_file_per_table=OFF; +CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `b` char(20) DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +name space=0 +test/t1 1 +# +# ALTER TABLE from system tablespace to system tablespace +# +ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY; +# +# Try to move t1 from the system tablespace to a file-per-table +# while a blocking t1.ibd file exists. +# +SET GLOBAL innodb_file_per_table=ON; +ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE; +ERROR HY000: Tablespace for table 'test/t1' exists. Please DISCARD the tablespace before IMPORT +ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY; +ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists") +# +# Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd +# Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd. +# +ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `b` char(20) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + `e` int(11) DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +name space=0 +test/t1 0 +DROP TABLE t1; +# +# Rename t2.ibd to t1.ibd. +# +ALTER TABLE t2 RENAME TO t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +name space=0 +test/t1 0 +SELECT * from t1; +a b +1 one +2 two +3 three +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/create-index-debug.result b/mysql-test/suite/innodb/r/create-index-debug.result new file mode 100644 index 00000000000..99f6efe9bfe --- /dev/null +++ b/mysql-test/suite/innodb/r/create-index-debug.result @@ -0,0 +1,26 @@ +SET @saved_debug_dbug = @@SESSION.debug_dbug; +# +#BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL +# +CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3 +CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6 +CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9 +CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12 +CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15 +CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18 +CHAR(255) NOT NULL) +ENGINE=INNODB ROW_FORMAT=DYNAMIC; +Warnings: +Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. +Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT. +INSERT INTO t1 +VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET debug_dbug = '+d,disk_is_full'; +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; +ERROR HY000: The table 't1' is full +SET debug_dbug= @saved_debug_dbug; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/index_tree_operation.result b/mysql-test/suite/innodb/r/index_tree_operation.result new file mode 100644 index 00000000000..29660962e0c --- /dev/null +++ b/mysql-test/suite/innodb/r/index_tree_operation.result @@ -0,0 +1,55 @@ +# +# Bug#15923864 (Bug#67718): +# INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS +# +SET GLOBAL innodb_file_per_table=ON; +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1000, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1001, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1002, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (2, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 2 +4 3 +5 3 +INSERT INTO t1 VALUES (999, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 3 +4 3 +5 3 +6 1 +INSERT INTO t1 VALUES (998, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 3 +4 3 +5 3 +6 2 +INSERT INTO t1 VALUES (997, REPEAT('a', 4096)); +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; +page_number number_records +3 3 +4 3 +5 3 +6 3 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter-autoinc.result b/mysql-test/suite/innodb/r/innodb-alter-autoinc.result new file mode 100644 index 00000000000..a96d2f634cb --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-alter-autoinc.result @@ -0,0 +1,174 @@ +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 ADD PRIMARY KEY(a); +SET @@sql_mode = @old_sql_mode; +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED +ALTER TABLE t1 ADD id INT AUTO_INCREMENT; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id); +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); +SELECT * FROM t1; +a id +6 0 +45 0 +123 0 +347 0 +33101 0 +SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30; +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +7 70 +ROLLBACK; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); +ALTER TABLE t1 AUTO_INCREMENT = 75; +INSERT INTO t1 SET a=123; +SELECT * FROM t1; +a id +-123 -45 +6 45 +45 50 +123 55 +347 60 +33101 65 +123 70 +123 75 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +ALTER TABLE t1 ADD PRIMARY KEY(a); +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); +SELECT * FROM t1; +a id +6 0 +45 0 +123 0 +347 0 +33101 0 +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +7 70 +ROLLBACK; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, +DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; +SELECT * FROM t1; +a id +6 45 +45 50 +123 55 +347 60 +33101 65 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); +ALTER TABLE t1 AUTO_INCREMENT = 75; +INSERT INTO t1 SET a=123; +SELECT * FROM t1; +a id +-123 -45 +6 45 +45 50 +123 55 +347 60 +33101 65 +123 70 +123 75 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`,`a`) +) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result new file mode 100644 index 00000000000..aa78f55c78f --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -0,0 +1,859 @@ +SET NAMES utf8mb4; +CREATE TABLE t1 ( +c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, +INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO t1 SET c1=1; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE t1p LIKE t1; +CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), +CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), +CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT 1, + `ct` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11), + `ct` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C2 c3 INT; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c3 C INT; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +C 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 C +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 C 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +Cöŀumň_TWO 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 Cöŀumň_TWO +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; +ERROR 42S22: Unknown column 'cöĿǖmň_two' in 't1' +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t3 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL, + `c3` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t3` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ERROR 42000: Identifier name '12345678901234567890123456789012345678901234567890123456789012345' is too long +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL, + `1234567890123456789012345678901234567890123456789012345678901234` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`1234567890123456789012345678901234567890123456789012345678901234`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿å€` INT; +ERROR 42000: Identifier name '倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ ' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿Ã¤` INT; +ERROR 42000: Identifier name '倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ ' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã¤` INT; +ALTER TABLE t3 CHANGE +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã„` +c3 INT; +ALTER TABLE t3 CHANGE c3 ðŒ€ðŒðŒ‚ðŒƒðŒ„ðŒ…ðŒ†ðŒ‡ðŒˆðŒ‰ðŒŠðŒ‹ðŒŒðŒðŒŽðŒðŒðŒ‘ðŒ’ðŒ“ðŒ”ðŒ•ðŒ–ðŒ—ðŒ˜ðŒ™ðŒšðŒ›ðŒœ INT; +ERROR HY000: Invalid utf8mb4 character string: '\xF0\x90\x8C\x80\xF0\x90\x8C\x81\xF0\x90\x8C\x82\xF0\x90\x8C\x83' +ALTER TABLE t3 CHANGE c3 😲 INT; +ERROR HY000: Invalid utf8mb4 character string: '\xF0\x9F\x98\xB2' +ALTER TABLE t3 RENAME TO t2; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t2 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int(11) NOT NULL, + `c3` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +RENAME TABLE t2 TO t1; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1 DROP INDEX c4; +ERROR 42000: Can't DROP INDEX `c4`; check that it exists +ALTER TABLE t1c DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP FOREIGN KEY `c2`; check that it exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP FOREIGN KEY `c2`; check that it exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; +ERROR 42000: Can't DROP FOREIGN KEY `c2`; check that it exists +ALTER TABLE t1c DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; +ERROR 42000: Can't DROP FOREIGN KEY `ẗ1C2`; check that it exists +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) ENGINE=InnoDB; +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP INDEX C3; +ERROR HY000: Cannot drop index 'c3': needed in a foreign key constraint +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1c DROP FOREIGN KEY t1C3; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +CREATE TABLE t1o LIKE t1; +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +SHOW CREATE TABLE tt; +Table Create Table +tt CREATE TABLE `tt` ( + `pk` int(11) NOT NULL, + `c2` int(11) DEFAULT 42, + `ct` text DEFAULT NULL, + PRIMARY KEY (`pk`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'dB_row_Id' +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'DB_ROW_ID' +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +ERROR 42000: Incorrect column name 'DB_TRX_ID' +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; +ERROR 42000: Incorrect column name 'DB_ROLL_PTR' +ALTER TABLE t1o ADD COLUMN DB_TRX_ID INT; +ERROR 42000: Incorrect column name 'DB_TRX_ID' +ALTER TABLE t1o ADD COLUMN db_roll_ptr INT; +ERROR 42000: Incorrect column name 'db_roll_ptr' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT; +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID INT; +ERROR 42S21: Duplicate column name 'FTS_DOC_ID' +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, DROP INDEX ct, ALGORITHM=INPLACE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN cu TEXT; +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY +CREATE TABLE t1n LIKE t1o; +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'Fts_DOC_ID' +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ERROR 42S22: Unknown column 'FTS_DOC_ID' in 't1n' +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE FTS_DOC_ÃD c1 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c2` int(11) NOT NULL, + `ct` int(11) DEFAULT NULL, + `c1` text DEFAULT NULL, + `cu` text DEFAULT NULL, + PRIMARY KEY (`c2`), + FULLTEXT KEY `ct` (`c1`), + FULLTEXT KEY `ct_2` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + `cu` text DEFAULT NULL, + PRIMARY KEY (`c1`), + FULLTEXT KEY `ct` (`ct`), + FULLTEXT KEY `ct_2` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL, + `c4` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + `cu` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c4` (`c4`), + FULLTEXT KEY `ct` (`ct`), + FULLTEXT KEY `ct_2` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n DROP INDEX c4; +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +ERROR 42S21: Duplicate column name 'c1' +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL, + `c11` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + `cu` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c11` (`c11`), + FULLTEXT KEY `ct` (`ct`), + FULLTEXT KEY `ct_2` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1n; +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct; +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; +pos +0 +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + `cu` text DEFAULT NULL, + PRIMARY KEY (`FTS_DOC_ID`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `foo_id` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text DEFAULT NULL, + `cu` text DEFAULT NULL, + PRIMARY KEY (`foo_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +foo_id 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +cu 3 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 foo_id +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID), +ADD FULLTEXT INDEX(ct), +CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX, +CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); +call mtr.add_suppression("InnoDB: No matching column for `FTS_DOC_ID` in index `ct` of table `test`\\.`t1o`"); +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); +ERROR HY000: Index for table 't1o' is corrupt; try to repair it +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; +CREATE TABLE t (t TEXT, FULLTEXT(t)) ENGINE=InnoDB; +DROP INDEX t ON t; +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; +prefix name +FTS_0 test/FTS_AUX_BEING_DELETED +FTS_0 test/FTS_AUX_BEING_DELETED_CACHE +FTS_0 test/FTS_AUX_CONFIG +FTS_0 test/FTS_AUX_DELETED +FTS_0 test/FTS_AUX_DELETED_CACHE +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; +pos NAME +0 t +1 FTS_DOC_ID +ALTER TABLE t ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE; +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; +prefix name +ALTER TABLE t ADD FULLTEXT INDEX(t); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; +pos NAME +0 t +1 FTS_DOC_ID +DROP TABLE t; +# +# Bug #19465984 INNODB DATA DICTIONARY IS NOT UPDATED WHILE +# RENAMING THE COLUMN +# +CREATE TABLE t1(c1 INT NOT NULL, PRIMARY KEY(c1))ENGINE=INNODB; +CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c2` int(11) NOT NULL, + KEY `c2` (`c2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `C1` int(11) NOT NULL, + PRIMARY KEY (`C1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c2` int(11) NOT NULL, + KEY `c2` (`c2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `C1` int(11) NOT NULL, + PRIMARY KEY (`C1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c2` int(11) NOT NULL, + KEY `c2` (`c2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t2, t1; +# +# BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN +# DICT_MEM_TABLE_COL_RENAME_LOW +# +CREATE TABLE parent(a INT, b INT, KEY(a, b)) ENGINE = InnoDB; +CREATE TABLE t1(a1 INT, a2 INT) ENGINE = InnoDB; +set foreign_key_checks=0; +ALTER TABLE t1 ADD CONSTRAINT fk_a FOREIGN KEY(a1, a2) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE t1 CHANGE a2 a3 INT,ADD CONSTRAINT fk_1 FOREIGN KEY(a1, a3) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `fk_1` (`a1`,`a3`), + CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a3`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a3`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE a3 a4 INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) DEFAULT NULL, + `a4` int(11) DEFAULT NULL, + KEY `fk_1` (`a1`,`a4`), + CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE parent CHANGE b c INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) DEFAULT NULL, + `a4` int(11) DEFAULT NULL, + KEY `fk_1` (`a1`,`a4`), + CONSTRAINT `fk_1` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `c`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_a` FOREIGN KEY (`a1`, `a4`) REFERENCES `parent` (`a`, `c`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1, parent; +# +#BUG#21514135 SCHEMA MISMATCH ERROR WHEN IMPORTING TABLESPACE AFTER +#DROPPING AN INDEX +# +CREATE DATABASE source_db; +CREATE DATABASE dest_db; +CREATE TABLE source_db.t1 ( +id int(11) NOT NULL, +age int(11) DEFAULT NULL, +name varchar(20), +PRIMARY KEY (id), +KEY index1 (age) +) ENGINE=InnoDB; +ALTER TABLE source_db.t1 DROP INDEX index1, ADD INDEX index2(name, age), algorithm=inplace; +FLUSH TABLES source_db.t1 FOR EXPORT; +UNLOCK TABLES; +USE dest_db; +CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `index2` (`name`,`age`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +ALTER TABLE dest_db.t1 DISCARD TABLESPACE; +ALTER TABLE dest_db.t1 IMPORT TABLESPACE; +CHECK TABLE dest_db.t1; +Table Op Msg_type Msg_text +dest_db.t1 check status OK +SHOW CREATE TABLE dest_db.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `index2` (`name`,`age`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM dest_db.t1; +id age name +DROP TABLE dest_db.t1; +ALTER TABLE source_db.t1 DROP INDEX index2, algorithm=inplace; +FLUSH TABLES source_db.t1 FOR EXPORT; +UNLOCK TABLES; +USE dest_db; +CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +ALTER TABLE dest_db.t1 DISCARD TABLESPACE; +ALTER TABLE dest_db.t1 IMPORT TABLESPACE; +CHECK TABLE dest_db.t1; +Table Op Msg_type Msg_text +dest_db.t1 check status OK +SHOW CREATE TABLE dest_db.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `age` int(11) DEFAULT NULL, + `name` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM dest_db.t1; +id age name +DROP TABLE dest_db.t1; +DROP TABLE source_db.t1; +DROP DATABASE source_db; +DROP DATABASE dest_db; diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result b/mysql-test/suite/innodb/r/innodb-index-debug.result new file mode 100644 index 00000000000..09c13e37cf2 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-debug.result @@ -0,0 +1,60 @@ +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Too many active concurrent transactions +SET DEBUG_DBUG = @saved_debug_dbug; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG_DBUG = @saved_debug_dbug; +DROP TABLE bug13861218; +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG_DBUG = @saved_debug_dbug; +DROP TABLE bug13861218; +# +# Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW +# WITH LARGE INNODB_SORT_BUFFER_SIZE. +call mtr.add_suppression("InnoDB: Cannot create temporary merge file"); +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1))engine=innodb; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480; +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480; +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; +select count(*) from t1; +count(*) +2880 +drop table t1, t480; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-delete.result b/mysql-test/suite/innodb/r/innodb-index-online-delete.result new file mode 100644 index 00000000000..1c6e7c26acb --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online-delete.result @@ -0,0 +1,18 @@ +connect con1,localhost,root,,; +connection default; +CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB; +INSERT INTO t VALUES(1,2),(2,3); +SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m'; +SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done'; +CREATE INDEX tb ON t(b); +connection con1; +SET DEBUG_SYNC='now WAIT_FOR do'; +SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned'; +UPDATE t SET a=2 WHERE a=1; +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert'); +SET DEBUG_SYNC='now SIGNAL done'; +disconnect con1; +connection default; +SET DEBUG_SYNC='RESET'; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-fk.result b/mysql-test/suite/innodb/r/innodb-index-online-fk.result new file mode 100644 index 00000000000..359ce4a717c --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online-fk.result @@ -0,0 +1,608 @@ +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +INSERT INTO child VALUES(10,20); +ALTER TABLE child ADD FOREIGN KEY(a2) REFERENCES parent(b), +ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY +SET foreign_key_checks = 0; +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Duplicate FOREIGN KEY constraint name 'test/fk_1' +SET foreign_key_checks = 1; +INSERT INTO child VALUES(1,2),(2,3); +INSERT INTO child VALUES(4,4); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE) +SELECT * FROM parent; +a b +1 2 +2 3 +10 20 +20 30 +SET foreign_key_checks = 0; +ALTER TABLE child ADD CONSTRAINT fk_20 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent' +SHOW WARNINGS; +Level Code Message +Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent' +SHOW ERRORS; +Level Code Message +Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_20' in the referenced table 'parent' +CREATE INDEX idx1 on parent(a, b); +ALTER TABLE child ADD CONSTRAINT fk_10 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ALTER TABLE child ADD CONSTRAINT fk_2 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ADD INDEX idx1(a1,a2), +ALGORITHM = INPLACE; +ALTER TABLE child ADD CONSTRAINT fk_3 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +SET foreign_key_checks = 1; +INSERT INTO child VALUES(5,4); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE) +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `tb` (`a2`), + KEY `idx1` (`a1`,`a2`), + CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_10` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_2` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_3` FOREIGN KEY (`a1`, `a2`) REFERENCES `parent` (`a`, `b`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DELETE FROM parent where a = 1; +SELECT * FROM child; +a1 a2 +2 3 +10 20 +SET foreign_key_checks = 0; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_test_open_ref_fail'; +ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a1 +test/child a2 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +SYS_VIRTUAL +mysql/innodb_index_stats +mysql/innodb_table_stats +test/child +test/parent +INSERT INTO child VALUES(5,4); +SET foreign_key_checks = 1; +INSERT INTO child VALUES(6,5); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE) +SET foreign_key_checks = 0; +CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +CREATE INDEX tb ON `#parent`(a, b); +CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON `#child`(a1, a2); +SET DEBUG_DBUG = '+d,innodb_test_no_foreign_idx'; +ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child' +SET DEBUG_DBUG = @saved_debug_dbug; +SHOW ERRORS; +Level Code Message +Error 1821 Failed to add the foreign key constaint. Missing index for constraint 'fk_40' in the foreign table '#child' +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +SET DEBUG_DBUG = '+d,innodb_test_no_reference_idx'; +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent' +SET DEBUG_DBUG = @saved_debug_dbug; +SHOW ERRORS; +Level Code Message +Error 1822 Failed to add the foreign key constaint. Missing index for constraint 'fk_42' in the referenced table 'parent' +SET DEBUG_DBUG = '+d,innodb_test_wrong_fk_option'; +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_42' +SET DEBUG_DBUG = @saved_debug_dbug; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; +ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint 'test/fk_43' to system tables +SET DEBUG_DBUG = @saved_debug_dbug; +SHOW ERRORS; +Level Code Message +Error 1823 Failed to add the foreign key constraint 'test/fk_43' to system tables +DROP TABLE `#child`; +DROP TABLE `#parent`; +SET foreign_key_checks = 0; +ALTER TABLE child ADD CONSTRAINT fk_5 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ADD CONSTRAINT fk_6 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +test/fk_10 test/child test/parent 2 5 +test/fk_2 test/child test/parent 2 5 +test/fk_3 test/child test/parent 2 5 +test/fk_4 test/child test/parent 2 5 +test/fk_5 test/child test/parent 1 6 +test/fk_6 test/child test/parent 2 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +test/fk_10 a1 a 0 +test/fk_10 a2 b 1 +test/fk_2 a1 a 0 +test/fk_2 a2 b 1 +test/fk_3 a1 a 0 +test/fk_3 a2 b 1 +test/fk_4 a1 a 0 +test/fk_4 a2 b 1 +test/fk_5 a2 b 0 +test/fk_6 a1 a 0 +test/fk_6 a2 b 1 +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +INSERT INTO child VALUES(10,20); +SET foreign_key_checks = 0; +ALTER TABLE child DROP INDEX tb, ADD CONSTRAINT fk_4 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `fk_4` (`a2`), + CONSTRAINT `fk_4` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_4 test/child test/parent 1 5 +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_4 a2 b 0 +SET foreign_key_checks = 1; +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +SET foreign_key_checks = 0; +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR 42000: Key column 'a2' doesn't exist in table +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); +CREATE INDEX tb ON parent(b); +INSERT INTO parent VALUES(10,20),(20,30); +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +SET foreign_key_checks = 0; +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint 'test/fk_1' to system tables +SET DEBUG_DBUG = @saved_debug_dbug; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a1 +test/child a2 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +SYS_VIRTUAL +mysql/innodb_index_stats +mysql/innodb_table_stats +test/child +test/parent +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a2 +test/child a3 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +SYS_VIRTUAL +mysql/innodb_index_stats +mysql/innodb_table_stats +test/child +test/parent +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a3` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a3`), + KEY `tb` (`a2`), + CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a2 b 0 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a1 +test/child a2 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +SYS_VIRTUAL +mysql/innodb_index_stats +mysql/innodb_table_stats +test/child +test/parent +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `fk_1` (`a2`), + CONSTRAINT `fk_1` FOREIGN KEY (`a2`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +ALTER TABLE child CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_1 test/child test/parent 1 6 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_1 a3 b 0 +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +name name +test/child a2 +test/child a3 +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; +NAME +SYS_DATAFILES +SYS_FOREIGN +SYS_FOREIGN_COLS +SYS_TABLESPACES +SYS_VIRTUAL +mysql/innodb_index_stats +mysql/innodb_table_stats +test/child +test/parent +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a3` int(11) DEFAULT NULL, + `a2` int(11) DEFAULT NULL, + KEY `fk_1` (`a3`), + CONSTRAINT `fk_1` FOREIGN KEY (`a3`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint on table 'child'. Incorrect options in FOREIGN KEY constraint 'test/fk_1' +DROP TABLE parent; +DROP TABLE child; +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL, c INT) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2,3),(2,3,4); +CREATE INDEX tb ON parent(b); +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +ALTER TABLE child +ADD CONSTRAINT fk_a FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +ALTER TABLE child +ADD CONSTRAINT fk_b FOREIGN KEY (a1) REFERENCES parent(a), +ALGORITHM = INPLACE; +ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1_new` int(11) DEFAULT NULL, + `a2_new` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2_new`), + KEY `fk_b` (`a1_new`), + CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_a test/child test/parent 1 6 +test/fk_b test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_a a2_new b 0 +test/fk_b a1_new a 0 +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_new_3' in the referenced table 'parent' +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1_new` int(11) DEFAULT NULL, + `a2_new` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2_new`), + KEY `fk_b` (`a1_new`), + CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_a test/child test/parent 1 6 +test/fk_b test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_a a2_new b 0 +test/fk_b a1_new a 0 +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1_new` int(11) DEFAULT NULL, + `a2_new` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2_new`), + KEY `fk_new_1` (`a1_new`), + KEY `fk_new_3` (`a3`), + CONSTRAINT `fk_a` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`b`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_b` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`a`), + CONSTRAINT `fk_new_1` FOREIGN KEY (`a1_new`) REFERENCES `parent` (`b`), + CONSTRAINT `fk_new_2` FOREIGN KEY (`a2_new`) REFERENCES `parent` (`a`), + CONSTRAINT `fk_new_3` FOREIGN KEY (`a3`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_a test/child test/parent 1 6 +test/fk_b test/child test/parent 1 0 +test/fk_new_1 test/child test/parent 1 0 +test/fk_new_2 test/child test/parent 1 0 +test/fk_new_3 test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_a a2_new b 0 +test/fk_b a1_new a 0 +test/fk_new_1 a1_new b 0 +test/fk_new_2 a2_new a 0 +test/fk_new_3 a3 a 0 +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_new_3' in the referenced table 'parent' +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + KEY `tb` (`a2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; +SHOW CREATE TABLE child; +Table Create Table +child CREATE TABLE `child` ( + `a1` int(11) NOT NULL, + `a2` int(11) DEFAULT NULL, + `a3` int(11) DEFAULT NULL, + PRIMARY KEY (`a1`), + KEY `tb` (`a2`), + KEY `fk_new_3` (`a3`), + CONSTRAINT `fk_new_1` FOREIGN KEY (`a1`) REFERENCES `parent` (`b`), + CONSTRAINT `fk_new_2` FOREIGN KEY (`a2`) REFERENCES `parent` (`a`), + CONSTRAINT `fk_new_3` FOREIGN KEY (`a3`) REFERENCES `parent` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * from information_schema.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk_new_1 test/child test/parent 1 0 +test/fk_new_2 test/child test/parent 1 0 +test/fk_new_3 test/child test/parent 1 0 +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/fk_new_1 a1 b 0 +test/fk_new_2 a2 a 0 +test/fk_new_3 a3 a 0 +SET foreign_key_checks = 1; +DROP TABLE child; +DROP TABLE parent; +CREATE TABLE Parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO Parent VALUES(1,2),(2,3); +CREATE INDEX tb ON Parent(b); +INSERT INTO Parent VALUES(10,20),(20,30); +CREATE TABLE Child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; +CREATE INDEX tb ON Child(a2); +INSERT INTO Child VALUES(10,20); +SET foreign_key_checks = 0; +ALTER TABLE Child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES Parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +DROP TABLE Child; +DROP TABLE Parent; +CREATE TABLE `t2`(a int,c int,d int) ENGINE=INNODB; +CREATE TABLE `t3`(a int,c int,d int) ENGINE=INNODB; +CREATE INDEX idx ON t3(a); +ALTER TABLE `t2` ADD CONSTRAINT `fw` FOREIGN KEY (`c`) REFERENCES t3 (a); +ALTER TABLE `t2` ADD CONSTRAINT `e` foreign key (`d`) REFERENCES t3(a); +ALTER TABLE `t3` ADD CONSTRAINT `e` foreign key (`c`) REFERENCES `t2`(`c`) ON UPDATE SET NULL; +ERROR HY000: Failed to add the foreign key constraint 'test/e' to system tables +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/e test/t2 test/t3 1 0 +test/fw test/t2 test/t3 1 0 +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +ID FOR_COL_NAME REF_COL_NAME POS +test/e d a 0 +test/fw c a 0 +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/innodb/r/innodb-index-online-purge.result b/mysql-test/suite/innodb/r/innodb-index-online-purge.result new file mode 100644 index 00000000000..7a6469dd23a --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online-purge.result @@ -0,0 +1,48 @@ +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection default; +CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB; +CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB; +INSERT INTO t VALUES (1,'aa'); +BEGIN; +INSERT INTO u SET a=1, c=1; +INSERT INTO u SELECT a+1,NULL,a+1 FROM u; +INSERT INTO u SELECT a+2,NULL,a+2 FROM u; +INSERT INTO u SELECT a+4,NULL,a+4 FROM u; +INSERT INTO u SELECT a+8,NULL,a+8 FROM u; +INSERT INTO u SELECT a+16,NULL,a+16 FROM u; +INSERT INTO u SELECT a+32,NULL,a+32 FROM u; +INSERT INTO u SELECT a+64,NULL,a+64 FROM u; +INSERT INTO u SELECT a+128,NULL,a+64 FROM u; +INSERT INTO u SELECT a+256,NULL,a+64 FROM u; +COMMIT; +BEGIN; +DELETE FROM u; +connection con2; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u'; +ALTER TABLE u ADD INDEX (c); +connection default; +COMMIT; +SET DEBUG_SYNC='now WAIT_FOR created_u'; +SELECT state FROM information_schema.processlist +WHERE info='ALTER TABLE u ADD INDEX (c)'; +state +debug sync point: row_log_apply_before +connection con1; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t'; +CREATE INDEX c1 ON t (c(1)); +connection default; +SET DEBUG_SYNC='now WAIT_FOR created_t'; +UPDATE t SET c='ab'; +SELECT SLEEP(10); +SLEEP(10) +0 +SET DEBUG_SYNC='now SIGNAL dml_done_u'; +connection con2; +SET DEBUG_SYNC='now SIGNAL dml_done_t'; +disconnect con2; +connection con1; +disconnect con1; +connection default; +SET DEBUG_SYNC='RESET'; +DROP TABLE t,u; diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result new file mode 100644 index 00000000000..6ebe52bb8fc --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -0,0 +1,412 @@ +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT) +ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); +SET GLOBAL innodb_monitor_enable = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +INSERT INTO t1 VALUES(1,2,3); +connect con1,localhost,root,,; +connection con1; +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; +connection default; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection con1; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET DEBUG_DBUG = @saved_debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter'; +CREATE UNIQUE INDEX c2 ON t1(c2); +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET DEBUG_DBUG = @saved_debug_dbug; +CREATE UNIQUE INDEX c2 ON t1(c2); +DROP INDEX c2 ON t1; +connection default; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` text DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +connection con1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection default; +COMMIT; +connection con1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR 23000: Duplicate entry '4' for key 'c2' +connection default; +DELETE FROM t1 WHERE c1 = 7; +connection con1; +ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY +ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +DROP INDEX c2 ON t1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL rollback_done'; +connection con1; +ERROR 23000: Duplicate entry '4' for key 'c2' +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +INSERT INTO t1 VALUES(6,3,1); +SET DEBUG_SYNC = 'now SIGNAL dml_done'; +connection con1; +ERROR 23000: Duplicate entry for key 'c2' +DELETE FROM t1 WHERE c1=6; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection default; +INSERT INTO t1 VALUES(6,3,1); +ERROR 23000: Duplicate entry '3' for key 'c2' +INSERT INTO t1 VALUES(7,4,2); +ERROR 23000: Duplicate entry '4' for key 'c2' +ALTER TABLE t1 STATS_PERSISTENT=1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +UPDATE mysql.innodb_index_stats SET stat_value = 5 +WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY' +AND stat_value = 6; +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 +test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index +test t1 c2 LAST_UPDATE n_diff_pfx01 5 1 c2 +test t1 c2 LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 c2 LAST_UPDATE size 1 NULL Number of pages in the index +CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats +WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2'; +ALTER TABLE t1_c2_stats ENGINE=INNODB; +DROP INDEX c2 ON t1; +ANALYZE TABLE t1_c2_stats; +Table Op Msg_type Msg_text +test.t1_c2_stats analyze status OK +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 +test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index +connection con1; +KILL QUERY @id; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done'; +CREATE INDEX c2d ON t1(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c2d_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; +connection con1; +ERROR 70100: Query execution was interrupted +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection default; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 80 Using where +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +connection con1; +UPDATE t1_c2_stats SET index_name = 'c2d'; +UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01'; +INSERT INTO t1_c2_stats +SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80, +sample_size, 'c2,c1' FROM t1_c2_stats +WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2'; +INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats; +DROP TABLE t1_c2_stats; +CREATE INDEX c2d ON t1(c2); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 0 PRIMARY 1 c1 A 80 NULL NULL BTREE +t1 1 c2d 1 c2 A 10 NULL NULL YES BTREE +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c2d c2d 5 NULL 32 Using where; Using index +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2d` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; +SET lock_wait_timeout = 10; +ALTER TABLE t1 DROP INDEX c2d, ADD INDEX c2e(c2), +ALGORITHM = INPLACE; +connection default; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c2e'; +name pos +c2 0 +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; +connection con1; +ERROR HY000: Creating index 'c2e' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c2e'; +name pos +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection default; +ALTER TABLE t1 COMMENT 'testing if c2e will be dropped'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection con1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; +ALTER TABLE t1 ADD INDEX c2f(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; +connection con1; +Warnings: +Note 1831 Duplicate index `c2f`. This is deprecated and will be disallowed in a future release +ALTER TABLE t1 CHANGE c2 c22f INT; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SELECT COUNT(c22f) FROM t1; +COUNT(c22f) +320 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +ERROR 23000: Duplicate entry 'NULL' for key 'c3p5' +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done'; +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c3p5'; +name pos +c3 0 +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +INSERT INTO t1 VALUES(347,33101,NULL); +connection con1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c3p5'; +name pos +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection default; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 1 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +connection con1; +disconnect con1; +connection default; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c22f` int(11) DEFAULT NULL, + `c3` text DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2d` (`c22f`), + KEY `c2f` (`c22f`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 COMMENT='testing if c2e will be dropped' +ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; +ERROR 42000: Duplicate key name 'c2h' +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result new file mode 100644 index 00000000000..a162bcef420 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-table-online.result @@ -0,0 +1,434 @@ +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); +call mtr.add_suppression("InnoDB: Error: table 'test/t1'"); +call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for"); +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); +SET GLOBAL innodb_monitor_enable = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +INSERT INTO t1 VALUES(1,2,3); +# Establish session con1 (user=root) +connect con1,localhost,root,,; +connection con1; +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; +# session default +connection default; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +# session con1 +connection con1; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = @saved_debug_dbug; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = @saved_debug_dbug; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +# session default +connection default; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +# session con1 +connection con1; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done'; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# session default +connection default; +COMMIT; +# session con1 +connection con1; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); +ERROR 23000: Duplicate entry '4' for key 'c2' +# session default +connection default; +DELETE FROM t1 WHERE c1 = 7; +# session con1 +connection con1; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT, +LOCK = SHARED, ALGORITHM = INPLACE; +ALTER TABLE t1 ADD UNIQUE INDEX(c2), +LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +Warnings: +Note 1831 Duplicate index `c2_2`. This is deprecated and will be disallowed in a future release +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try ALGORITHM=COPY +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1); +# session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +BEGIN; +INSERT INTO t1 VALUES(4,7,2); +SET DEBUG_SYNC = 'now SIGNAL insert_done'; +# session con1 +connection con1; +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' +# session default +connection default; +ROLLBACK; +# session con1 +connection con1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE; +ERROR 42000: Can't DROP INDEX `PRIMARY`; check that it exists +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +# session default +connection default; +INSERT INTO t1 VALUES(6,3,1); +ERROR 23000: Duplicate entry '3' for key 'c2_2' +INSERT INTO t1 VALUES(7,4,2); +ERROR 23000: Duplicate entry '4' for key 'c2_2' +DROP INDEX c2_2 ON t1; +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +# session con1 +connection con1; +KILL QUERY @id; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +# session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; +# session con1 +connection con1; +ERROR 70100: Query execution was interrupted +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +# session default +connection default; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 80 Using where +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# session con1 +connection con1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) NOT NULL, + `c3` text NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done'; +SET lock_wait_timeout = 10; +ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE; +# session default +connection default; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; +# session con1 +connection con1; +ERROR HY000: Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done'; +ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +ERROR 42000: Multiple primary key defined +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +ERROR 23000: Duplicate entry '5' for key 'PRIMARY' +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)), +CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f, +ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online'; +# session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 1 +ddl_pending_alter_table 1 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; +# session con1 +connection con1; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 0 +ddl_log_file_alter_table 0 +SELECT COUNT(c22f) FROM t1; +COUNT(c22f) +320 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)); +ERROR 23000: Duplicate entry '' for key 'PRIMARY' +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); +ERROR 42000: Key column 'c22f' doesn't exist in table +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), +ALGORITHM = INPLACE; +ERROR 22004: Invalid use of NULL value +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +ERROR 22004: Invalid use of NULL value +SET @@sql_mode = @old_sql_mode; +UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f, +DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)), +ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST; +# session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0'; +BEGIN; +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2'); +INSERT INTO t1 VALUES(33101,347,NULL,''); +SET DEBUG_SYNC = 'now SIGNAL ins_done0'; +# session con1 +connection con1; +ERROR 22004: Invalid use of NULL value +SET @@sql_mode = @old_sql_mode; +# session default +connection default; +ROLLBACK; +# session con1 +connection con1; +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done'; +ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f, +ADD COLUMN c6 VARCHAR(1000) DEFAULT +'I love tracking down hard-to-reproduce bugs.', +ADD PRIMARY KEY c3p5(c3(5), c6(2)); +# session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +INSERT INTO t1 VALUES(347,33101,NULL,''); +ERROR 23000: Column 'c3' cannot be null +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti',''); +# session con1 +connection con1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; +name count +ddl_background_drop_indexes 0 +ddl_background_drop_tables 0 +ddl_online_create_index 0 +ddl_pending_alter_table 0 +ddl_sort_file_alter_table 4 +ddl_log_file_alter_table 0 +# session default +connection default; +SELECT COUNT(*) FROM t1; +COUNT(*) +321 +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SELECT * FROM t1 LIMIT 10; +c22f c1 c3 c4 +5 1 1foo Online +6 2 2foofoo Online +7 3 3foofoofoo Online +8 4 4foofoofoofoo Online +9 5 5foofoofoofoofoo Online +5 6 6foofoofoofoofoofoo Online +6 7 7foofoofoofoofoofoofoo Online +7 8 8foofoofoofoofoofoofoofoo Online +8 9 9foofoofoofoofoofoofoofoofoo Online +9 10 10foofoofoofoofoofoofoofoofoofoo Online +# session con1 +connection con1; +ALTER TABLE t1 DISCARD TABLESPACE; +# Disconnect session con1 +disconnect con1; +# session default +connection default; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c22f` int(11) NOT NULL, + `c1` int(11) NOT NULL, + `c3` text NOT NULL, + `c4` varchar(6) NOT NULL DEFAULT 'Online', + PRIMARY KEY (`c1`,`c22f`,`c4`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-wl5980-alter.result b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result new file mode 100644 index 00000000000..edd101efebb --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-wl5980-alter.result @@ -0,0 +1,1420 @@ +# +# This is a copy of innodb-alter.test except using remote tablespaces +# and showing those files. +# +SET default_storage_engine=InnoDB; +SET GLOBAL innodb_file_per_table=ON; +SET NAMES utf8mb4; +CREATE TABLE t1 ( +c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, +INDEX(c2)) +ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir'; +INSERT INTO t1 SET c1=1; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE t1p LIKE t1; +CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), +CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), +CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir'; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT '1', + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL, + `c2` int(11), + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c2 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c2 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C2 c3 INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE c3 C INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +C 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 C +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 C 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +Cöŀumň_TWO 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 Cöŀumň_TWO +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 Cöŀumň_TWO 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; +ERROR 42S22: Unknown column 'cöĿǖmň_two' in 't1' +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t3 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL, + `c3` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t3` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ERROR 42000: Identifier name '12345678901234567890123456789012345678901234567890123456789012345' is too long +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int(11) NOT NULL, + `1234567890123456789012345678901234567890123456789012345678901234` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`1234567890123456789012345678901234567890123456789012345678901234`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿å€` INT; +ERROR 42000: Identifier name '倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ ' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿Ã¤` INT; +ERROR 42000: Identifier name '倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ ' is too long +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã¤` INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +ALTER TABLE t3 CHANGE +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã„` +c3 INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t3.frm +t3.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t3.ibd +ALTER TABLE t3 CHANGE c3 ðŒ€ðŒðŒ‚ðŒƒðŒ„ðŒ…ðŒ†ðŒ‡ðŒˆðŒ‰ðŒŠðŒ‹ðŒŒðŒðŒŽðŒðŒðŒ‘ðŒ’ðŒ“ðŒ”ðŒ•ðŒ–ðŒ—ðŒ˜ðŒ™ðŒšðŒ›ðŒœ INT; +ERROR HY000: Invalid utf8 character string: '\xF0\x90\x8C\x80\xF0\x90\x8C\x81\xF0\x90\x8C\x82\xF0\x90\x8C\x83' +ALTER TABLE t3 CHANGE c3 😲 INT; +ERROR HY000: Invalid utf8 character string: '\xF0\x9F\x98\xB2' +ALTER TABLE t3 RENAME TO t2; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +t2.frm +t2.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t2.ibd +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t2 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int(11) NOT NULL, + `c3` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c2` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +RENAME TABLE t2 TO t1; +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; +NAME NAME +test/t1 test/t1 +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.ibd +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1 DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1 DROP INDEX c4; +ERROR 42000: Can't DROP 'c4'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; +ERROR 42000: Can't DROP 'c2'; check that column/key exists +ALTER TABLE t1c DROP INDEX c2; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; +ERROR 42000: Can't DROP 'ẗ1C2'; check that column/key exists +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + KEY `c3` (`c3`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) +ENGINE=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir'; +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +ERROR HY000: Cannot drop index 'c2': needed in a foreign key constraint +ALTER TABLE t1c DROP INDEX C3; +ERROR HY000: Cannot drop index 'c3': needed in a foreign key constraint +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SET foreign_key_checks=1; +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`), + CONSTRAINT `t1c3` FOREIGN KEY (`c3`) REFERENCES `t1p` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +test/t1c3 c3 c2 0 +ALTER TABLE t1c DROP FOREIGN KEY t1C3; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `c2` (`c2`), + CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `t1` (`c3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +test/t1c2 c2 c3 0 +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SHOW CREATE TABLE t1c; +Table Create Table +t1c CREATE TABLE `t1c` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `c3` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c3 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +c2 0 c3 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; +### files in MYSQL_DATA_DIR/test +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1.frm +t1.isl +t1c.frm +t1c.isl +t1p.frm +t1p.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1.ibd +t1c.ibd +t1p.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +c1 0 6 1283 4 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 c1 +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +CREATE TABLE t1o LIKE t1; +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED. +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +SHOW CREATE TABLE tt; +Table Create Table +tt CREATE TABLE `tt` ( + `pk` int(11) NOT NULL, + `c2` int(11) DEFAULT '42', + `ct` text, + PRIMARY KEY (`pk`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/' +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'dB_row_Id' +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'DB_ROW_ID' +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +ERROR 42000: Incorrect column name 'DB_TRX_ID' +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; +ERROR 42000: Incorrect column name 'DB_ROLL_PTR' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_Doc_ID' +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY. +CREATE TABLE t1n LIKE t1o; +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'Fts_DOC_ID' +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ERROR 42S22: Unknown column 'FTS_DOC_ID' in 't1n' +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE FTS_DOC_ÃD c1 INT, ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c2` int(11) NOT NULL, + `ct` int(11) DEFAULT NULL, + `c1` text, + PRIMARY KEY (`c2`), + FULLTEXT KEY `ct` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +ERROR 42000: Key column 'c2' doesn't exist in table +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL, + `c4` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c4` (`c4`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1n DROP INDEX c4; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +ERROR 42S21: Duplicate column name 'c1' +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY. +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1n.frm +t1n.ibd +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1n; +Table Create Table +t1n CREATE TABLE `t1n` ( + `c1` int(11) NOT NULL, + `c11` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`c1`), + KEY `c11` (`c11`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1n; +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o"); +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ERROR HY000: Incorrect key file for table 't1o'; try to repair it +# The following would crash 10.2. Re-enable this and test after merge! +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; +pos +0 +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`FTS_DOC_ID`), + FULLTEXT KEY `ct` (`ct`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, LOCK=NONE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1c.frm +t1c.isl +t1o.frm +t1o.ibd +t1p.frm +t1p.isl +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +t1c.ibd +t1p.ibd +tt.ibd +SHOW CREATE TABLE t1o; +Table Create Table +t1o CREATE TABLE `t1o` ( + `foo_id` bigint(20) unsigned NOT NULL, + `c2` int(11) DEFAULT NULL, + `ct` text, + PRIMARY KEY (`foo_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +foo_id 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 foo_id +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1o.frm +t1o.ibd +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +tt.ibd +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); +ERROR HY000: Incorrect key file for table 't1o'; try to repair it +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +### files in MYSQL_DATA_DIR/test +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +FTS_AUX_INDEX_1.ibd +FTS_AUX_INDEX_2.ibd +FTS_AUX_INDEX_3.ibd +FTS_AUX_INDEX_4.ibd +FTS_AUX_INDEX_5.ibd +FTS_AUX_INDEX_6.ibd +FTS_AUX_BEING_DELETED.ibd +FTS_AUX_BEING_DELETED_CACHE.ibd +FTS_AUX_CONFIG.ibd +FTS_AUX_DELETED.ibd +FTS_AUX_DELETED_CACHE.ibd +sys_foreign.frm +sys_foreign.ibd +sys_indexes.frm +sys_indexes.ibd +sys_tables.frm +sys_tables.ibd +t1o.frm +t1o.ibd +tt.frm +tt.isl +### files in MYSQL_TMP_DIR/alt_dir/test +tt.ibd +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN +FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +NAME POS MTYPE PRTYPE LEN +FTS_DOC_ID 0 6 1800 8 +c2 1 6 1027 4 +ct 2 5 524540 10 +SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i +INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID; +NAME POS NAME +PRIMARY 0 FTS_DOC_ID +FTS_DOC_ID_INDEX 0 FTS_DOC_ID +ct 0 ct +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; +ID FOR_COL_NAME REF_COL_NAME POS +# +# Cleanup +# +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; +### files in MYSQL_DATA_DIR/test +### files in MYSQL_TMP_DIR/alt_dir/test diff --git a/mysql-test/suite/innodb/t/alter_rename_existing.test b/mysql-test/suite/innodb/t/alter_rename_existing.test new file mode 100644 index 00000000000..0c8bf481969 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_rename_existing.test @@ -0,0 +1,93 @@ +--echo # +--echo # Show what happens during ALTER TABLE when an existing file +--echo # exists in the target location. +--echo # +--echo # Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE, +--echo # BUT CAN ALTER ENGINE=INNODB +--echo # + +--source include/have_innodb.inc + +--disable_query_log +LET $MYSQLD_DATADIR = `select @@datadir`; +SET @old_innodb_file_per_table = @@innodb_file_per_table; +--enable_query_log + +CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); + +--echo # +--echo # Create a file called MYSQLD_DATADIR/test/t1.ibd +--exec echo "This is not t1.ibd" > $MYSQLD_DATADIR/test/t1.ibd + +--echo # Directory listing of test/*.ibd +--echo # +--list_files $MYSQLD_DATADIR/test/ *.ibd + +--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/ +--error ER_ERROR_ON_RENAME +ALTER TABLE t1 ENGINE = InnoDB; + +--echo # +--echo # Move the file to InnoDB as t2 +--echo # +ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB; +SHOW CREATE TABLE t2; +SELECT * from t2; + +--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/ +--error ER_ERROR_ON_RENAME +ALTER TABLE t2 RENAME TO t1; + +--echo # +--echo # Create another t1, but in the system tablespace. +--echo # +SET GLOBAL innodb_file_per_table=OFF; +CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB; +INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); +SHOW CREATE TABLE t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; + +--echo # +--echo # ALTER TABLE from system tablespace to system tablespace +--echo # +ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY; + +--echo # +--echo # Try to move t1 from the system tablespace to a file-per-table +--echo # while a blocking t1.ibd file exists. +--echo # +SET GLOBAL innodb_file_per_table=ON; +--replace_regex /$MYSQLD_DATADIR/MYSQLD_DATADIR/ +--error ER_TABLESPACE_EXISTS +ALTER TABLE t1 ADD COLUMN e1 INT, ALGORITHM=INPLACE; +--replace_regex /Error on rename of '.*' to '.*'/Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME'/ +--error ER_ERROR_ON_RENAME +ALTER TABLE t1 ADD COLUMN e2 INT, ALGORITHM=COPY; + +--echo # +--echo # Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd +--remove_file $MYSQLD_DATADIR/test/t1.ibd + +--echo # Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd. +--echo # +ALTER TABLE t1 ADD COLUMN e INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; + +DROP TABLE t1; + +--echo # +--echo # Rename t2.ibd to t1.ibd. +--echo # +ALTER TABLE t2 RENAME TO t1; +SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1'; +SELECT * from t1; + +DROP TABLE t1; + +--disable_query_log +call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot rename '.*' to '.*' for space ID .* because the target file exists. Remove the target file and try again"); +SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/create-index-debug.test b/mysql-test/suite/innodb/t/create-index-debug.test new file mode 100644 index 00000000000..9ea416fbe1e --- /dev/null +++ b/mysql-test/suite/innodb/t/create-index-debug.test @@ -0,0 +1,34 @@ +--source include/have_innodb.inc +--source include/have_innodb_16k.inc +--source include/have_debug.inc + +SET @saved_debug_dbug = @@SESSION.debug_dbug; + +--echo # +--echo #BUG#21326304 INNODB ONLINE ALTER TABLE ENDS IN CRASH ON DISK FULL +--echo # +CREATE TABLE t1(f1 CHAR(255) NOT NULL, f2 CHAR(255) NOT NULL, f3 +CHAR(255) NOT NULL, f4 CHAR(255) NOT NULL, f5 CHAR(255) NOT NULL,f6 +CHAR(255) NOT NULL, f7 CHAR(255) NOT NULL, f8 CHAR(255) NOT NULL,f9 +CHAR(255) NOT NULL, f10 CHAR(255) NOT NULL, f11 CHAR(255) NOT NULL,f12 +CHAR(255) NOT NULL, f13 CHAR(255) NOT NULL, f14 CHAR(255) NOT NULL,f15 +CHAR(255) NOT NULL, f16 CHAR(255) NOT NULL, f17 CHAR(255) NOT NULL,f18 +CHAR(255) NOT NULL) +ENGINE=INNODB ROW_FORMAT=DYNAMIC; + +INSERT INTO t1 +VALUES('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r'); + +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; + +SET debug_dbug = '+d,disk_is_full'; + +--error ER_RECORD_FILE_FULL +ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; + +SET debug_dbug= @saved_debug_dbug; + +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/index_tree_operation.opt b/mysql-test/suite/innodb/t/index_tree_operation.opt new file mode 100644 index 00000000000..66bceccc683 --- /dev/null +++ b/mysql-test/suite/innodb/t/index_tree_operation.opt @@ -0,0 +1 @@ +--innodb-sys-tablespaces diff --git a/mysql-test/suite/innodb/t/index_tree_operation.test b/mysql-test/suite/innodb/t/index_tree_operation.test new file mode 100644 index 00000000000..b9695db9346 --- /dev/null +++ b/mysql-test/suite/innodb/t/index_tree_operation.test @@ -0,0 +1,74 @@ +-- source include/have_innodb.inc +-- source include/have_innodb_16k.inc +--echo # +--echo # Bug#15923864 (Bug#67718): +--echo # INNODB DRASTICALLY UNDER-FILLS PAGES IN CERTAIN CONDITIONS +--echo # +# InnoDB should try to insert to the next page before split, +# if the insert record for split_and_insert is last of the page. +# Otherwise, the follwing records 999,998,997 cause each page per record. +# + +--disable_query_log +SET @old_innodb_file_per_table = @@innodb_file_per_table; +--enable_query_log + +SET GLOBAL innodb_file_per_table=ON; + +CREATE TABLE t1 (a BIGINT PRIMARY KEY, b VARCHAR(4096)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1000, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1001, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1002, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (1, REPEAT('a', 4096)); +INSERT INTO t1 VALUES (2, REPEAT('a', 4096)); + +# | 0, 1, 2 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + +INSERT INTO t1 VALUES (999, REPEAT('a', 4096)); + +# try to insert '999' to the end of '0,1,2' page, but no space +# the next '1000,1001,1002' page has also no space. +# | 0, 1, 2 | 999 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + + +INSERT INTO t1 VALUES (998, REPEAT('a', 4096)); + +# try to insert to the end of '0,1,2' page, but no space +# the next '998' page has space. +# | 0, 1, 2 | 998, 999 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + +INSERT INTO t1 VALUES (997, REPEAT('a', 4096)); + +# same +# | 0, 1, 2 | 997, 998, 999 | 1000, 1001, 1002| + +SELECT page_number, number_records +FROM information_schema.innodb_sys_tablespaces s1, +information_schema.innodb_buffer_page s2 +WHERE s1.space = s2.space AND name = 'test/t1' +AND page_type = "INDEX" ORDER BY page_number; + +DROP TABLE t1; + +--disable_query_log +SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb-alter-autoinc.test b/mysql-test/suite/innodb/t/innodb-alter-autoinc.test new file mode 100644 index 00000000000..e01c44aa26e --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter-autoinc.test @@ -0,0 +1,104 @@ +--source include/have_innodb.inc + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t1 ADD PRIMARY KEY(a); +SET @@sql_mode = @old_sql_mode; + +# We cannot assign AUTO_INCREMENT values during online index creation. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + LOCK=NONE; + +--error ER_WRONG_AUTO_KEY +ALTER TABLE t1 ADD id INT AUTO_INCREMENT; + +--error ER_WRONG_AUTO_KEY +ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id); + +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); + +SELECT * FROM t1; + +# Test with a non-default increment and offset +SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; + +SHOW CREATE TABLE t1; + +# The autoinc next value should increase. It is not rolled back. +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +ROLLBACK; + +SHOW CREATE TABLE t1; + +# We cannot assign AUTO_INCREMENT values during online index creation. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; + +SELECT * FROM t1; +SHOW CREATE TABLE t1; + +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); + +ALTER TABLE t1 AUTO_INCREMENT = 75; + +INSERT INTO t1 SET a=123; +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +DROP TABLE t1; + +# ALGORITHM=INPLACE should deliver identical results to ALGORITHM=COPY. +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(347),(33101),(123),(45),(6); +ALTER TABLE t1 ADD PRIMARY KEY(a); + +ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a); + +SELECT * FROM t1; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1; + +# The autoinc next value should increase. It is not rolled back. +BEGIN; +INSERT INTO t1 VALUES(7,0); +SELECT * FROM t1; +ROLLBACK; + +SHOW CREATE TABLE t1; + +ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY, + DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY; + +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +INSERT INTO t1 SET a=123; +INSERT INTO t1 VALUES(-123,-45); + +ALTER TABLE t1 AUTO_INCREMENT = 75; + +INSERT INTO t1 SET a=123; +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-alter.opt b/mysql-test/suite/innodb/t/innodb-alter.opt new file mode 100644 index 00000000000..aa400236153 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter.opt @@ -0,0 +1,3 @@ +--loose-innodb-sys-indexes +--loose-innodb-sys-columns +--loose-innodb-sys-fields diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test new file mode 100644 index 00000000000..5e681f96b4a --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -0,0 +1,499 @@ +--source include/have_innodb.inc + +SET NAMES utf8mb4; + +CREATE TABLE t1 ( + c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, + INDEX(c2)) +ENGINE=InnoDB; + +INSERT INTO t1 SET c1=1; + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +CREATE TABLE t1p LIKE t1; + +CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), + CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), + CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB; + +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +SHOW CREATE TABLE t1; +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +SHOW CREATE TABLE t1; + +-- source suite/innodb/include/innodb_dict.inc + +# These should be no-op. +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C2 c3 INT; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE c3 C INT; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +-- error ER_BAD_FIELD_ERROR +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; + +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +SHOW CREATE TABLE t3; +SHOW CREATE TABLE t1c; + +# The maximum column name length should be 64 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; +SHOW CREATE TABLE t3; + +# Test the length limit with non-ASCII utf-8 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿å€` INT; +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿Ã¤` INT; +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã¤` INT; + +# check that the rename is case-insensitive (note the upper-case ä at end) +ALTER TABLE t3 CHANGE +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã„` +c3 INT; + +# test with 4-byte UTF-8 (should be disallowed) +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 ðŒ€ðŒðŒ‚ðŒƒðŒ„ðŒ…ðŒ†ðŒ‡ðŒˆðŒ‰ðŒŠðŒ‹ðŒŒðŒðŒŽðŒðŒðŒ‘ðŒ’ðŒ“ðŒ”ðŒ•ðŒ–ðŒ—ðŒ˜ðŒ™ðŒšðŒ›ðŒœ INT; +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 😲 INT; + +ALTER TABLE t3 RENAME TO t2; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +SHOW CREATE TABLE t2; + +RENAME TABLE t2 TO t1; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +-- source suite/innodb/include/innodb_dict.inc + +--error ER_DROP_INDEX_FK +ALTER TABLE t1 DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP INDEX c4; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; + +SHOW CREATE TABLE t1c; + +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; + +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) ENGINE=InnoDB; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C3; + +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; +SET foreign_key_checks=1; + +SHOW CREATE TABLE t1c; +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP FOREIGN KEY t1C3; + +SHOW CREATE TABLE t1c; +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; + +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; + +-- source suite/innodb/include/innodb_dict.inc + +CREATE TABLE t1o LIKE t1; + +# This will implicitly add a FTS_DOC_ID column, which cannot be done online. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; + +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; + +# The output should be empty, because index->id was reassigned. +-- source suite/innodb/include/innodb_dict.inc + +SHOW CREATE TABLE tt; + +# DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR are reserved InnoDB system column names. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD COLUMN DB_TRX_ID INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD COLUMN db_roll_ptr INT; + +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT; +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; + +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; + +--error ER_DUP_FIELDNAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN FTS_DOC_ID INT; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; + +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, DROP INDEX ct, ALGORITHM=INPLACE; + +# This creates a hidden FTS_DOC_ID column. +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ADD COLUMN cu TEXT; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED; + +# This would drop the hidden FTS_DOC_ID column and create +# a fulltext index on ct and another fulltext index on cu. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(cu), +ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +# Replace the hidden FTS_DOC_ID column with a user-visible one. +# This used to work if there is at most one fulltext index. +# Currently, we disallow native ALTER TABLE if the table +# contains any FULLTEXT indexes. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; +ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL; +# Replace the user-visible FTS_DOC_ID column with a hidden one. +# We do not support this in-place. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE; +ALTER TABLE t1o DROP COLUMN FTS_DOC_ID; + +# FTS_DOC_ID is the internal row identifier for full-text search. +# It should be of type BIGINT UNSIGNED NOT NULL. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +CREATE TABLE t1n LIKE t1o; + +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; + +ALTER TABLE t1n CHANGE FTS_DOC_ÃD c1 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; +SHOW CREATE TABLE t1n; +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; +SHOW CREATE TABLE t1n; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; +# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table +# when renaming a column and adding index +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; +SHOW CREATE TABLE t1n; +ALTER TABLE t1n DROP INDEX c4; +--error ER_DUP_FIELDNAME +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +# FIXME: MDEV-13668 +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; + +SHOW CREATE TABLE t1n; +DROP TABLE t1n; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct, +ALGORITHM=INPLACE; + +# This will copy the table, removing the hidden FTS_DOC_ID column. +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL, DROP INDEX ct; + +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +# This should not show duplicates. +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; + +SHOW CREATE TABLE t1o; + +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1o; + +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; + +# Check the internal schemata of tt, t1o. + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; + +-- source suite/innodb/include/innodb_dict.inc + +# Ensure that there exists no hidden FTS_DOC_ID_INDEX on foo_id. + +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID), +ADD FULLTEXT INDEX(ct), +CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL; + +ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX, +CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; + +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); + +# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE +call mtr.add_suppression("InnoDB: No matching column for `FTS_DOC_ID` in index `ct` of table `test`\\.`t1o`"); +--error ER_NOT_KEYFILE +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); +# FIXME: MDEV-9469 (enable this) +#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +#ALGORITHM=INPLACE; +#end of MDEV-9469 FIXME + +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +-- source suite/innodb/include/innodb_dict.inc + +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; + +CREATE TABLE t (t TEXT, FULLTEXT(t)) ENGINE=InnoDB; +DROP INDEX t ON t; + +LET $regexp=/FTS_([0-9a-f_]+)([A-Z_]+)/FTS_AUX_\2/; +--replace_regex $regexp +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; + +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; + +ALTER TABLE t ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE; + +--replace_regex $regexp +SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name +FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE name LIKE '%FTS_%' ORDER BY 1, 2; + +ALTER TABLE t ADD FULLTEXT INDEX(t); + +SELECT sc.pos, sc.NAME FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t'; + +DROP TABLE t; + +--disable_query_log +call mtr.add_suppression("deleting orphaned .ibd file"); +--enable_query_log + +--echo # +--echo # Bug #19465984 INNODB DATA DICTIONARY IS NOT UPDATED WHILE +--echo # RENAMING THE COLUMN +--echo # +CREATE TABLE t1(c1 INT NOT NULL, PRIMARY KEY(c1))ENGINE=INNODB; +CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +# FIXME: MDEV-13671 InnoDB should use case-insensitive column name comparisons +# like the rest of the server +#ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +DROP TABLE t2, t1; + +--echo # +--echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN +--echo # DICT_MEM_TABLE_COL_RENAME_LOW +--echo # +CREATE TABLE parent(a INT, b INT, KEY(a, b)) ENGINE = InnoDB; +CREATE TABLE t1(a1 INT, a2 INT) ENGINE = InnoDB; + +set foreign_key_checks=0; +ALTER TABLE t1 ADD CONSTRAINT fk_a FOREIGN KEY(a1, a2) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; + +ALTER TABLE t1 CHANGE a2 a3 INT,ADD CONSTRAINT fk_1 FOREIGN KEY(a1, a3) REFERENCES parent(a, b) ON DELETE SET NULL ON UPDATE CASCADE; +SHOW CREATE TABLE t1; +CHECK TABLE t1; + +ALTER TABLE t1 CHANGE a3 a4 INT; +SHOW CREATE TABLE t1; +CHECK TABLE t1; + +ALTER TABLE parent CHANGE b c INT; +SHOW CREATE TABLE t1; +CHECK TABLE t1; + +DROP TABLE t1, parent; + +--echo # +--echo #BUG#21514135 SCHEMA MISMATCH ERROR WHEN IMPORTING TABLESPACE AFTER +--echo #DROPPING AN INDEX +--echo # +let $source_db = source_db; +let $dest_db = dest_db; + +eval CREATE DATABASE $source_db; +eval CREATE DATABASE $dest_db; + +eval CREATE TABLE $source_db.t1 ( + id int(11) NOT NULL, + age int(11) DEFAULT NULL, + name varchar(20), + PRIMARY KEY (id), + KEY index1 (age) + ) ENGINE=InnoDB; + +eval ALTER TABLE $source_db.t1 DROP INDEX index1, ADD INDEX index2(name, age), algorithm=inplace; + +--source suite/innodb/include/import.inc + +eval ALTER TABLE $source_db.t1 DROP INDEX index2, algorithm=inplace; + +--source suite/innodb/include/import.inc + +eval DROP TABLE $source_db.t1; +eval DROP DATABASE $source_db; +eval DROP DATABASE $dest_db; + + + diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.opt b/mysql-test/suite/innodb/t/innodb-index-debug.opt new file mode 100644 index 00000000000..778b4443d4f --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-debug.opt @@ -0,0 +1 @@ +--innodb-sort-buffer-size=64k diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.test b/mysql-test/suite/innodb/t/innodb-index-debug.test new file mode 100644 index 00000000000..d4da0c14246 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-debug.test @@ -0,0 +1,70 @@ +-- source include/have_debug.inc +-- source include/have_innodb.inc + +let $MYSQLD_DATADIR= `select @@datadir`; + +# +# Test for BUG# 12739098, check whether trx->error_status is reset on error. +# +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); + +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +--error ER_TOO_MANY_CONCURRENT_TRXS +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_DBUG = @saved_debug_dbug; + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +# Test for Bug#13861218 Records are not fully sorted during index creation +# +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; +# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2). +# No crash here, because n_uniq for c2 includes the clustered index fields +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG_DBUG = @saved_debug_dbug; +DROP TABLE bug13861218; + +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); +SET DEBUG_DBUG = '+d,ib_row_merge_buf_add_two'; +# Force creation of a PRIMARY KEY on c1 to see what happens on the index(c2). +# assertion failure: ut_ad(cmp_dtuple_rec(dtuple, rec, rec_offsets) > 0) +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG_DBUG = @saved_debug_dbug; +DROP TABLE bug13861218; + +--echo # +--echo # Bug #21762319 ADDING INDEXES ON EMPTY TABLE IS SLOW +--echo # WITH LARGE INNODB_SORT_BUFFER_SIZE. + +call mtr.add_suppression("InnoDB: Cannot create temporary merge file"); + +# Table with large data which is greater than sort buffer + +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, + f2 char(200) not null, f3 char(200) not null, + f4 char(200) not null,primary key(f1))engine=innodb; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480; +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480; +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; +select count(*) from t1; +drop table t1, t480; diff --git a/mysql-test/suite/innodb/t/innodb-index-online-delete.test b/mysql-test/suite/innodb/t/innodb-index-online-delete.test new file mode 100644 index 00000000000..ec5f93731ed --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-delete.test @@ -0,0 +1,36 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +connect (con1,localhost,root,,); + +connection default; + +CREATE TABLE t (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB; +INSERT INTO t VALUES(1,2),(2,3); + +SET DEBUG_SYNC='alter_table_inplace_after_lock_downgrade SIGNAL do WAIT_FOR m'; +SET DEBUG_SYNC='innodb_after_inplace_alter_table SIGNAL scanned WAIT_FOR done'; +--send +CREATE INDEX tb ON t(b); + +connection con1; +SET DEBUG_SYNC='now WAIT_FOR do'; +SET DEBUG_SYNC='row_update_for_mysql_error SIGNAL m WAIT_FOR scanned'; +--error ER_DUP_ENTRY +UPDATE t SET a=2 WHERE a=1; +call mtr.add_suppression('InnoDB: record in index .*tb was not found on rollback, trying to insert'); +SET DEBUG_SYNC='now SIGNAL done'; + +disconnect con1; + +connection default; +reap; +SET DEBUG_SYNC='RESET'; +DROP TABLE t; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/innodb-index-online-fk.opt b/mysql-test/suite/innodb/t/innodb-index-online-fk.opt new file mode 100644 index 00000000000..345d5529dce --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-fk.opt @@ -0,0 +1,4 @@ +--loose-innodb-sys-tables +--loose-innodb-sys-columns +--loose-innodb-sys-foreign +--loose-innodb-sys-foreign-cols diff --git a/mysql-test/suite/innodb/t/innodb-index-online-fk.test b/mysql-test/suite/innodb/t/innodb-index-online-fk.test new file mode 100644 index 00000000000..5c8954064ce --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-fk.test @@ -0,0 +1,484 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +INSERT INTO child VALUES(10,20); + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE child ADD FOREIGN KEY(a2) REFERENCES parent(b), +ALGORITHM = INPLACE; + +SET foreign_key_checks = 0; + +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +# duplicated foreign key name +--error ER_DUP_CONSTRAINT_NAME +ALTER TABLE child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SET foreign_key_checks = 1; + +INSERT INTO child VALUES(1,2),(2,3); + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child VALUES(4,4); + +SELECT * FROM parent; + +SET foreign_key_checks = 0; + +# This would fail. No corresponding index +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE child ADD CONSTRAINT fk_20 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SHOW WARNINGS; + +SHOW ERRORS; + +CREATE INDEX idx1 on parent(a, b); + +ALTER TABLE child ADD CONSTRAINT fk_10 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +# This should be successful, as we added the index +ALTER TABLE child ADD CONSTRAINT fk_2 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, ADD INDEX idx1(a1,a2), +ALGORITHM = INPLACE; + +ALTER TABLE child ADD CONSTRAINT fk_3 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +SET foreign_key_checks = 1; + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child VALUES(5,4); + +SHOW CREATE TABLE child; + +DELETE FROM parent where a = 1; + +SELECT * FROM child; + +# Now test referenced table cannot be opened. This should work fine +# when foreign_key_checks is set to 0 + +SET foreign_key_checks = 0; + +# This is to test the scenario we cannot open the referenced table. +# Since foreign_key_checks is set to 0, the foreign key should still +# be added. +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_test_open_ref_fail'; +ALTER TABLE child ADD CONSTRAINT fk_4 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; + +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +# this should succeed, since we disabled the foreign key check +INSERT INTO child VALUES(5,4); + +SET foreign_key_checks = 1; + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child VALUES(6,5); + +SET foreign_key_checks = 0; + +# Create some table with 'funny' characters, for testing the +# error message +CREATE TABLE `#parent` (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; + +CREATE INDEX tb ON `#parent`(a, b); + +CREATE TABLE `#child` (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON `#child`(a1, a2); + +# This is to test the scenario no foreign index, alter table should fail +SET DEBUG_DBUG = '+d,innodb_test_no_foreign_idx'; +--error ER_FK_NO_INDEX_CHILD, +ALTER TABLE `#child` ADD CONSTRAINT fk_40 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; + +SHOW ERRORS; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +# This is to test the scenario no index on referenced table, +# alter table should fail +SET DEBUG_DBUG = '+d,innodb_test_no_reference_idx'; +--error ER_FK_NO_INDEX_PARENT, +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; + +SHOW ERRORS; + +# This is to test the scenario no index on referenced table, +# alter table should fail +SET DEBUG_DBUG = '+d,innodb_test_wrong_fk_option'; +--error ER_FK_INCORRECT_OPTION +ALTER TABLE child ADD CONSTRAINT fk_42 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +# This is to test the scenario cannot add fk to the system table, +# alter table should fail +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE `#child` ADD CONSTRAINT fk_43 FOREIGN KEY (a1, a2) +REFERENCES `#parent`(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; + +SHOW ERRORS; + +DROP TABLE `#child`; +DROP TABLE `#parent`; + +# Now test add multiple foreign key constrain in a single clause +SET foreign_key_checks = 0; + +ALTER TABLE child ADD CONSTRAINT fk_5 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ADD CONSTRAINT fk_6 FOREIGN KEY (a1, a2) +REFERENCES parent(a, b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +DROP TABLE child; +DROP TABLE parent; + +# Test a case where child's foreign key index is being dropped in the +# same clause of adding the foreign key. In theory, MySQL will +# automatically create a new index to meet the index requirement +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; + +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +INSERT INTO child VALUES(10,20); + +SET foreign_key_checks = 0; + +ALTER TABLE child DROP INDEX tb, ADD CONSTRAINT fk_4 FOREIGN KEY (a2) +REFERENCES parent(b) ON DELETE CASCADE ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SHOW CREATE TABLE child; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN; + +SELECT * FROM information_schema.INNODB_SYS_FOREIGN_COLS; + +SET foreign_key_checks = 1; + +DROP TABLE child; + +DROP TABLE parent; + +# Test ADD FOREIGN KEY together with renaming columns. +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; + +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +SET foreign_key_checks = 0; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +ALTER TABLE child CHANGE a2 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +DROP TABLE child; + +DROP TABLE parent; + +# Add test for add Primary key and FK on changing columns +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON parent(b); + +INSERT INTO parent VALUES(10,20),(20,30); + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON child(a2); + +SET foreign_key_checks = 0; + +# Let's rebuild the table and add the FK, make the add FK failed. + +SET DEBUG_DBUG = '+d,innodb_test_cannot_add_fk_system'; +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; +SET DEBUG_DBUG = @saved_debug_dbug; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +# This should be successful. It will also check any left over +# from previous failed operation (if dictionary entries not cleaned, +# it will have dup key error. +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +SHOW CREATE TABLE child; + +DROP TABLE child; + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; + +# Now try primary index and FK +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_1 FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +SHOW CREATE TABLE child; + +DROP TABLE child; + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; + +ALTER TABLE child CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; +SELECT t2.name, t1.name FROM information_schema.innodb_sys_columns t1, information_schema.innodb_sys_tables t2 WHERE t1.table_id = t2.table_id AND t2.name LIKE "%child" ORDER BY t1.name; +SELECT NAME FROM information_schema.INNODB_SYS_TABLES; + +SHOW CREATE TABLE child; + +DROP TABLE child; + +CREATE TABLE child (a1 INT NOT NULL, a2 INT) ENGINE = InnoDB; +# Now try all three +--error ER_FK_INCORRECT_OPTION +ALTER TABLE child ADD PRIMARY KEY idx (a3), CHANGE a1 a3 INT, +ADD CONSTRAINT fk_1 FOREIGN KEY (a3) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +DROP TABLE parent; +DROP TABLE child; + +CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL, c INT) ENGINE = InnoDB; +INSERT INTO parent VALUES(1,2,3),(2,3,4); + +CREATE INDEX tb ON parent(b); + +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); + +ALTER TABLE child +ADD CONSTRAINT fk_a FOREIGN KEY (a2) REFERENCES parent(b) +ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +ALTER TABLE child +ADD CONSTRAINT fk_b FOREIGN KEY (a1) REFERENCES parent(a), +ALGORITHM = INPLACE; + +ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT; + +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +# The third add FK will fail +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; + +# It should still have only 2 FKs +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +#Now let's make it successful +ALTER TABLE child +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1_new) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2_new) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; + +# It should still have 5 FKs +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +DROP TABLE child; +CREATE TABLE child (a1 INT NOT NULL, a2 INT, a3 INT) ENGINE = InnoDB; +CREATE INDEX tb ON child(a2); + +# Let's try this 3rd fk failure with add primary index +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(c), +ALGORITHM = INPLACE; + +# It should still have no FKs, no PRIMARY +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +# make it successful +ALTER TABLE child ADD PRIMARY KEY idx (a1), +ADD CONSTRAINT fk_new_1 FOREIGN KEY (a1) REFERENCES parent(b), +ADD CONSTRAINT fk_new_2 FOREIGN KEY (a2) REFERENCES parent(a), +ADD CONSTRAINT fk_new_3 FOREIGN KEY (a3) REFERENCES parent(a), +ALGORITHM = INPLACE; + +# It should have 3 FKs, a new PRIMARY +SHOW CREATE TABLE child; + +SELECT * from information_schema.INNODB_SYS_FOREIGN; + +SELECT * from information_schema.INNODB_SYS_FOREIGN_COLS; + +SET foreign_key_checks = 1; + +DROP TABLE child; +DROP TABLE parent; + +CREATE TABLE Parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; +INSERT INTO Parent VALUES(1,2),(2,3); + +CREATE INDEX tb ON Parent(b); + +INSERT INTO Parent VALUES(10,20),(20,30); + +CREATE TABLE Child (a1 INT PRIMARY KEY, a2 INT) ENGINE = InnoDB; + +CREATE INDEX tb ON Child(a2); + +INSERT INTO Child VALUES(10,20); + +SET foreign_key_checks = 0; + +ALTER TABLE Child ADD CONSTRAINT fk_1 FOREIGN KEY (a2) +REFERENCES Parent(b) ON DELETE SET NULL ON UPDATE CASCADE, +ALGORITHM = INPLACE; + +DROP TABLE Child; +DROP TABLE Parent; + +# This is the test for bug 14594526 - FK: ASSERTION IN +# DICT_TABLE_CHECK_FOR_DUP_INDEXES +CREATE TABLE `t2`(a int,c int,d int) ENGINE=INNODB; +CREATE TABLE `t3`(a int,c int,d int) ENGINE=INNODB; +CREATE INDEX idx ON t3(a); + +ALTER TABLE `t2` ADD CONSTRAINT `fw` FOREIGN KEY (`c`) REFERENCES t3 (a); + +ALTER TABLE `t2` ADD CONSTRAINT `e` foreign key (`d`) REFERENCES t3(a); + +--error ER_FK_FAIL_ADD_SYSTEM +ALTER TABLE `t3` ADD CONSTRAINT `e` foreign key (`c`) REFERENCES `t2`(`c`) ON UPDATE SET NULL; + +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; + +DROP TABLE t2; + +DROP TABLE t3; diff --git a/mysql-test/suite/innodb/t/innodb-index-online-purge.test b/mysql-test/suite/innodb/t/innodb-index-online-purge.test new file mode 100644 index 00000000000..28ff9403c0c --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online-purge.test @@ -0,0 +1,73 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +connect (con1,localhost,root,,); + +connect (con2,localhost,root,,); +connection default; + +CREATE TABLE t (a INT PRIMARY KEY, c TEXT) ENGINE=InnoDB; +CREATE TABLE u (a INT PRIMARY KEY, b INT, c INT NOT NULL) ENGINE=InnoDB; + +INSERT INTO t VALUES (1,'aa'); +BEGIN; +INSERT INTO u SET a=1, c=1; +INSERT INTO u SELECT a+1,NULL,a+1 FROM u; +INSERT INTO u SELECT a+2,NULL,a+2 FROM u; +INSERT INTO u SELECT a+4,NULL,a+4 FROM u; +INSERT INTO u SELECT a+8,NULL,a+8 FROM u; +INSERT INTO u SELECT a+16,NULL,a+16 FROM u; +INSERT INTO u SELECT a+32,NULL,a+32 FROM u; +INSERT INTO u SELECT a+64,NULL,a+64 FROM u; +INSERT INTO u SELECT a+128,NULL,a+64 FROM u; +INSERT INTO u SELECT a+256,NULL,a+64 FROM u; +COMMIT; + +BEGIN; +DELETE FROM u; + +connection con2; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_u WAIT_FOR dml_done_u'; +--send +ALTER TABLE u ADD INDEX (c); + +connection default; +# Check that the above SELECT is blocked +let $wait_condition= + SELECT COUNT(*) = 1 from information_schema.processlist + WHERE state = 'Waiting for table metadata lock' AND + info = 'ALTER TABLE u ADD INDEX (c)'; +--source include/wait_condition.inc + +COMMIT; +SET DEBUG_SYNC='now WAIT_FOR created_u'; +SELECT state FROM information_schema.processlist +WHERE info='ALTER TABLE u ADD INDEX (c)'; + +connection con1; +SET DEBUG_SYNC='row_log_apply_before SIGNAL created_t WAIT_FOR dml_done_t'; +--send +CREATE INDEX c1 ON t (c(1)); +connection default; +SET DEBUG_SYNC='now WAIT_FOR created_t'; +UPDATE t SET c='ab'; +# Allow purge to kick in. TODO: Trigger this faster, somehow. +SELECT SLEEP(10); +SET DEBUG_SYNC='now SIGNAL dml_done_u'; +connection con2; +reap; +SET DEBUG_SYNC='now SIGNAL dml_done_t'; +disconnect con2; +connection con1; +reap; +disconnect con1; +connection default; +SET DEBUG_SYNC='RESET'; +DROP TABLE t,u; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb/t/innodb-index-online.opt b/mysql-test/suite/innodb/t/innodb-index-online.opt new file mode 100644 index 00000000000..a11d16860eb --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online.opt @@ -0,0 +1,6 @@ +--loose-innodb-sort-buffer-size=64k +--loose-innodb-online-alter-log-max-size=64k +--loose-innodb-buffer-pool-size=5M +--loose-innodb-log-buffer-size=256k +--loose-innodb-sys-indexes +--loose-innodb-sys-fields diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test new file mode 100644 index 00000000000..24e3cd1ba22 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-index-online.test @@ -0,0 +1,409 @@ +--source include/innodb_page_size_small.inc +--source include/have_debug_sync.inc + +let $innodb_metrics_select= +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; + +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); + +# DISCARD TABLESPACE needs file-per-table +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT) +ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); + +SET GLOBAL innodb_monitor_enable = module_ddl; +eval $innodb_metrics_select; + +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +--send +INSERT INTO t1 VALUES(1,2,3); + +connect (con1,localhost,root,,); +connection con1; + +# This should block at the end because of the INSERT in connection default +# is holding a metadata lock. +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; + +connection default; +--error ER_DUP_ENTRY +reap; +eval $innodb_metrics_select; + +connection con1; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; +--error ER_OUT_OF_RESOURCES +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_DBUG = @saved_debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_inplace_alter'; +--error ER_OUT_OF_RESOURCES +CREATE UNIQUE INDEX c2 ON t1(c2); +SET DEBUG_DBUG = @saved_debug_dbug; +CREATE UNIQUE INDEX c2 ON t1(c2); +DROP INDEX c2 ON t1; + +connection default; +SHOW CREATE TABLE t1; +# Insert a duplicate entry (4) for the upcoming UNIQUE INDEX(c2). +BEGIN; +INSERT INTO t1 VALUES(7,4,2); + +connection con1; +# This DEBUG_SYNC should not kick in yet, because the duplicate key will be +# detected before we get a chance to apply the online log. +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done'; +# This will be a lock wait timeout on the meta-data lock, +# because the transaction inserting (7,4,2) is still active. +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +COMMIT; +connection con1; +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +DELETE FROM t1 WHERE c1 = 7; +connection con1; +# ADD FOREIGN KEY is not supported in-place +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE; +# The previous DEBUG_SYNC should be ignored, because an exclusive lock +# has been requested and the online log is not being allocated. +ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +DROP INDEX c2 ON t1; +# Now the previous DEBUG_SYNC should kick in. +--send +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +eval $innodb_metrics_select; + +# Insert a duplicate entry (4) for the already started UNIQUE INDEX(c2). +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL rollback_done'; + +connection con1; +# Because the modification log will be applied in order, there will be +# a duplicate key error on the (7,4,2) even though we roll it back. +--error ER_DUP_ENTRY +reap; +# Now, create the index without any concurrent DML, while no duplicate exists. +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done'; +--send +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR created'; +# At this point, the index has been created inside InnoDB but not yet +# in the MySQL data dictionary. +eval $innodb_metrics_select; +# A duplicate key error should now be triggered by InnoDB, but reported +# by the ALTER TABLE because the index does not 'officially' exist yet. +INSERT INTO t1 VALUES(6,3,1); +SET DEBUG_SYNC = 'now SIGNAL dml_done'; +connection con1; +# This is due to the duplicate entry (6,3,1). +--error ER_DUP_UNKNOWN_IN_INDEX +reap; +DELETE FROM t1 WHERE c1=6; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +eval $innodb_metrics_select; + +connection default; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(6,3,1); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(7,4,2); +ALTER TABLE t1 STATS_PERSISTENT=1; +ANALYZE TABLE t1; +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +UPDATE mysql.innodb_index_stats SET stat_value = 5 +WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY' +AND stat_value = 6; +--replace_column 4 LAST_UPDATE +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1'); +CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats +WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2'; +# in Embedded mode (./mtr --embedded-server) the t1_c2_stats table gets +# created in MyISAM format by default even if we set +# default_storage_engine='innodb' +ALTER TABLE t1_c2_stats ENGINE=INNODB; +DROP INDEX c2 ON t1; +ANALYZE TABLE t1_c2_stats; +--replace_column 4 LAST_UPDATE +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats'); + +connection con1; +let $ID= `SELECT @id := CONNECTION_ID()`; +--error ER_QUERY_INTERRUPTED +KILL QUERY @id; + +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done'; +--send +CREATE INDEX c2d ON t1(c2); + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c2d_created'; +eval $innodb_metrics_select; +let $ignore= `SELECT @id := $ID`; +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; + +connection con1; +--error ER_QUERY_INTERRUPTED +reap; +eval $innodb_metrics_select; + +connection default; +CHECK TABLE t1; +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +--replace_result 81 80 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +ANALYZE TABLE t1; + +connection con1; +# Forge some statistics for c2d, and see that they will be used +UPDATE t1_c2_stats SET index_name = 'c2d'; +# Fake the statistics. The cardinality should be 5,80. +UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01'; +INSERT INTO t1_c2_stats +SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80, +sample_size, 'c2,c1' FROM t1_c2_stats +WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2'; +INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats; +DROP TABLE t1_c2_stats; + +CREATE INDEX c2d ON t1(c2); +# This should show the newly calculated stats by CREATE INDEX above, +# not the faked cardinality=4 for c2d(c2). +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +--replace_result 81 80 +SHOW INDEX FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; + +SHOW CREATE TABLE t1; + +# Exceed the configured innodb_online_alter_log_max_size. +# The actual limit is a multiple of innodb_sort_buf_size, +# because that is the size of the in-memory log buffers. +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; +# Ensure that the ALTER TABLE will be executed even with some concurrent DML. +SET lock_wait_timeout = 10; +--send +# FIXME: MDEV-13668 +#ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +ALTER TABLE t1 DROP INDEX c2d, ADD INDEX c2e(c2), +ALGORITHM = INPLACE; + +# Generate some log (delete-mark, delete-unmark, insert etc.) +# while the index creation is blocked. Some of this may run +# in parallel with the clustered index scan. +connection default; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +#UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; +# At this point, the clustered index scan must have completed, +# but the modification log keeps accumulating due to the DEBUG_SYNC. +eval $innodb_metrics_select; +let $c= 2; +while ($c) +{ + BEGIN; + DELETE FROM t1; + ROLLBACK; + UPDATE t1 SET c2 = c2 + 1; + BEGIN; + UPDATE t1 SET c2 = c2 + 1; + DELETE FROM t1; + ROLLBACK; + dec $c; +} +# Incomplete index c2e should exist until the DDL thread notices the overflow. +# (The output below strips TEMP_INDEX_PREFIX from the name.) +eval $innodb_metrics_select; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c2e'; + +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; + +connection con1; +# If the following fails with the wrong error, it probably means that +# you should rerun with a larger mtr --debug-sync-timeout. +--error ER_INNODB_ONLINE_LOG_TOO_BIG +reap; +# The index c2e should have been dropped from the data dictionary +# when the above error was noticed. It should still exist in the +# cache with index->online_status = ONLINE_INDEX_ABORTED_DROPPED. +eval $innodb_metrics_select; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c2e'; + +# ddl_background_drop_indexes = 1 here, because the incomplete index c2e still +# exists in the InnoDB data dictionary cache. +eval $innodb_metrics_select; + +connection default; + +ALTER TABLE t1 COMMENT 'testing if c2e will be dropped'; + +# Check that the 'zombie' index c2e was dropped. +eval $innodb_metrics_select; + +connection con1; +# Accumulate and apply some modification log. +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; +--send +# FIXME: MDEV-13668 +#ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; +ALTER TABLE t1 ADD INDEX c2f(c2); + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; +# Generate some log (delete-mark, delete-unmark, insert etc.) +eval $innodb_metrics_select; +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +eval $innodb_metrics_select; +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; + +connection con1; +reap; +# FIXME: MDEV-13668 +ALTER TABLE t1 CHANGE c2 c22f INT; + +eval $innodb_metrics_select; +SELECT COUNT(c22f) FROM t1; +CHECK TABLE t1; + +# Create a column prefix index. +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done'; +--send +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; + +# Check that the index was created. +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c3p5'; + +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +--send +INSERT INTO t1 VALUES(347,33101,NULL); + +connection con1; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; + +# InnoDB should have cleaned up the index c3p5 from the data dictionary, +# but not yet from the dictionary cache. +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c3p5'; +eval $innodb_metrics_select; + +connection default; +reap; +# Index c3p5 should still exist in the data dictionary cache. +eval $innodb_metrics_select; + +--disable_parsing +# Temporarily disabled by fix for bug#14213236. Should be either +# removed or updated to take into account that locking for IMPORT/ +# DISCARD TABLESPACE happens on MDL layer. New test case is added +# to validate this at MDL layer(i_main.alter_table.test) + +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2g_created WAIT_FOR dml4_done'; +# The lock upgrade at the end of the ALTER will conflict with the DISCARD. +SET lock_wait_timeout = 1; +--send +ALTER TABLE t1 DROP INDEX c2f, ADD INDEX c2g(c22f); + +connection con1; +SET DEBUG_SYNC = 'now WAIT_FOR c2g_created'; + +connect (con2,localhost,root,,); +connection con2; + +# This will conflict with the ALTER in connection default, above. +SET lock_wait_timeout = 10; +--send +ALTER TABLE t1 DISCARD TABLESPACE; + +connection con1; +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = 'Waiting for table level lock' and + info = 'ALTER TABLE t1 DISCARD TABLESPACE'; +--source include/wait_condition.inc + +SET DEBUG_SYNC = 'now SIGNAL dml4_done'; +disconnect con1; +connection con2; +reap; +disconnect con2; +connection default; +--error ER_LOCK_WAIT_TIMEOUT +reap; +--enable_parsing +#remove below con1 disconnect if above test case is enabled +connection con1; +disconnect con1; +connection default; + +SHOW CREATE TABLE t1; +ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f; +# The ALTER TABLE should have cleaned up c3p5 from the cache. +eval $innodb_metrics_select; +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; +--error ER_DUP_KEYNAME +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; + +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL innodb_monitor_disable = module_ddl; + +DROP TABLE t1; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc + +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +--disable_warnings +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; +--enable_warnings diff --git a/mysql-test/suite/innodb/t/innodb-table-online-master.opt b/mysql-test/suite/innodb/t/innodb-table-online-master.opt new file mode 100644 index 00000000000..9ac01ffb5ad --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-table-online-master.opt @@ -0,0 +1 @@ +--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=64k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k diff --git a/mysql-test/suite/innodb/t/innodb-table-online.test b/mysql-test/suite/innodb/t/innodb-table-online.test new file mode 100644 index 00000000000..a1977fa06a4 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-table-online.test @@ -0,0 +1,380 @@ +--source include/innodb_page_size_small.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +let $innodb_metrics_select= +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; + +call mtr.add_suppression("InnoDB: Warning: Small buffer pool size"); +# these will be triggered by DISCARD TABLESPACE +call mtr.add_suppression("InnoDB: Error: table 'test/t1'"); +call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for"); + +# DISCARD TABLESPACE needs file-per-table +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; + +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); + +SET GLOBAL innodb_monitor_enable = module_ddl; +eval $innodb_metrics_select; + +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +--send +INSERT INTO t1 VALUES(1,2,3); + +--echo # Establish session con1 (user=root) +connect (con1,localhost,root,,); +connection con1; + +# This should block at the end because of the INSERT in connection default +# is holding a metadata lock. +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; + +--echo # session default +connection default; +--error ER_DUP_ENTRY +reap; +eval $innodb_metrics_select; + +--echo # session con1 +connection con1; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET DEBUG_DBUG = '+d,innodb_OOM_prepare_inplace_alter'; +--error ER_OUT_OF_RESOURCES +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +SET SESSION DEBUG = @saved_debug_dbug; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +--error ER_OUT_OF_RESOURCES +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +SET SESSION DEBUG = @saved_debug_dbug; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; + +--echo # session default +connection default; +SHOW CREATE TABLE t1; +# Insert a duplicate entry (4) for the upcoming UNIQUE INDEX(c2). +BEGIN; +INSERT INTO t1 VALUES(7,4,2); + +--echo # session con1 +connection con1; +# This DEBUG_SYNC should not kick in yet, because the duplicate key will be +# detected before we get a chance to apply the online log. +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done'; +# This will be a lock wait timeout on the meta-data lock, +# because the transaction inserting (7,4,2) is still active. +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); + +--echo # session default +connection default; +COMMIT; + +--echo # session con1 +connection con1; +--error ER_DUP_ENTRY +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); + +--echo # session default +connection default; +DELETE FROM t1 WHERE c1 = 7; + +--echo # session con1 +connection con1; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT, +LOCK = SHARED, ALGORITHM = INPLACE; + +# The previous DEBUG_SYNC should be ignored, because an exclusive lock +# has been requested and the online log is not being allocated. +ALTER TABLE t1 ADD UNIQUE INDEX(c2), +LOCK = EXCLUSIVE, ALGORITHM = INPLACE; + +SHOW CREATE TABLE t1; +# We do not support plain DROP_PK_INDEX without ADD_PK_INDEX. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE; +SHOW CREATE TABLE t1; +# Now the previous DEBUG_SYNC should kick in. +--send +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1); + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +eval $innodb_metrics_select; + +# Insert a duplicate entry (4) for the already started UNIQUE INDEX(c1). +BEGIN; +INSERT INTO t1 VALUES(4,7,2); +SET DEBUG_SYNC = 'now SIGNAL insert_done'; + +--echo # session con1 +connection con1; +# Because the modification log will be applied in order and we did +# not roll back before the log apply, there will be a duplicate key +# error on the (4,7,2). +--error ER_DUP_ENTRY +reap; + +--echo # session default +connection default; +ROLLBACK; + +--echo # session con1 +connection con1; +SHOW CREATE TABLE t1; +# Now, rebuild the table without any concurrent DML, while no duplicate exists. +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE; +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE; +eval $innodb_metrics_select; + +--echo # session default +connection default; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(6,3,1); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES(7,4,2); +DROP INDEX c2_2 ON t1; +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; + +--echo # session con1 +connection con1; +let $ID= `SELECT @id := CONNECTION_ID()`; +--error ER_QUERY_INTERRUPTED +KILL QUERY @id; + +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done'; +--send +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt'; +eval $innodb_metrics_select; +let $ignore= `SELECT @id := $ID`; +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; + +--echo # session con1 +connection con1; +--error ER_QUERY_INTERRUPTED +reap; +eval $innodb_metrics_select; + +--echo # session default +connection default; +CHECK TABLE t1; +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +# Purge may or may not have cleaned up the DELETE FROM t1 WHERE c1 = 7; +--replace_result 81 80 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +ANALYZE TABLE t1; + +--echo # session con1 +connection con1; +SHOW CREATE TABLE t1; + +# Exceed the configured innodb_online_alter_log_max_size. +# The actual limit is a multiple of innodb_sort_buf_size, +# because that is the size of the in-memory log buffers. +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done'; +# Ensure that the ALTER TABLE will be executed even with some concurrent DML. +SET lock_wait_timeout = 10; +--send +ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE; + +# Generate some log (delete-mark, delete-unmark, insert etc.) +# while the index creation is blocked. Some of this may run +# in parallel with the clustered index scan. +--echo # session default +connection default; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2'; +# At this point, the clustered index scan must have completed, +# but the modification log keeps accumulating due to the DEBUG_SYNC. +eval $innodb_metrics_select; +let $c= 3; +while ($c) +{ + BEGIN; + DELETE FROM t1; + ROLLBACK; + UPDATE t1 SET c2 = c2 + 1; + BEGIN; + UPDATE t1 SET c2 = c2 + 1; + DELETE FROM t1; + ROLLBACK; + dec $c; +} +# Temporary table should exist until the DDL thread notices the overflow. +eval $innodb_metrics_select; + +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; + +--echo # session con1 +connection con1; +# If the following fails with the wrong error, it probably means that +# you should rerun with a larger mtr --debug-sync-timeout. +--error ER_INNODB_ONLINE_LOG_TOO_BIG +reap; +# The table should have been dropped from the data dictionary +# when the above error was noticed. +eval $innodb_metrics_select; + +# Accumulate and apply some modification log. +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done'; +--error ER_MULTIPLE_PRI_KEY +ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +--error ER_DUP_ENTRY +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +--send +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)), +CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f, +ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online'; + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3'; +# Generate some log (delete-mark, delete-unmark, insert etc.) +eval $innodb_metrics_select; +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +eval $innodb_metrics_select; +# Release con1. +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; + +--echo # session con1 +connection con1; +reap; +eval $innodb_metrics_select; +SELECT COUNT(c22f) FROM t1; +CHECK TABLE t1; + +# Create a column prefix index. +--error ER_DUP_ENTRY +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)); +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); +SET @old_sql_mode = @@sql_mode; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +--error ER_INVALID_USE_OF_NULL +ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), +ALGORITHM = INPLACE; + +--error ER_INVALID_USE_OF_NULL +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET @@sql_mode = @old_sql_mode; +UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL; + +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +SET @@sql_mode = 'STRICT_TRANS_TABLES'; +--send +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f, +DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)), +ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST; + +--echo # session default +connection default; + +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0'; +BEGIN; +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2'); +INSERT INTO t1 VALUES(33101,347,NULL,''); +SET DEBUG_SYNC = 'now SIGNAL ins_done0'; + +--echo # session con1 +connection con1; +--error ER_INVALID_USE_OF_NULL +reap; +SET @@sql_mode = @old_sql_mode; + +--echo # session default +connection default; +ROLLBACK; + +--echo # session con1 +connection con1; +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done'; +--send +ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f, +ADD COLUMN c6 VARCHAR(1000) DEFAULT +'I love tracking down hard-to-reproduce bugs.', +ADD PRIMARY KEY c3p5(c3(5), c6(2)); + +--echo # session default +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +--error ER_BAD_NULL_ERROR +INSERT INTO t1 VALUES(347,33101,NULL,''); +--send +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti',''); + +--echo # session con1 +connection con1; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +eval $innodb_metrics_select; + +--echo # session default +connection default; +reap; +SELECT COUNT(*) FROM t1; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SELECT * FROM t1 LIMIT 10; + +--echo # session con1 +connection con1; +ALTER TABLE t1 DISCARD TABLESPACE; +--echo # Disconnect session con1 +disconnect con1; + +--echo # session default +connection default; +SHOW CREATE TABLE t1; +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc + +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +--disable_warnings +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; +--enable_warnings diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.opt b/mysql-test/suite/innodb/t/innodb-wl5980-alter.opt new file mode 100644 index 00000000000..aa400236153 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.opt @@ -0,0 +1,3 @@ +--loose-innodb-sys-indexes +--loose-innodb-sys-columns +--loose-innodb-sys-fields diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test new file mode 100644 index 00000000000..4b26661793c --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test @@ -0,0 +1,619 @@ +--echo # +--echo # This is a copy of innodb-alter.test except using remote tablespaces +--echo # and showing those files. +--echo # + +--source include/have_innodb.inc + +--disable_query_log +# These values can change during the test +LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`; +LET $regexp=/FTS_([0-9a-f_]+)([A-Z0-9_]+)\.ibd/FTS_AUX_\2.ibd/; + +# Set up some variables +LET $MYSQL_DATA_DIR = `select @@datadir`; +LET $data_directory_clause = DATA DIRECTORY='$MYSQL_TMP_DIR/alt_dir'; +--enable_query_log + +SET default_storage_engine=InnoDB; +SET GLOBAL innodb_file_per_table=ON; + +SET NAMES utf8mb4; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1 ( + c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, + INDEX(c2)) +ENGINE=InnoDB $data_directory_clause; + +INSERT INTO t1 SET c1=1; + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME LIKE 'test/t%'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +CREATE TABLE t1p LIKE t1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3), + CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2), + CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2)) +ENGINE=InnoDB $data_directory_clause; + +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i +WHERE FOR_NAME LIKE 'test/t%'; + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1; +ALTER TABLE t1 ALTER c2 DROP DEFAULT; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +# These should be no-op. +ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1; +ALTER TABLE t1 CHANGE c1 c1 INT FIRST; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C2 c3 INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE c3 C INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 CHANGE C Cöŀumň_TWO INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i +INNER JOIN sys_foreign sf ON i.ID = sf.ID; + +-- source suite/innodb/include/innodb_dict.inc + +-- error ER_BAD_FIELD_ERROR +ALTER TABLE t1 CHANGE cöĿǖmň_two c3 INT; + +ALTER TABLE t1 CHANGE cÖĿUMŇ_two c3 INT, RENAME TO t3; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t3; +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +# The maximum column name length should be 64 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE c3 +`12345678901234567890123456789012345678901234567890123456789012345` INT; +ALTER TABLE t3 CHANGE c3 +`1234567890123456789012345678901234567890123456789012345678901234` INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t3; + +# Test the length limit with non-ASCII utf-8 characters. +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿å€` INT; + +--error ER_TOO_LONG_IDENT +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾å€¿Ã¤` INT; + +ALTER TABLE t3 CHANGE +`1234567890123456789012345678901234567890123456789012345678901234` +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã¤` INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# check that the rename is case-insensitive (note the upper-case ä at end) +ALTER TABLE t3 CHANGE +`倀å€å€‚倃倄倅倆倇倈倉倊個倌å€å€Žå€å€å€‘倒倓倔倕倖倗倘候倚倛倜å€å€žå€Ÿå€ 倡倢倣値倥倦倧倨倩倪倫倬å€å€®å€¯å€°å€±å€²å€³å€´å€µå€¶å€·å€¸å€¹å€ºå€»å€¼å€½å€¾Ã„` +c3 INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# test with 4-byte UTF-8 (should be disallowed) +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 ðŒ€ðŒðŒ‚ðŒƒðŒ„ðŒ…ðŒ†ðŒ‡ðŒˆðŒ‰ðŒŠðŒ‹ðŒŒðŒðŒŽðŒðŒðŒ‘ðŒ’ðŒ“ðŒ”ðŒ•ðŒ–ðŒ—ðŒ˜ðŒ™ðŒšðŒ›ðŒœ INT; + +--error ER_INVALID_CHARACTER_STRING +ALTER TABLE t3 CHANGE c3 😲 INT; + +ALTER TABLE t3 RENAME TO t2; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t2; + +RENAME TABLE t2 TO t1; + +SELECT st.NAME, i.NAME +FROM sys_tables st INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_TABLES i +ON i.TABLE_ID=st.TABLE_ID; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +--error ER_DROP_INDEX_FK +ALTER TABLE t1 DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP INDEX c4; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY t1c2, DROP FOREIGN KEY c2, DROP INDEX c2; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX c2; + +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1c DROP FOREIGN KEY ẗ1C2; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +SET foreign_key_checks=0; +DROP TABLE t1p; +SET foreign_key_checks=1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval CREATE TABLE t1p (c1 INT PRIMARY KEY, c2 INT, INDEX(c2)) + ENGINE=InnoDB $data_directory_clause; + +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C2, DROP INDEX C3; +--error ER_DROP_INDEX_FK +ALTER TABLE t1c DROP INDEX C3; + +SET foreign_key_checks=0; +ALTER TABLE t1c DROP INDEX C3; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +SET foreign_key_checks=1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP FOREIGN KEY t1C3; + +--echo ### files in MYSQL_DATA_DIR/test +--list_files $MYSQL_DATA_DIR/test +--replace_regex $regexp +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1c DROP INDEX c2, DROP FOREIGN KEY t1C2; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1c; + +-- source suite/innodb/include/innodb_dict.inc + +ALTER TABLE t1 DROP INDEX c2, CHANGE c3 c2 INT; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +-- source suite/innodb/include/innodb_dict.inc + +CREATE TABLE t1o LIKE t1; + +# This will implicitly add a DOC_ID column. +# The LOCK=NONE should thus fail. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=NONE; + +# Retry with LOCK=EXCLUSIVE. +ALTER TABLE t1 ADD FULLTEXT INDEX (ct), +CHANGE c1 pk INT, ALTER c2 SET DEFAULT 42, RENAME TO tt, +ALGORITHM=INPLACE, LOCK=SHARED; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# The output should be empty, because index->id was reassigned. +-- source suite/innodb/include/innodb_dict.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE tt; + +# DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR are reserved InnoDB system column names. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 DB_TRX_ID INT; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o CHANGE c1 db_roll_ptr INT; + +# FTS_DOC_ID is the internal row identifier for full-text search. +# It should be of type BIGINT UNSIGNED NOT NULL. +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=COPY; + +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_DOC_ID INT, +ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), CHANGE c1 FTS_Doc_ID INT, +ALGORITHM=INPLACE; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +CREATE TABLE t1n LIKE t1o; + +ALTER TABLE t1n ADD FULLTEXT INDEX(ct); + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE; +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY; +--error ER_BAD_FIELD_ERROR +ALTER TABLE t1n CHANGE FTS_DOC_ID c11 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c1 FTS_DOC_ïD INT, ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +ALTER TABLE t1n CHANGE FTS_DOC_ÃD c1 INT, ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +ALTER TABLE t1n CHANGE c1 c2 INT, CHANGE c2 ct INT, CHANGE ct c1 TEXT, +ALGORITHM=INPLACE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; +ALTER TABLE t1n CHANGE c2 c1 INT, CHANGE ct c2 INT, CHANGE c1 ct TEXT, +ALGORITHM=COPY; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +--error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY; + +# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table +# when renaming a column and adding index +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; +ALTER TABLE t1n DROP INDEX c4; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--error ER_DUP_FIELDNAME +ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE; +# FIXME: MDEV-13668 +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE; +ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE; +ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1n; +DROP TABLE t1n; + +ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE +call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o"); +--error ER_NOT_KEYFILE +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), +CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ALGORITHM=INPLACE; + +--echo # The following would crash 10.2. Re-enable this and test after merge! +ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +# end of MDEV-9469 FIXME + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# This would create a hidden FTS_DOC_ID column, which cannot be done online. +# FIXME: MDEV-9469 (enable this) +#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +#LOCK=NONE; +#end of MDEV-9469 FIXME + +# This should not show duplicates. +SELECT sc.pos FROM information_schema.innodb_sys_columns sc +INNER JOIN information_schema.innodb_sys_tables st +ON sc.TABLE_ID=st.TABLE_ID +WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID'; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1o; + +# FIXME: MDEV-13668 +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL, +DROP INDEX ct, LOCK=NONE; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +SHOW CREATE TABLE t1o; + +DROP TABLE t1c, t1p, sys_tables, sys_indexes, sys_foreign; + +# Check the internal schemata of tt, t1o. + +CREATE TABLE sys_tables SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES +WHERE NAME='test/t1o'; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; +CREATE TABLE sys_foreign SELECT i.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN i WHERE FOR_NAME='test/t1o'; + +-- source suite/innodb/include/innodb_dict.inc + +# Ensure that there exists no hidden FTS_DOC_ID_INDEX on foo_id. + +ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id); + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE +--error ER_NOT_KEYFILE +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +ADD FULLTEXT INDEX(ct); + +ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE; +ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE; +#end of MDEV-9469 FIXME + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test + +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL; + +DROP TABLE sys_indexes; +CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i +INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID; + +-- source suite/innodb/include/innodb_dict.inc + +--echo # +--echo # Cleanup +--echo # + +DROP TABLE tt, t1o, sys_tables, sys_indexes, sys_foreign; + +--echo ### files in MYSQL_DATA_DIR/test +--replace_regex $regexp +--list_files $MYSQL_DATA_DIR/test +--echo ### files in MYSQL_TMP_DIR/alt_dir/test +--replace_regex $regexp +--list_files $MYSQL_TMP_DIR/alt_dir/test +--rmdir $MYSQL_TMP_DIR/alt_dir/test +--rmdir $MYSQL_TMP_DIR/alt_dir + +-- disable_query_log +eval set global innodb_file_per_table=$innodb_file_per_table_orig; +call mtr.add_suppression("deleting orphaned .ibd file"); +-- enable_query_log diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test index 957b758d05c..20bb52c22f2 100644 --- a/mysql-test/suite/innodb/t/xa_recovery.test +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -15,8 +15,14 @@ connect (con1,localhost,root); XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x'; connection default; +# innodb_force_recovery=2 prevents the purge and tests that the fix of +# MDEV-13606 XA PREPARE transactions should survive innodb_force_recovery=1 or 2 +# is present. +--let $restart_parameters= --innodb-force-recovery=2 --let $shutdown_timeout=0 --source include/restart_mysqld.inc +--let $restart_parameters= +--let $shutdown_timeout= disconnect con1; connect (con1,localhost,root); diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.opt b/mysql-test/suite/mariabackup/auth_plugin_win.opt new file mode 100644 index 00000000000..e534ae1eae5 --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.opt @@ -0,0 +1 @@ +--loose-enable-named-pipe diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.result b/mysql-test/suite/mariabackup/auth_plugin_win.result new file mode 100644 index 00000000000..7a623be147f --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.result @@ -0,0 +1,5 @@ +INSTALL SONAME 'auth_named_pipe'; +CREATE USER 'USERNAME' IDENTIFIED WITH named_pipe; +GRANT ALL PRIVILEGES ON *.* to USERNAME; +DROP USER 'USERNAME'; +UNINSTALL SONAME 'auth_named_pipe'; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.test b/mysql-test/suite/mariabackup/auth_plugin_win.test new file mode 100644 index 00000000000..9c8cd5ad411 --- /dev/null +++ b/mysql-test/suite/mariabackup/auth_plugin_win.test @@ -0,0 +1,31 @@ +--source include/windows.inc +--source include/not_embedded.inc + +if (!$AUTH_NAMED_PIPE_SO) { + skip No named pipe plugin; +} + +if (!$USERNAME) { + skip USERNAME variable is undefined; +} + +if (`SELECT count(*) <> 0 FROM mysql.user WHERE user = '$USERNAME'`) { + skip \$USER=$USER which exists in mysql.user; +} + +INSTALL SONAME 'auth_named_pipe'; + +--replace_result $USERNAME USERNAME +eval CREATE USER '$USERNAME' IDENTIFIED WITH named_pipe; +--replace_result $USERNAME USERNAME +eval GRANT ALL PRIVILEGES ON *.* to $USERNAME; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf -u $USERNAME --backup --protocol=pipe --target-dir=$targetdir; +--enable_result_log +--replace_result $USERNAME USERNAME +eval DROP USER '$USERNAME'; +rmdir $targetdir; +UNINSTALL SONAME 'auth_named_pipe'; + diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.opt b/mysql-test/suite/mariabackup/xb_aws_key_management.opt index 62d4f864073..fceff3be28d 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.opt +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.opt @@ -1,3 +1,3 @@ --plugin-load-add=$AWS_KEY_MANAGEMENT_SO --loose-aws-key-management ---loose-aws-key-management-master-key-id=$AWS_KEY_MANAGEMENT_MASTER_KEY_ID +--loose-aws-key-management-mock=ON diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.result b/mysql-test/suite/mariabackup/xb_aws_key_management.result index ccad423f631..6efc76a8be3 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.result +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.result @@ -1,4 +1,7 @@ CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; +Warnings: +Note 1105 AWS KMS plugin: generated encrypted datakey for key id=1, version=1 +Note 1105 AWS KMS plugin: loaded key 1, version 1, key length 128 bit INSERT INTO t VALUES('foobar1'); # xtrabackup backup # shutdown server @@ -8,4 +11,6 @@ INSERT INTO t VALUES('foobar1'); SELECT * from t; c foobar1 +Warnings: +Note 1105 AWS KMS plugin: loaded key 1, version 1, key length 128 bit DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.test b/mysql-test/suite/mariabackup/xb_aws_key_management.test index 28ef459f853..9f69cbec8b8 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.test +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.test @@ -1,13 +1,9 @@ --source include/innodb_page_size.inc +--source include/have_debug.inc if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'aws_key_management' AND PLUGIN_STATUS='ACTIVE'`) { - --skip needs aws_key_management plugin plugin -} - -if (`SELECT @@aws_key_management_master_key_id=''`) -{ - --skip Test requires AWS_KEY_MANAGEMEMENT_MASTER_KEY_ID env. variable + --skip needs aws_key_management plugin } CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; diff --git a/mysql-test/suite/storage_engine/parts/repair_table.opt b/mysql-test/suite/storage_engine/parts/repair_table.opt new file mode 100644 index 00000000000..759bf0b6429 --- /dev/null +++ b/mysql-test/suite/storage_engine/parts/repair_table.opt @@ -0,0 +1 @@ +--myisam-recover-options=DEFAULT diff --git a/mysql-test/suite/storage_engine/parts/repair_table.result b/mysql-test/suite/storage_engine/parts/repair_table.result index d9ac215797b..727c648ef6f 100644 --- a/mysql-test/suite/storage_engine/parts/repair_table.result +++ b/mysql-test/suite/storage_engine/parts/repair_table.result @@ -88,6 +88,7 @@ call mtr.add_suppression("Got an error from thread_id=.*"); call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table"); call mtr.add_suppression(" '\..test.t1'"); call mtr.add_suppression("Couldn't repair table: test.t1"); +call mtr.add_suppression("Table 't1' is marked as crashed.*"); CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2; REPAIR TABLE t1; Table Op Msg_type Msg_text diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff index 44bb824432b..3122f0a5711 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff @@ -480,7 +480,7 @@ VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT +VARIABLE_TYPE INT - VARIABLE_COMMENT Number of multi-threaded flush threads + VARIABLE_COMMENT DEPRECATED. Number of multi-threaded flush threads NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 @@ -2084,10 +2084,10 @@ diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 62a72525aab..b2c8ada4b27 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -2029,7 +2029,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 8 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT -VARIABLE_COMMENT Number of multi-threaded flush threads +VARIABLE_COMMENT DEPRECATED. Number of multi-threaded flush threads NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 64 NUMERIC_BLOCK_SIZE 0 @@ -3037,7 +3037,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE OFF VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Use multi-threaded flush. Default FALSE. +VARIABLE_COMMENT DEPRECATED. Use multi-threaded flush. Default FALSE. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 69df8c0f19e..0c206975c29 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -598,7 +598,7 @@ VARIABLE_SCOPE SESSION VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Ensure "synchronous" read view before executing an operation of the type specified by bitmask: 1 - READ(includes SELECT, SHOW and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - INSERT and REPLACE NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 7 +NUMERIC_MAX_VALUE 15 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY NO diff --git a/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result b/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result index 1e7b9364570..0df3dff8990 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_sync_wait_basic.result @@ -34,11 +34,9 @@ SELECT @@session.wsrep_sync_wait; @@session.wsrep_sync_wait 7 SET @@session.wsrep_sync_wait=8; -Warnings: -Warning 1292 Truncated incorrect wsrep_sync_wait value: '8' SELECT @@session.wsrep_sync_wait; @@session.wsrep_sync_wait -7 +8 # invalid values SET @@global.wsrep_sync_wait=NULL; diff --git a/mysql-test/suite/wsrep/disabled.def b/mysql-test/suite/wsrep/disabled.def index 605f063f967..8b137891791 100644 --- a/mysql-test/suite/wsrep/disabled.def +++ b/mysql-test/suite/wsrep/disabled.def @@ -1 +1 @@ -foreign_key : MDEV-7915 + diff --git a/mysql-test/suite/wsrep/t/mdev_6832.opt b/mysql-test/suite/wsrep/t/mdev_6832.opt index 459a9702707..16f8962dba2 100644 --- a/mysql-test/suite/wsrep/t/mdev_6832.opt +++ b/mysql-test/suite/wsrep/t/mdev_6832.opt @@ -1 +1 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --wsrep_causal_reads=ON +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 diff --git a/mysql-test/suite/wsrep/t/mdev_7798.opt b/mysql-test/suite/wsrep/t/mdev_7798.opt index 459a9702707..1007d5c0b78 100644 --- a/mysql-test/suite/wsrep/t/mdev_7798.opt +++ b/mysql-test/suite/wsrep/t/mdev_7798.opt @@ -1 +1 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --wsrep_causal_reads=ON +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 93fd23b7fea..ca2f73db5ca 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1766,6 +1766,48 @@ SHOW CREATE TABLE t1; DROP TABLE t1; --echo # +--echo # MDEV-8960 Can't refer the same column twice in one ALTER TABLE +--echo # + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` DROP DEFAULT; + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL, +ALTER COLUMN `consultant_id` SET DEFAULT 2; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + `a` int(11) DEFAULT NULL +) DEFAULT CHARSET=utf8; + +ALTER TABLE t1 ADD COLUMN `consultant_id` integer NOT NULL DEFAULT 2, +ALTER COLUMN `consultant_id` DROP DEFAULT, +MODIFY COLUMN `consultant_id` BIGINT; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # --echo # Start of 10.1 tests --echo # diff --git a/mysql-test/t/tc_heuristic_recover.test b/mysql-test/t/tc_heuristic_recover.test new file mode 100644 index 00000000000..c9fa767c249 --- /dev/null +++ b/mysql-test/t/tc_heuristic_recover.test @@ -0,0 +1,106 @@ +# The test verifies a few server/engine recovery option combinations. +# Specifically, MDEV-13437,13438 are concerned with no crashes +# due to InnoDB being read-only during --tc-heuristic-recover=ROLLBACK|COMMIT. +# +# Initially the test commits a transaction and in the following proceeds +# throughout some phases. +# Within them the server is shut down and attempted to restart, to succeed +# that in the end. +# All this proves no crashes and effective rollback of the transaction. +# +--source include/have_innodb.inc +# The test logics really requires --log-bin. +--source include/have_binlog_format_mixed.inc +--source include/have_debug_sync.inc +--source include/not_embedded.inc + +call mtr.add_suppression("Can't init tc log"); +call mtr.add_suppression("Found 1 prepared transactions!"); +call mtr.add_suppression("Aborting"); + +# Now take a shapshot of the last time server options. +# +# The "restart" expect-file facility can't be engaged because the server +# having conflicting options may not succeed to boot up. +# Also notice $MYSQLD_CMD is too "static" being unaware of the actual options +# of the last (before shutdown or kill) server run. +# That's why $MYSQLD_LAST_CMD that allows for the server new start +# with more options appended to a stub set which is settled at this very point. +--let $mysqld_stub_cmd= $MYSQLD_LAST_CMD +--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err +--let SEARCH_FILE= $error_log +set debug_sync='RESET'; + +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +FLUSH TABLES; # we need the table post crash-restart, see MDEV-8841. + +# Run transaction in a separate "prey" connection +--connect (con1,localhost,root,,) +# The signal won't arrive though +set debug_sync='ha_commit_trans_after_prepare WAIT_FOR go'; +--send INSERT INTO t1 VALUES (1); + +--connection default + +--let $table= information_schema.processlist +--let $where= where state = 'debug sync point: ha_commit_trans_after_prepare' +--let $wait_condition= SELECT count(*) = 1 FROM $table $where +--source include/wait_condition.inc + +--echo # Prove that no COMMIT or ROLLBACK occurred yet. +SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; + +# TODO: MDEV-12700 Allow innodb_read_only startup without prior slow shutdown. +--source include/kill_mysqld.inc +--let $restart_parameters= --innodb-force-recovery=4 +--source include/fail_start_mysqld.inc + +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= \\[ERROR\\] Can\\'t init tc log +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --innodb-force-recovery=4 --tc-heuristic-recover=COMMIT +--source include/fail_start_mysqld.inc +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= \\[ERROR\\] Can\\'t init tc log +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= Please restart mysqld without --tc-heuristic-recover +--source include/search_pattern_in_file.inc + +--let $restart_parameters= --tc-heuristic-recover=ROLLBACK +--source include/fail_start_mysqld.inc + +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= \\[ERROR\\] Can\\'t init tc log +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= Please restart mysqld without --tc-heuristic-recover +--source include/search_pattern_in_file.inc + +--let $restart_parameters= +--source include/start_mysqld.inc + +--let SEARCH_PATTERN= was in the XA prepared state +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN= Found 1 prepared transactions! +--source include/search_pattern_in_file.inc + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1; +# +# Cleanup +# +DROP TABLE t1; diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 4ece5fd1749..84841aabb8b 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -122,10 +122,22 @@ SELECT 3; eval SET @@global.wait_timeout= $start_value; disconnect con1; - -# The last connect is to keep tools checking the current test happy. connect (default,localhost,root,,test,,); +# +# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout +# +set global log_warnings=2; +connect (foo,localhost,root); +set @@wait_timeout=1; +sleep 2; +connection default; +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets; +source include/search_pattern_in_file.inc; +set global log_warnings=@@log_warnings; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/wait_timeout_not_windows.test b/mysql-test/t/wait_timeout_not_windows.test deleted file mode 100644 index 50731779845..00000000000 --- a/mysql-test/t/wait_timeout_not_windows.test +++ /dev/null @@ -1,15 +0,0 @@ -source include/not_embedded.inc; -source include/not_windows.inc; - -# -# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout -# -set global log_warnings=2; -connect (foo,localhost,root); -set @@wait_timeout=1; -sleep 2; -connection default; -let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; -let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets; -source include/search_pattern_in_file.inc; -set global log_warnings=@@log_warnings; diff --git a/mysys/my_init.c b/mysys/my_init.c index 7f0f7a8cc44..84489a994e3 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -200,7 +200,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR ); _CrtCheckMemory(); - _CrtDumpMemoryLeaks(); #endif } diff --git a/mysys/my_winerr.c b/mysys/my_winerr.c index 92e1fa83d78..a3f6229b74e 100644 --- a/mysys/my_winerr.c +++ b/mysys/my_winerr.c @@ -75,7 +75,9 @@ static struct errentry errtable[]= { { ERROR_ALREADY_EXISTS, EEXIST }, /* 183 */ { ERROR_FILENAME_EXCED_RANGE, ENOENT }, /* 206 */ { ERROR_NESTING_NOT_ALLOWED, EAGAIN }, /* 215 */ - { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } /* 1816 */ + { ERROR_FILE_SYSTEM_LIMITATION, EFBIG }, /* 665 */ + { ERROR_NO_SYSTEM_RESOURCES, ENOMEM }, /* 1450 */ + { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } /* 1816 */ }; /* size of the table */ diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt index 33ac1b8716c..913bd8b16ed 100644 --- a/plugin/aws_key_management/CMakeLists.txt +++ b/plugin/aws_key_management/CMakeLists.txt @@ -15,6 +15,7 @@ MACRO(SKIP_AWS_PLUGIN msg) MESSAGE_ONCE(SKIP_AWS_PLUGIN "Skip aws_key_management - ${msg}") RETURN() ENDMACRO() +SET(CMAKE_CXX_STANDARD 11) diff --git a/plugin/aws_key_management/aws_key_management_plugin.cc b/plugin/aws_key_management/aws_key_management_plugin.cc index 365c5caf198..60ca6fd1ff3 100644 --- a/plugin/aws_key_management/aws_key_management_plugin.cc +++ b/plugin/aws_key_management/aws_key_management_plugin.cc @@ -82,9 +82,20 @@ static unsigned long log_level; static int rotate_key; static int request_timeout; +#ifndef DBUG_OFF +#define WITH_AWS_MOCK 1 +#else +#define WITH_AWS_MOCK 0 +#endif + +#if WITH_AWS_MOCK +static char mock; +#endif + + /* AWS functionality*/ -static int aws_decrypt_key(const char *path, KEY_INFO *info); -static int aws_generate_datakey(uint key_id, uint version); +static int read_and_decrypt_key(const char *path, KEY_INFO *info); +static int generate_and_save_datakey(uint key_id, uint version); static int extract_id_and_version(const char *name, uint *id, uint *ver); static unsigned int get_latest_key_version(unsigned int key_id); @@ -95,6 +106,35 @@ static std::mutex mtx; static Aws::KMS::KMSClient *client; +#if WITH_AWS_MOCK +/* + Mock routines to test plugin without actual AWS KMS interaction + we only need to mock 2 functions - generating encrypted key, and decrypt + + This mock functions do no-op encryption, i.e encrypt and decrypt of + a buffer return the buffer itself. +*/ + +/* + Generate random "encrypted" key. We do not encrypt anything in mock mode. +*/ +static int mock_generate_encrypted_key(Aws::Utils::ByteBuffer *result) +{ + size_t len = key_spec == 0?16 : 32; + *result = Aws::Utils::ByteBuffer(len); + my_random_bytes(result->GetUnderlyingData(), (int)len); + return 0; +} + + +static int mock_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +{ + /* We do not encrypt or decrypt in mock mode.*/ + *output = input; + return 0; +} +#endif + /* Redirect AWS trace to error log */ class MySQLLogSystem : public Aws::Utils::Logging::FormattedLogSystem { @@ -163,13 +203,7 @@ static vector<string> traverse_current_directory() Aws::SDKOptions sdkOptions; -/* - Plugin initialization. - - Create KMS client and scan datadir to find out which keys and versions - are present. -*/ -static int plugin_init(void *p) +static int aws_init() { #ifdef HAVE_YASSL @@ -198,7 +232,29 @@ static int plugin_init(void *p) my_printf_error(ER_UNKNOWN_ERROR, "Can not initialize KMS client", ME_ERROR_LOG | ME_WARNING); return -1; } - + return 0; +} + +static int init() +{ +#if WITH_AWS_MOCK + if(mock) + return 0; +#endif + return aws_init(); +} + +/* + Plugin initialization. + + Create KMS client and scan datadir to find out which keys and versions + are present. +*/ +static int plugin_init(void *p) +{ + if (init()) + return -1; + vector<string> files= traverse_current_directory(); for (size_t i=0; i < files.size(); i++) { @@ -214,14 +270,29 @@ static int plugin_init(void *p) } -static int plugin_deinit(void *p) +static void aws_shutdown() { - latest_version_cache.clear(); - key_info_cache.clear(); delete client; ShutdownAWSLogging(); - Aws::ShutdownAPI(sdkOptions); +} + + +static void shutdown() +{ +#if WITH_AWS_MOCK + if(mock) + return; +#endif + aws_shutdown(); +} + + +static int plugin_deinit(void *p) +{ + latest_version_cache.clear(); + key_info_cache.clear(); + shutdown(); return 0; } @@ -251,7 +322,7 @@ static int load_key(KEY_INFO *info) char path[256]; format_keyfile_name(path, sizeof(path), info->key_id, info->key_version); - ret= aws_decrypt_key(path, info); + ret= read_and_decrypt_key(path, info); if (ret) info->load_failed= true; @@ -317,14 +388,7 @@ static unsigned int get_latest_key_version_nolock(unsigned int key_id) else // (ver == 0) { /* Generate a new key, version 1 */ - if (!master_key_id[0]) - { - my_printf_error(ER_UNKNOWN_ERROR, - "Can't generate encryption key %u, because 'aws_key_management_master_key_id' parameter is not set", - MYF(0), key_id); - return(ENCRYPTION_KEY_VERSION_INVALID); - } - if (aws_generate_datakey(key_id, 1) != 0) + if (generate_and_save_datakey(key_id, 1) != 0) return(ENCRYPTION_KEY_VERSION_INVALID); info.key_id= key_id; info.key_version= 1; @@ -336,11 +400,35 @@ static unsigned int get_latest_key_version_nolock(unsigned int key_id) return(info.key_version); } +/* Decrypt Byte buffer with AWS. */ +static int aws_decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +{ + DecryptRequest request; + request.SetCiphertextBlob(input); + DecryptOutcome outcome = client->Decrypt(request); + if (!outcome.IsSuccess()) + { + *errmsg = outcome.GetError().GetMessage(); + return -1; + } + *output= outcome.GetResult().GetPlaintext(); + return 0; +} + + +static int decrypt(Aws::Utils::ByteBuffer input, Aws::Utils::ByteBuffer* output, Aws::String *errmsg) +{ +#if WITH_AWS_MOCK + if(mock) + return mock_decrypt(input,output, errmsg); +#endif + return aws_decrypt(input, output, errmsg); +} /* Decrypt a file with KMS */ -static int aws_decrypt_key(const char *path, KEY_INFO *info) +static int read_and_decrypt_key(const char *path, KEY_INFO *info) { /* Read file content into memory */ @@ -361,20 +449,21 @@ static int aws_decrypt_key(const char *path, KEY_INFO *info) ifs.read(&contents[0], pos); /* Decrypt data the with AWS */ - DecryptRequest request; - Aws::Utils::ByteBuffer byteBuffer((unsigned char *)contents.data(), pos); - request.SetCiphertextBlob(byteBuffer); - DecryptOutcome outcome = client->Decrypt(request); - if (!outcome.IsSuccess()) + + Aws::Utils::ByteBuffer input((unsigned char *)contents.data(), pos); + Aws::Utils::ByteBuffer plaintext; + Aws::String errmsg; + + if (decrypt(input, &plaintext, &errmsg)) { - my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: Decrypt failed for %s : %s", ME_ERROR_LOG, path, - outcome.GetError().GetMessage().c_str()); - return(-1); + my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: Decrypt failed for %s : %s", ME_ERROR_LOG, path, + errmsg.c_str()); + return -1; } - Aws::Utils::ByteBuffer plaintext = outcome.GetResult().GetPlaintext(); + size_t len = plaintext.GetLength(); - if (len > (int)sizeof(info->data)) + if (len > sizeof(info->data)) { my_printf_error(ER_UNKNOWN_ERROR, "AWS KMS plugin: encoding key too large for %s", ME_ERROR_LOG, path); return(ENCRYPTION_KEY_BUFFER_TOO_SMALL); @@ -385,9 +474,15 @@ static int aws_decrypt_key(const char *path, KEY_INFO *info) } -/* Generate a new datakey and store it a file */ -static int aws_generate_datakey(uint keyid, uint version) +int aws_generate_encrypted_key(Aws::Utils::ByteBuffer *result) { + if (!master_key_id[0]) + { + my_printf_error(ER_UNKNOWN_ERROR, + "Can't generate encryption key, because 'aws_key_management_master_key_id' parameter is not set", + MYF(0)); + return(-1); + } GenerateDataKeyWithoutPlaintextRequest request; request.SetKeyId(master_key_id); request.SetKeySpec(DataKeySpecMapper::GetDataKeySpecForName(key_spec_names[key_spec])); @@ -401,11 +496,30 @@ static int aws_generate_datakey(uint keyid, uint version) outcome.GetError().GetMessage().c_str()); return(-1); } + *result = outcome.GetResult().GetCiphertextBlob(); + return 0; +} + + +static int generate_encrypted_key(Aws::Utils::ByteBuffer *output) +{ +#if WITH_AWS_MOCK + if(mock) + return mock_generate_encrypted_key(output); +#endif + return aws_generate_encrypted_key(output); +} + +/* Generate a new datakey and store it a file */ +static int generate_and_save_datakey(uint keyid, uint version) +{ + Aws::Utils::ByteBuffer byteBuffer; + + if (generate_encrypted_key(&byteBuffer)) + return -1; string out; char filename[20]; - Aws::Utils::ByteBuffer byteBuffer = outcome.GetResult().GetCiphertextBlob(); - format_keyfile_name(filename, sizeof(filename), keyid, version); int fd= open(filename, O_WRONLY |O_CREAT|O_BINARY, IF_WIN(_S_IREAD, S_IRUSR| S_IRGRP| S_IROTH)); if (fd < 0) @@ -438,7 +552,7 @@ static int rotate_single_key(uint key_id) my_printf_error(ER_UNKNOWN_ERROR, "key %u does not exist", MYF(ME_JUST_WARNING), key_id); return -1; } - else if (aws_generate_datakey(key_id, ver + 1)) + else if (generate_and_save_datakey(key_id, ver + 1)) { my_printf_error(ER_UNKNOWN_ERROR, "Could not generate datakey for key id= %u, ver= %u", MYF(ME_JUST_WARNING), key_id, ver); @@ -594,6 +708,13 @@ static MYSQL_SYSVAR_STR(region, region, "AWS region. For example us-east-1, or eu-central-1. If no value provided, SDK default is used.", NULL, NULL, ""); +#if WITH_AWS_MOCK +static MYSQL_SYSVAR_BOOL(mock, mock, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Mock AWS KMS calls (for testing).", + NULL, NULL, 0); +#endif + static struct st_mysql_sys_var* settings[]= { MYSQL_SYSVAR(master_key_id), MYSQL_SYSVAR(key_spec), @@ -601,6 +722,9 @@ static struct st_mysql_sys_var* settings[]= { MYSQL_SYSVAR(log_level), MYSQL_SYSVAR(request_timeout), MYSQL_SYSVAR(region), +#if WITH_AWS_MOCK + MYSQL_SYSVAR(mock), +#endif NULL }; diff --git a/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf b/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf index 4af933f1633..70682178ca1 100644 --- a/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf +++ b/plugin/wsrep_info/mysql-test/wsrep_info/my.cnf @@ -8,8 +8,6 @@ innodb-autoinc-lock-mode=2 innodb-locks-unsafe-for-binlog=1 wsrep-cluster-address=gcomm:// wsrep_provider=@ENV.WSREP_PROVIDER -# enforce read-committed characteristics across the cluster -wsrep_causal_reads=ON [mysqld.1] #galera_port=@OPT.port diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 466bb46b382..7bfca799a77 100755 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -32,6 +32,22 @@ while [ $# -gt 0 ]; do case "$1" in '--address') readonly WSREP_SST_OPT_ADDR="$2" + # + # Break address string into host:port/path parts + # + if echo $WSREP_SST_OPT_ADDR | grep -qe '^\[.*\]' + then + # IPv6 notation + readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR/\]*/\]} + readonly WSREP_SST_OPT_HOST_UNESCAPED=$(echo $WSREP_SST_OPT_HOST | \ + cut -d '[' -f 2 | cut -d ']' -f 1) + else + # "traditional" notation + readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*} + fi + readonly WSREP_SST_OPT_PORT=$(echo $WSREP_SST_OPT_ADDR | \ + cut -d ']' -f 2 | cut -s -d ':' -f 2 | cut -d '/' -f 1) + readonly WSREP_SST_OPT_PATH=${WSREP_SST_OPT_ADDR#*/} shift ;; '--bypass') @@ -180,6 +196,11 @@ wsrep_log_error() wsrep_log "[ERROR] $*" } +wsrep_log_warning() +{ + wsrep_log "[WARNING] $*" +} + wsrep_log_info() { wsrep_log "[INFO] $*" @@ -213,3 +234,39 @@ wsrep_check_programs() return $ret } + +# +# user can specify xtrabackup specific settings that will be used during sst +# process like encryption, etc..... +# parse such configuration option. (group for xb settings is [sst] in my.cnf +# +# 1st param: group : name of the config file section, e.g. mysqld +# 2nd param: var : name of the variable in the section, e.g. server-id +# 3rd param: - : default value for the param +parse_cnf() +{ + local group=$1 + local var=$2 + local reval="" + + # print the default settings for given group using my_print_default. + # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin) + # then grep for needed variable + # finally get the variable value (if variables has been specified multiple time use the last value only) + + # look in group+suffix + if [[ -n $WSREP_SST_OPT_CONF_SUFFIX ]]; then + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF "${group}${WSREP_SST_OPT_CONF_SUFFIX}" | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) + fi + + # look in group + if [[ -z $reval ]]; then + reval=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) + fi + + # use default if we haven't found a value + if [[ -z $reval ]]; then + [[ -n $3 ]] && reval=$3 + fi + echo $reval +} diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index aaa82e1ed5c..f7f911ec1e8 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -30,6 +30,7 @@ local_ip() { [ "$1" = "127.0.0.1" ] && return 0 [ "$1" = "localhost" ] && return 0 + [ "$1" = "[::1]" ] && return 0 [ "$1" = "$(hostname -s)" ] && return 0 [ "$1" = "$(hostname -f)" ] && return 0 [ "$1" = "$(hostname -d)" ] && return 0 @@ -116,8 +117,9 @@ GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" |\ $MYSQL_CLIENT $AUTH -S$WSREP_SST_OPT_SOCKET --disable-reconnect --connect_timeout=10 |\ tail -1 | awk -F ' ' '{ print $2 }') -MYSQL="$MYSQL_CLIENT $AUTH -h$WSREP_SST_OPT_HOST -P$WSREP_SST_OPT_PORT "\ -"--disable-reconnect --connect_timeout=10" +MYSQL="$MYSQL_CLIENT --defaults-extra-file=$WSREP_SST_OPT_CONF "\ +"$AUTH -h${WSREP_SST_OPT_HOST_UNESCAPED:-$WSREP_SST_OPT_HOST} "\ +"-P$WSREP_SST_OPT_PORT --disable-reconnect --connect_timeout=10" # Check if binary logging is enabled on the joiner node. # Note: SELECT cannot be used at this point. diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 9e3d9560807..23ee3df5d40 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -135,9 +135,19 @@ fi WSREP_LOG_DIR=${WSREP_LOG_DIR:-""} # if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf if [ -z "$WSREP_LOG_DIR" ]; then - WSREP_LOG_DIR=$($MY_PRINT_DEFAULTS --mysqld \ - | grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' \ - | cut -b 29- ) + WSREP_LOG_DIR=$(parse_cnf mariadb-10.0 innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mysqld innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf server innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mariadb innodb_log_group_home_dir "") +fi +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mysqld-10.0 innodb_log_group_home_dir "") fi if [ -n "$WSREP_LOG_DIR" ]; then @@ -263,8 +273,8 @@ then [ "$OS" = "Linux" ] && count=$(grep -c processor /proc/cpuinfo) [ "$OS" = "Darwin" -o "$OS" = "FreeBSD" ] && count=$(sysctl -n hw.ncpu) - find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" -print0 | \ - xargs -I{} -0 -P $count \ + find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" \ + -print0 | xargs -I{} -0 -P $count \ rsync --owner --group --perms --links --specials \ --ignore-times --inplace --recursive --delete --quiet \ $WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \ @@ -326,9 +336,9 @@ then RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf" if [ -n "${MYSQL_TMP_DIR:-}" ] ; then - SILENT="log file = $MYSQL_TMP_DIR/rsynd.log" + SILENT="log file = $MYSQL_TMP_DIR/rsyncd.log" else - SILENT="" + SILENT="" fi cat << EOF > "$RSYNC_CONF" @@ -345,6 +355,7 @@ EOF # rm -rf "$DATA"/ib_logfile* # we don't want old logs around + readonly RSYNC_PORT=${WSREP_SST_OPT_PORT:-4444} # If the IP is local listen only in it if is_local_ip $RSYNC_ADDR then @@ -362,7 +373,7 @@ EOF sleep 0.2 done - echo "ready $ADDR/$MODULE" + echo "ready $WSREP_SST_OPT_HOST:$RSYNC_PORT/$MODULE" # wait for SST to complete by monitoring magic file while [ ! -r "$MAGIC_FILE" ] && check_pid "$RSYNC_PID" && \ diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 565e62e4dbe..78a7d76da09 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -35,6 +35,7 @@ XTRABACKUP_PID="" SST_PORT="" REMOTEIP="" REMOTEHOST="" +tca="" tcert="" tpem="" tkey="" @@ -48,7 +49,6 @@ rlimit="" # Initially stagemsg="${WSREP_SST_OPT_ROLE}" cpat="" -speciald=1 ib_home_dir="" ib_log_dir="" ib_undo_dir="" @@ -72,6 +72,11 @@ xtmpdir="" scomp="" sdecomp="" +ssl_dhparams="" + +ssl_cert="" +ssl_ca="" +ssl_key="" # Required for backup locks # For backup locks it is 1 sent by joiner @@ -151,6 +156,10 @@ get_keys() if [[ -z $ekey ]];then ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile" else + wsrep_log_warning "Using the 'encrypt-key' option causes the encryption key" + wsrep_log_warning "to be set via the command-line and is considered insecure." + wsrep_log_warning "It is recommended to use the 'encrypt-key-file' option instead." + ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey" fi @@ -161,6 +170,86 @@ get_keys() stagemsg+="-XB-Encrypted" } +# +# If the ssl_dhparams variable is already set, uses that as a source +# of dh parameters for OpenSSL. Otherwise, looks for dhparams.pem in the +# datadir, and creates it there if it can't find the file. +# No input parameters +# +check_for_dhparams() +{ + if [[ -z "$ssl_dhparams" ]]; then + if ! [[ -r "$DATA/dhparams.pem" ]]; then + wsrep_check_programs openssl + wsrep_log_info "Could not find dhparams file, creating $DATA/dhparams.pem" + + if ! openssl dhparam -out "$DATA/dhparams.pem" 2048 >/dev/null 2>&1 + then + wsrep_log_error "******** FATAL ERROR ********************************* " + wsrep_log_error "* Could not create the dhparams.pem file with OpenSSL. " + wsrep_log_error "****************************************************** " + exit 22 + fi + fi + ssl_dhparams="$DATA/dhparams.pem" + fi +} + +# +# verifies that the certificate matches the private key +# doing this will save us having to wait for a timeout that would +# otherwise occur. +# +# 1st param: path to the cert +# 2nd param: path to the private key +# +verify_cert_matches_key() +{ + local cert_path=$1 + local key_path=$2 + + wsrep_check_programs openssl diff + + # generate the public key from the cert and the key + # they should match (otherwise we can't create an SSL connection) + if ! diff <(openssl x509 -in "$cert_path" -pubkey -noout) <(openssl rsa -in "$key_path" -pubout 2>/dev/null) >/dev/null 2>&1 + then + wsrep_log_error "******** FATAL ERROR ************************* " + wsrep_log_error "* The certifcate and private key do not match. " + wsrep_log_error "* Please check your certificate and key files. " + wsrep_log_error "********************************************** " + exit 22 + fi +} + +# Checks to see if the file exists +# If the file does not exist (or cannot be read), issues an error +# and exits +# +# 1st param: file name to be checked (for read access) +# 2nd param: 1st error message (header) +# 3rd param: 2nd error message (footer, optional) +# +verify_file_exists() +{ + local file_path=$1 + local error_message1=$2 + local error_message2=$3 + + if ! [[ -r "$file_path" ]]; then + wsrep_log_error "******** FATAL ERROR ************************* " + wsrep_log_error "* $error_message1 " + wsrep_log_error "* Could not find/access : $file_path " + + if ! [[ -z "$error_message2" ]]; then + wsrep_log_error "* $error_message2 " + fi + + wsrep_log_error "********************************************** " + exit 22 + fi +} + get_transfer() { if [[ -z $SST_PORT ]];then @@ -174,15 +263,25 @@ get_transfer() wsrep_log_error "nc(netcat) not found in path: $PATH" exit 2 fi + + if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then + wsrep_log_error "******** FATAL ERROR *********************** " + wsrep_log_error "* Using SSL encryption (encrypt= 2, 3, or 4) " + wsrep_log_error "* is not supported when using nc(netcat). " + wsrep_log_error "******************************************** " + exit 22 + fi + wsrep_log_info "Using netcat as streamer" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then - if nc -h 2>&1 | grep -q ncat;then - tcmd="nc -l ${TSST_PORT}" + if nc -h 2>&1 | grep -q ncat; then + tcmd="nc $sockopt -l ${TSST_PORT}" else - tcmd="nc -dl ${TSST_PORT}" + tcmd="nc $sockopt -dl ${TSST_PORT}" fi else - tcmd="nc ${REMOTEIP} ${TSST_PORT}" + # netcat doesn't understand [] around IPv6 address + tcmd="nc ${REMOTEIP//[\[\]]/} ${TSST_PORT}" fi else tfmt='socat' @@ -192,74 +291,112 @@ get_transfer() exit 2 fi - if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then - wsrep_log_error "Encryption requested, but socat is not OpenSSL enabled (encrypt=$encrypt)" - exit 2 - fi + donor_extra="" + joiner_extra="" + if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then + if ! socat -V | grep -q WITH_OPENSSL; then + wsrep_log_error "******** FATAL ERROR ****************** " + wsrep_log_error "* socat is not openssl enabled. " + wsrep_log_error "* Unable to encrypt SST communications. " + wsrep_log_error "*************************************** " + exit 2 + fi - if [[ $encrypt -eq 2 ]];then - wsrep_log_info "Using openssl based encryption with socat: with crt and pem" - if [[ -z $tpem || -z $tcert ]];then - wsrep_log_error "Both PEM and CRT files required" - exit 22 + # Determine the socat version + SOCAT_VERSION=`socat -V 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1` + if [[ -z "$SOCAT_VERSION" ]]; then + wsrep_log_error "******** FATAL ERROR **************** " + wsrep_log_error "* Cannot determine the socat version. " + wsrep_log_error "************************************* " + exit 2 fi + + # socat versions < 1.7.3 will have 512-bit dhparams (too small) + # so create 2048-bit dhparams and send that as a parameter + # socat version >= 1.7.3, checks to see if the peername matches the hostname + # set commonname="" to disable the peername checks + # + if ! check_for_version "$SOCAT_VERSION" "1.7.3"; then + if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then + # dhparams check (will create ssl_dhparams if needed) + check_for_dhparams + joiner_extra=",dhparam=$ssl_dhparams" + fi + fi + if check_for_version "$SOCAT_VERSION" "1.7.3"; then + donor_extra=',commonname=""' + fi + fi + + if [[ $encrypt -eq 2 ]]; then + wsrep_log_warning "**** WARNING **** encrypt=2 is deprecated and will be removed in a future release" + wsrep_log_info "Using openssl based encryption with socat: with crt and ca" + + verify_file_exists "$tcert" "Both certificate and CA files are required." \ + "Please check the 'tcert' option. " + verify_file_exists "$tca" "Both certificate and CA files are required." \ + "Please check the 'tca' option. " + stagemsg+="-OpenSSL-Encrypted-2" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then - wsrep_log_info "Decrypting with cert=${tpem}, cafile=${tcert}" - tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio" + wsrep_log_info "Decrypting with CERT: $tcert, CA: $tca" + tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},cafile=${tca}${joiner_extra}${sockopt} stdio" else - wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}" - tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}" + wsrep_log_info "Encrypting with CERT: $tcert, CA: $tca" + tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tcert},cafile=${tca}${donor_extra}${sockopt}" fi elif [[ $encrypt -eq 3 ]];then + wsrep_log_warning "**** WARNING **** encrypt=3 is deprecated and will be removed in a future release" wsrep_log_info "Using openssl based encryption with socat: with key and crt" - if [[ -z $tpem || -z $tkey ]];then - wsrep_log_error "Both certificate and key files required" - exit 22 - fi + + verify_file_exists "$tcert" "Both certificate and key files are required." \ + "Please check the 'tcert' option. " + verify_file_exists "$tkey" "Both certificate and key files are required." \ + "Please check the 'tkey' option. " + stagemsg+="-OpenSSL-Encrypted-3" if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then - if [[ -z $tcert ]];then - wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, verify=0" + wsrep_log_info "Decrypting with CERT: $tcert, KEY: $tkey" + tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},key=${tkey},verify=0${joiner_extra}${sockopt} stdio" tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},verify=0${sockopt} stdio" else - wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}" - tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},cafile=${tcert}${sockopt} stdio" - fi + wsrep_log_info "Encrypting with CERT: $tcert, KEY: $tkey" + tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tcert},key=${tkey},verify=0${sockopt}" + fi + elif [[ $encrypt -eq 4 ]]; then + wsrep_log_info "Using openssl based encryption with socat: with key, crt, and ca" + + verify_file_exists "$ssl_ca" "CA, certificate, and key files are required." \ + "Please check the 'ssl-ca' option. " + verify_file_exists "$ssl_cert" "CA, certificate, and key files are required." \ + "Please check the 'ssl-cert' option. " + verify_file_exists "$ssl_key" "CA, certificate, and key files are required." \ + "Please check the 'ssl-key' option. " + + # Check to see that the key matches the cert + verify_cert_matches_key $ssl_cert $ssl_key + + stagemsg+="-OpenSSL-Encrypted-4" + if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then + wsrep_log_info "Decrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca" + tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${joiner_extra}${sockopt} stdio" else - if [[ -z $tcert ]];then - wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, verify=0" - tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}" - else - wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}" - tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}" - fi + wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca" + tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}" fi - else - if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then + else + if [[ $encrypt -eq 1 ]]; then + wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release" + fi + + if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio" else tcmd="socat -u stdio TCP:${REMOTEIP}:${TSST_PORT}${sockopt}" fi fi fi - -} - -parse_cnf() -{ - local group=$1 - local var=$2 - # print the default settings for given group using my_print_default. - # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin) - # then grep for needed variable - # finally get the variable value (if variables has been specified multiple time use the last value only) - reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) - if [[ -z $reval ]];then - [[ -n $3 ]] && reval=$3 - fi - echo $reval } get_footprint() @@ -309,15 +446,15 @@ read_cnf() { sfmt=$(parse_cnf sst streamfmt "xbstream") tfmt=$(parse_cnf sst transferfmt "socat") - tcert=$(parse_cnf sst tca "") - tpem=$(parse_cnf sst tcert "") + tca=$(parse_cnf sst tca "") + tcert=$(parse_cnf sst tcert "") tkey=$(parse_cnf sst tkey "") encrypt=$(parse_cnf sst encrypt 0) sockopt=$(parse_cnf sst sockopt "") progress=$(parse_cnf sst progress "") rebuild=$(parse_cnf sst rebuild 0) ttime=$(parse_cnf sst time 0) - cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$') + cpat=$(parse_cnf sst cpat '.*\.pem$\|.*init\.ok$\|.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$') ealgo=$(parse_cnf xtrabackup encrypt "") ekey=$(parse_cnf xtrabackup encrypt-key "") ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "") @@ -331,9 +468,23 @@ read_cnf() ekey=$(parse_cnf sst encrypt-key "") ekeyfile=$(parse_cnf sst encrypt-key-file "") fi + + # Pull the parameters needed for encrypt=4 + ssl_ca=$(parse_cnf sst ssl-ca "") + if [[ -z "$ssl_ca" ]]; then + ssl_ca=$(parse_cnf mysqld ssl-ca "") + fi + ssl_cert=$(parse_cnf sst ssl-cert "") + if [[ -z "$ssl_cert" ]]; then + ssl_cert=$(parse_cnf mysqld ssl-cert "") + fi + ssl_key=$(parse_cnf sst ssl-key "") + if [[ -z "$ssl_key" ]]; then + ssl_key=$(parse_cnf mysqld ssl-key "") + fi + rlimit=$(parse_cnf sst rlimit "") uextra=$(parse_cnf sst use-extra 0) - speciald=$(parse_cnf sst sst-special-dirs 1) iopts=$(parse_cnf sst inno-backup-opts "") iapts=$(parse_cnf sst inno-apply-opts "") impts=$(parse_cnf sst inno-move-opts "") @@ -342,13 +493,8 @@ read_cnf() ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}") ssystag+="-" - if [[ $speciald -eq 0 ]];then - wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1" - speciald=1 - fi - if [[ $ssyslog -ne -1 ]];then - if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then + if $MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then ssyslog=1 fi fi @@ -494,32 +640,30 @@ kill_xtrabackup() setup_ports() { if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then - SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }') - REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }') - REMOTEHOST=$(getent hosts $REMOTEIP | awk '{ print $2 }') - if [[ -z $REMOTEHOST ]];then - REMOTEHOST=$REMOTEIP - fi - lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }') - sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }') + SST_PORT=$WSREP_SST_OPT_PORT + REMOTEIP=$WSREP_SST_OPT_HOST + lsn=$(echo $WSREP_SST_OPT_PATH | awk -F '[/]' '{ print $2 }') + sst_ver=$(echo $WSREP_SST_OPT_PATH | awk -F '[/]' '{ print $3 }') else - SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $2 }') + SST_PORT=$WSREP_SST_OPT_PORT fi } -# waits ~10 seconds for nc to open the port and then reports ready +# waits ~1 minute for nc/socat to open the port and then reports ready # (regardless of timeout) wait_for_listen() { - local PORT=$1 - local ADDR=$2 + local HOST=$1 + local PORT=$2 local MODULE=$3 - for i in {1..50} + + for i in {1..300} do ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break sleep 0.2 done - echo "ready ${ADDR}/${MODULE}//$sst_ver" + + echo "ready ${HOST}:${PORT}/${MODULE}//$sst_ver" } check_extra() @@ -527,7 +671,7 @@ check_extra() local use_socket=1 if [[ $uextra -eq 1 ]];then if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then - local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) + local eport=$($MY_PRINT_DEFAULTS -c $WSREP_SST_OPT_CONF mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2) if [[ -n $eport ]];then # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. @@ -622,11 +766,64 @@ send_donor() } +# Returns the version string in a standardized format +# Input "1.2.3" => echoes "010203" +# Wrongly formatted values => echoes "000000" +normalize_version() +{ + local major=0 + local minor=0 + local patch=0 + + # Only parses purely numeric version numbers, 1.2.3 + # Everything after the first three values are ignored + if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then + major=${BASH_REMATCH[1]} + minor=${BASH_REMATCH[2]} + patch=${BASH_REMATCH[3]} + fi + + printf %02d%02d%02d $major $minor $patch +} + +# Compares two version strings +# The first parameter is the version to be checked +# The second parameter is the minimum version required +# Returns 1 (failure) if $1 >= $2, 0 (success) otherwise +check_for_version() +{ + local local_version_str="$( normalize_version $1 )" + local required_version_str="$( normalize_version $2 )" + + if [[ "$local_version_str" < "$required_version_str" ]]; then + return 1 + else + return 0 + fi +} + + if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then wsrep_log_error "innobackupex not in path: $PATH" exit 2 fi +# check the version, we require XB-2.4 to ensure that we can pass the +# datadir via the command-line option +XB_REQUIRED_VERSION="2.3.5" + +XB_VERSION=`$INNOBACKUPEX_BIN --version 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1` +if [[ -z $XB_VERSION ]]; then + wsrep_log_error "FATAL: Cannot determine the $INNOBACKUPEX_BIN version. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST" + exit 2 +fi + +if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then + wsrep_log_error "FATAL: The $INNOBACKUPEX_BIN version is $XB_VERSION. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST" + exit 2 +fi + + rm -f "${MAGIC_FILE}" if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then @@ -670,13 +867,13 @@ if [[ $ssyslog -eq 1 ]];then } INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply " - INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move " + INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} $disver $impts --datadir=${DATA} --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move " INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" fi else INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log" - INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log" + INNOMOVE="${INNOBACKUPEX_BIN} --defaults-file=${WSREP_SST_OPT_CONF} --defaults-group=mysqld${WSREP_SST_OPT_CONF_SUFFIX} $disver $impts --datadir=${DATA} --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log" INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log" fi @@ -718,15 +915,6 @@ then fi get_keys - if [[ $encrypt -eq 1 ]];then - if [[ -n $ekey ]];then - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey " - else - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile " - fi - fi - - check_extra wsrep_log_info "Streaming GTID file before SST" @@ -739,17 +927,17 @@ then if [[ $encrypt -eq 1 ]];then if [[ -n $scomp ]];then - tcmd=" $ecmd | $scomp | $tcmd " + tcmd=" \$ecmd | $scomp | $tcmd " else - tcmd=" $ecmd | $tcmd " + tcmd=" \$ecmd | $tcmd " fi elif [[ -n $scomp ]];then tcmd=" $scomp | $tcmd " fi - send_donor $DATA "${stagemsg}-gtid" + # Restore the transport commmand to its original state tcmd="$ttcmd" if [[ -n $progress ]];then get_footprint @@ -764,10 +952,16 @@ then wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}" - if [[ -n $scomp ]];then + # Add compression to the head of the stream (if specified) + if [[ -n $scomp ]]; then tcmd="$scomp | $tcmd" fi + # Add encryption to the head of the stream (if specified) + if [[ $encrypt -eq 1 ]]; then + tcmd=" \$ecmd | $tcmd " + fi + set +e timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )" set -e @@ -797,9 +991,9 @@ then get_keys if [[ $encrypt -eq 1 ]];then if [[ -n $scomp ]];then - tcmd=" $ecmd | $scomp | $tcmd " + tcmd=" \$ecmd | $scomp | $tcmd " else - tcmd=" $ecmd | $tcmd " + tcmd=" \$ecmd | $tcmd " fi elif [[ -n $scomp ]];then tcmd=" $scomp | $tcmd " @@ -824,7 +1018,6 @@ then stagemsg="Joiner-Recv" - sencrypted=1 nthreads=1 @@ -835,14 +1028,7 @@ then # May need xtrabackup_checkpoints later on rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile - ADDR=${WSREP_SST_OPT_ADDR} - if [ -z "${SST_PORT}" ] - then - SST_PORT=4444 - ADDR="$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $1 }'):${SST_PORT}" - fi - - wait_for_listen ${SST_PORT} ${ADDR} ${MODULE} & + wait_for_listen ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444} ${MODULE} & trap sig_joiner_cleanup HUP PIPE INT TERM trap cleanup_joiner EXIT @@ -855,9 +1041,9 @@ then get_keys if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then if [[ -n $sdecomp ]];then - strmcmd=" $sdecomp | $ecmd | $strmcmd" + strmcmd=" $sdecomp | \$ecmd | $strmcmd" else - strmcmd=" $ecmd | $strmcmd" + strmcmd=" \$ecmd | $strmcmd" fi elif [[ -n $sdecomp ]];then strmcmd=" $sdecomp | $strmcmd" diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index e5aacdc2092..59ef805a7f7 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -230,23 +230,35 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS) SET(_PLATFORM x64) ENDIF() + # Create a cmake script to generate import and export libs + # from a .def file + SET(CMAKE_CONFIGURABLE_FILE_CONTENT " + IF ((mysqld_lib.def IS_NEWER_THAN mysqld_lib.lib) OR + (mysqld_lib.def IS_NEWER_THAN mysqld_lib.exp)) + SET(ENV{VS_UNICODE_OUTPUT}) + EXECUTE_PROCESS ( + COMMAND \"${CMAKE_LINKER}\" /lib /NAME:mysqld.exe \"/DEF:${MYSQLD_DEF}\" /MACHINE:${_PLATFORM} + RESULT_VARIABLE ret) + IF(NOT ret EQUAL 0) + MESSAGE(FATAL_ERROR \"process failed ret=\${ret}\") + ENDIF() + ENDIF() + ") + + CONFIGURE_FILE( + ${PROJECT_SOURCE_DIR}/cmake/configurable_file_content.in + make_mysqld_lib.cmake) + ADD_CUSTOM_COMMAND( - OUTPUT ${MYSQLD_DEF} + OUTPUT ${MYSQLD_DEF} ${MYSQLD_LIB} ${MYSQLD_EXP} COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js ${_PLATFORM} /forLib ${LIB_LOCATIONS} > mysqld_lib.def.tmp COMMAND ${CMAKE_COMMAND} -E copy_if_different mysqld_lib.def.tmp mysqld_lib.def - COMMAND ${CMAKE_COMMAND} -E remove mysqld_lib.def.tmp + COMMAND ${CMAKE_COMMAND} -P make_mysqld_lib.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${MYSQLD_CORELIBS} ) - ADD_CUSTOM_COMMAND( - OUTPUT ${MYSQLD_LIB} - COMMAND lib - ARGS /NAME:mysqld.exe "/DEF:${MYSQLD_DEF}" "/MACHINE:${_PLATFORM}" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${MYSQLD_DEF} - ) ADD_CUSTOM_TARGET(gen_mysqld_lib DEPENDS ${MYSQLD_LIB}) ADD_LIBRARY(mysqld_import_lib UNKNOWN IMPORTED GLOBAL) SET_TARGET_PROPERTIES(mysqld_import_lib PROPERTIES IMPORTED_LOCATION ${MYSQLD_LIB}) @@ -263,7 +275,10 @@ IF(APPLE) ENDIF() IF(NOT WITHOUT_DYNAMIC_PLUGINS) - SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) + IF(NOT MSVC) + SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) + ENDIF() + GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS) IF(NOT mysqld_link_flags) SET(mysqld_link_flags) @@ -277,7 +292,6 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS) ENDIF() ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS) -SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) TARGET_LINK_LIBRARIES(mysqld sql) # Provide plugins with minimal set of libraries @@ -422,15 +436,15 @@ IF(WIN32 AND MYSQLD_EXECUTABLE) ENDIF() MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) ADD_CUSTOM_COMMAND( - OUTPUT initdb.dep - COMMAND ${CMAKE_COMMAND} - ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep + COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DEPENDS mysqld ) ADD_CUSTOM_TARGET(initial_database ALL - DEPENDS initdb.dep + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep ) INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data DESTINATION . COMPONENT DataFiles diff --git a/sql/handler.cc b/sql/handler.cc index 6f83175f16a..4fe8f658e77 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -73,6 +73,14 @@ KEY_CREATE_INFO default_key_create_info= ulong total_ha= 0; /* number of storage engines (from handlertons[]) that support 2pc */ ulong total_ha_2pc= 0; +#ifndef DBUG_OFF +/* + Number of non-mandatory 2pc handlertons whose initialization failed + to estimate total_ha_2pc value under supposition of the failures + have not occcured. +*/ +ulong failed_ha_2pc= 0; +#endif /* size of savepoint storage area (see ha_init) */ ulong savepoint_alloc_size= 0; @@ -652,6 +660,10 @@ err_deinit: (void) plugin->plugin->deinit(NULL); err: +#ifndef DBUG_OFF + if (hton->prepare && hton->state == SHOW_OPTION_YES) + failed_ha_2pc++; +#endif my_free(hton); err_no_hton_memory: plugin->data= NULL; @@ -1663,6 +1675,11 @@ int ha_rollback_trans(THD *thd, bool all) { // cannot happen my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); error=1; +#ifdef WITH_WSREP + WSREP_WARN("handlerton rollback failed, thd %lu %lld conf %d SQL %s", + thd->thread_id, thd->query_id, thd->wsrep_conflict_state, + thd->query()); +#endif /* WITH_WSREP */ } status_var_increment(thd->status_var.ha_rollback_count); ha_info_next= ha_info->next(); @@ -1857,7 +1874,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, { #ifndef DBUG_OFF char buf[XIDDATASIZE*4+6]; // see xid_to_str - sql_print_information("ignore xid %s", xid_to_str(buf, info->list+i)); + DBUG_PRINT("info", ("ignore xid %s", xid_to_str(buf, info->list+i))); #endif xid_cache_insert(info->list+i, XA_PREPARED); info->found_foreign_xids++; @@ -1874,19 +1891,31 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) { #ifndef DBUG_OFF - char buf[XIDDATASIZE*4+6]; // see xid_to_str - sql_print_information("commit xid %s", xid_to_str(buf, info->list+i)); + int rc= +#endif + hton->commit_by_xid(hton, info->list+i); +#ifndef DBUG_OFF + if (rc == 0) + { + char buf[XIDDATASIZE*4+6]; // see xid_to_str + DBUG_PRINT("info", ("commit xid %s", xid_to_str(buf, info->list+i))); + } #endif - hton->commit_by_xid(hton, info->list+i); } else { #ifndef DBUG_OFF - char buf[XIDDATASIZE*4+6]; // see xid_to_str - sql_print_information("rollback xid %s", - xid_to_str(buf, info->list+i)); + int rc= +#endif + hton->rollback_by_xid(hton, info->list+i); +#ifndef DBUG_OFF + if (rc == 0) + { + char buf[XIDDATASIZE*4+6]; // see xid_to_str + DBUG_PRINT("info", ("rollback xid %s", + xid_to_str(buf, info->list+i))); + } #endif - hton->rollback_by_xid(hton, info->list+i); } } if (got < info->len) @@ -1908,7 +1937,8 @@ int ha_recover(HASH *commit_list) /* commit_list and tc_heuristic_recover cannot be set both */ DBUG_ASSERT(info.commit_list==0 || tc_heuristic_recover==0); /* if either is set, total_ha_2pc must be set too */ - DBUG_ASSERT(info.dry_run || total_ha_2pc>(ulong)opt_bin_log); + DBUG_ASSERT(info.dry_run || + (failed_ha_2pc + total_ha_2pc) > (ulong)opt_bin_log); if (total_ha_2pc <= (ulong)opt_bin_log) DBUG_RETURN(0); diff --git a/sql/init.h b/sql/init.h index 88cd8e6e178..af2621e5e70 100644 --- a/sql/init.h +++ b/sql/init.h @@ -19,6 +19,6 @@ #include "my_global.h" /* ulong */ void unireg_init(ulong options); -void unireg_end(void) __attribute__((noreturn)); +ATTRIBUTE_NORETURN void unireg_end(void); #endif /* INIT_INCLUDED */ diff --git a/sql/log.cc b/sql/log.cc index 766f45182a5..cb789e7f9f3 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -9353,8 +9353,10 @@ int TC_LOG_BINLOG::open(const char *opt_name) if (using_heuristic_recover()) { + mysql_mutex_lock(&LOCK_log); /* generate a new binlog to mask a corrupted one */ open(opt_name, LOG_BIN, 0, 0, WRITE_CACHE, max_binlog_size, 0, TRUE); + mysql_mutex_unlock(&LOCK_log); cleanup(); return 1; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6f9490826a7..82052445b3c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1566,7 +1566,7 @@ static void close_server_sock(); static void clean_up_mutexes(void); static void wait_for_signal_thread_to_end(void); static void create_pid_file(); -static void mysqld_exit(int exit_code) __attribute__((noreturn)); +ATTRIBUTE_NORETURN static void mysqld_exit(int exit_code); #endif static void delete_pid_file(myf flags); static void end_ssl(); @@ -9312,8 +9312,29 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) } #ifdef WITH_WSREP case OPT_WSREP_CAUSAL_READS: - wsrep_causal_reads_update(&global_system_variables); + { + if (global_system_variables.wsrep_causal_reads) + { + WSREP_WARN("option --wsrep-causal-reads is deprecated"); + if (!(global_system_variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ)) + { + WSREP_WARN("--wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=%u. " + "WSREP_SYNC_WAIT_BEFORE_READ is on", + global_system_variables.wsrep_sync_wait); + global_system_variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; + } + } + else + { + if (global_system_variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ) { + WSREP_WARN("--wsrep-sync-wait=%u takes precedence over --wsrep-causal-reads=OFF. " + "WSREP_SYNC_WAIT_BEFORE_READ is on", + global_system_variables.wsrep_sync_wait); + global_system_variables.wsrep_causal_reads = 1; + } + } break; + } case OPT_WSREP_SYNC_WAIT: global_system_variables.wsrep_causal_reads= MY_TEST(global_system_variables.wsrep_sync_wait & diff --git a/sql/mysqld.h b/sql/mysqld.h index 98fc58e07c5..aa08f77d468 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -711,7 +711,7 @@ enum enum_query_type /* query_id */ extern query_id_t global_query_id; -void unireg_end(void) __attribute__((noreturn)); +ATTRIBUTE_NORETURN void unireg_end(void); /* increment query_id and return it. */ inline __attribute__((warn_unused_result)) query_id_t next_query_id() diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index efcc9a3f0b2..6e21d6249ab 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -204,6 +204,10 @@ extern "C" sig_handler handle_fatal_signal(int sig) case KILL_SLAVE_SAME_ID: kreason= "KILL_SLAVE_SAME_ID"; break; + case KILL_WAIT_TIMEOUT: + case KILL_WAIT_TIMEOUT_HARD: + kreason= "KILL_WAIT_TIMEOUT"; + break; } my_safe_printf_stderr("%s", "\n" "Trying to get some variables.\n" diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d196b072705..6adadf8f377 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -891,6 +891,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) wsrep_info[sizeof(wsrep_info) - 1] = '\0'; /* make sure it is 0-terminated */ wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; wsrep_affected_rows = 0; + wsrep_replicate_GTID = false; + wsrep_skip_wsrep_GTID = false; #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1336,6 +1338,8 @@ void THD::init(void) wsrep_TOI_pre_query_len = 0; wsrep_sync_wait_gtid = WSREP_GTID_UNDEFINED; wsrep_affected_rows = 0; + wsrep_replicate_GTID = false; + wsrep_skip_wsrep_GTID = false; #endif /* WITH_WSREP */ if (variables.sql_log_bin) @@ -2054,6 +2058,9 @@ int THD::killed_errno() DBUG_RETURN(ER_SERVER_SHUTDOWN); case KILL_SLAVE_SAME_ID: DBUG_RETURN(ER_SLAVE_SAME_ID); + case KILL_WAIT_TIMEOUT: + case KILL_WAIT_TIMEOUT_HARD: + DBUG_RETURN(ER_NET_READ_INTERRUPTED); } DBUG_RETURN(0); // Keep compiler happy } diff --git a/sql/sql_class.h b/sql/sql_class.h index 1872cd9c1a8..d3b59be2ce1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -477,6 +477,11 @@ enum killed_state KILL_SYSTEM_THREAD_HARD= 15, KILL_SERVER= 16, KILL_SERVER_HARD= 17, + /* + Used in threadpool to signal wait timeout. + */ + KILL_WAIT_TIMEOUT= 18, + KILL_WAIT_TIMEOUT_HARD= 19 }; @@ -4394,6 +4399,8 @@ public: bool wsrep_ignore_table; wsrep_gtid_t wsrep_sync_wait_gtid; ulong wsrep_affected_rows; + bool wsrep_replicate_GTID; + bool wsrep_skip_wsrep_GTID; #endif /* WITH_WSREP */ /* Handling of timeouts for commands */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 48d8df2c6d6..832079c964f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3624,6 +3624,7 @@ mysql_execute_command(THD *thd) #endif case SQLCOM_SHOW_STATUS: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); execute_show_status(thd, all_tables); break; } @@ -3662,21 +3663,21 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_TABLE_STATUS: case SQLCOM_SHOW_OPEN_TABLES: case SQLCOM_SHOW_GENERIC: + case SQLCOM_SHOW_PLUGINS: case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_KEYS: - case SQLCOM_SELECT: - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) - goto error; - /* fall through */ - case SQLCOM_SHOW_PLUGINS: case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SHOW_PROFILE: - { + case SQLCOM_SELECT: + { #ifdef WITH_WSREP - DBUG_ASSERT(thd->wsrep_exec_mode != REPL_RECV); + if (lex->sql_command == SQLCOM_SELECT) + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ) + else + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW) #endif /* WITH_WSREP */ thd->status_var.last_query_cost= 0.0; @@ -3805,6 +3806,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_RELAYLOG_EVENTS: /* fall through */ case SQLCOM_SHOW_BINLOG_EVENTS: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (check_global_access(thd, REPL_SLAVE_ACL)) goto error; res = mysql_show_binlog_events(thd); @@ -4385,6 +4387,7 @@ end_with_restore_list: { if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL)) goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res = show_binlogs(thd); break; } @@ -4392,15 +4395,13 @@ end_with_restore_list: #endif /* EMBEDDED_LIBRARY */ case SQLCOM_SHOW_CREATE: { - DBUG_ASSERT(first_table == all_tables && first_table != 0); + DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS my_message(ER_NOT_ALLOWED_COMMAND, ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */ goto error; #else - - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) - goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); /* Access check: @@ -4463,8 +4464,7 @@ end_with_restore_list: case SQLCOM_CHECKSUM: { DBUG_ASSERT(first_table == all_tables && first_table != 0); - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) - goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); if (check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)) @@ -4475,6 +4475,7 @@ end_with_restore_list: } case SQLCOM_UPDATE: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); ha_rows found= 0, updated= 0; DBUG_ASSERT(first_table == all_tables && first_table != 0); if (WSREP_CLIENT(thd) && @@ -4517,9 +4518,7 @@ end_with_restore_list: /* if we switched from normal update, rights are checked */ if (up_result != 2) { - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) - goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); if ((res= multi_update_precheck(thd, all_tables))) break; } @@ -4589,10 +4588,6 @@ end_with_restore_list: break; } case SQLCOM_REPLACE: - { - if (WSREP_CLIENT(thd) && - wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) - goto error; #ifndef DBUG_OFF if (mysql_bin_log.is_open()) { @@ -4627,10 +4622,10 @@ end_with_restore_list: DBUG_PRINT("debug", ("Just after generate_incident()")); } #endif - } /* fall through */ case SQLCOM_INSERT: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); DBUG_ASSERT(first_table == all_tables && first_table != 0); if (WSREP_CLIENT(thd) && @@ -4689,6 +4684,7 @@ end_with_restore_list: case SQLCOM_REPLACE_SELECT: case SQLCOM_INSERT_SELECT: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE); select_result *sel_result; bool explain= MY_TEST(lex->describe); DBUG_ASSERT(first_table == all_tables && first_table != 0); @@ -4812,6 +4808,7 @@ end_with_restore_list: } case SQLCOM_DELETE: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); select_result *sel_result=lex->result; DBUG_ASSERT(first_table == all_tables && first_table != 0); if (WSREP_CLIENT(thd) && @@ -4872,6 +4869,7 @@ end_with_restore_list: } case SQLCOM_DELETE_MULTI: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); DBUG_ASSERT(first_table == all_tables && first_table != 0); TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first; multi_delete *result; @@ -4953,19 +4951,6 @@ end_with_restore_list: /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */ thd->variables.option_bits|= OPTION_KEEP_LOG; } - if (WSREP(thd)) - { - for (TABLE_LIST *table= all_tables; table; table= table->next_global) - { - if (!lex->tmp_table() && - (!thd->is_current_stmt_binlog_format_row() || - !thd->find_temporary_table(table))) - { - WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); - break; - } - } - } /* If we are a slave, we should add IF EXISTS if the query executed on the master without an error. This will help a slave to @@ -4975,6 +4960,20 @@ end_with_restore_list: if (thd->slave_thread && !thd->slave_expected_error && slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) lex->create_info.set(DDL_options_st::OPT_IF_EXISTS); + + if (WSREP(thd)) + { + for (TABLE_LIST *table= all_tables; table; table= table->next_global) + { + if (!lex->tmp_table() && + (!thd->is_current_stmt_binlog_format_row() || + !thd->find_temporary_table(table))) + { + WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables); + break; + } + } + } /* DDL and binlog write order are protected by metadata locks. */ res= mysql_rm_table(thd, first_table, lex->if_exists(), lex->tmp_table(), @@ -5219,9 +5218,7 @@ end_with_restore_list: db_name.length= lex->name.length; strmov(db_name_buff, lex->name.str); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (check_db_name((LEX_STRING*) &db_name)) { @@ -5276,9 +5273,7 @@ end_with_restore_list: /* lex->unit.cleanup() is called outside, no need to call it here */ break; case SQLCOM_SHOW_CREATE_EVENT: -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res= Events::show_create_event(thd, &lex->spname->m_db, &lex->spname->m_name); break; @@ -5662,6 +5657,7 @@ end_with_restore_list: if (!grant_user) goto error; + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); res = mysql_show_grants(thd, grant_user); break; } @@ -5976,10 +5972,8 @@ end_with_restore_list: case SQLCOM_SHOW_CREATE_PROC: case SQLCOM_SHOW_CREATE_FUNC: { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); const Sp_handler *sph= Sp_handler::handler(lex->sql_command); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ if (sph->sp_show_create_routine(thd, lex->spname)) goto error; break; @@ -5990,9 +5984,7 @@ end_with_restore_list: #ifndef DBUG_OFF sp_head *sp; const Sp_handler *sph= Sp_handler::handler(lex->sql_command); -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (sph->sp_cache_routine(thd, lex->spname, false, &sp)) goto error; if (!sp || sp->show_routine_code(thd)) @@ -6014,9 +6006,7 @@ end_with_restore_list: if (check_ident_length(&lex->spname->m_name)) goto error; -#ifdef WITH_WSREP - if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); if (show_create_trigger(thd, lex->spname)) goto error; /* Error has been already logged. */ @@ -6477,6 +6467,7 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables) if (!(res= check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE))) res= execute_sqlcom_select(thd, all_tables); + /* Don't log SHOW STATUS commands to slow query log */ thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED); diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index ed330bcc7b9..bb4954914f0 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -777,7 +777,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd) (!thd->is_current_stmt_binlog_format_row() || !thd->find_temporary_table(first_table)) && wsrep_to_isolation_begin( - thd, first_table->db, first_table->table_name, NULL) + thd, first_table->db, first_table->table_name, NULL) ) { WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure"); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e70331d9f24..8d4789d0efe 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2091,6 +2091,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists, DBUG_RETURN(TRUE); my_ok(thd); DBUG_RETURN(FALSE); + } @@ -2137,7 +2138,6 @@ static uint32 comment_length(THD *thd, uint32 comment_pos, return 0; } - /** Execute the drop of a normal or temporary table. @@ -2573,6 +2573,9 @@ err: /* Chop of the last comma */ built_non_trans_tmp_query.chop(); built_non_trans_tmp_query.append(" /* generated by server */"); +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = true; +#endif /* WITH_WSREP */ error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_non_trans_tmp_query.ptr(), built_non_trans_tmp_query.length(), @@ -2585,6 +2588,9 @@ err: /* Chop of the last comma */ built_trans_tmp_query.chop(); built_trans_tmp_query.append(" /* generated by server */"); +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = true; +#endif /* WITH_WSREP */ error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_trans_tmp_query.ptr(), built_trans_tmp_query.length(), @@ -2599,6 +2605,9 @@ err: built_query.append(" /* generated by server */"); int error_code = non_tmp_error ? thd->get_stmt_da()->sql_errno() : 0; +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = false; +#endif /* WITH_WSREP */ error |= thd->binlog_query(THD::STMT_QUERY_TYPE, built_query.ptr(), built_query.length(), @@ -2647,6 +2656,9 @@ err: } end: +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = false; +#endif /* WITH_WSREP */ DBUG_RETURN(error); } @@ -7566,9 +7578,26 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, { if (def->change.str && ! def->field) { - my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change.str, - table->s->table_name.str); - goto err; + /* + Check if there is modify for newly added field. + */ + Create_field *find; + find_it.rewind(); + while((find=find_it++)) + { + if (!my_strcasecmp(system_charset_info,find->field_name.str, + def->field_name.str)) + break; + } + + if (find && !find->field) + find_it.remove(); + else + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change.str, + table->s->table_name.str); + goto err; + } } /* Check that the DATE/DATETIME not null field we are going to add is @@ -7636,6 +7665,30 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, find_it.after(def); // Put column after this } } + /* + Check if there is alter for newly added field. + */ + alter_it.rewind(); + Alter_column *alter; + while ((alter=alter_it++)) + { + if (!my_strcasecmp(system_charset_info,def->field_name.str, + alter->name)) + break; + } + if (alter) + { + if (def->real_field_type() == MYSQL_TYPE_BLOB) + { + my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change); + goto err; + } + if ((def->default_value= alter->default_value)) // Use new default + def->flags&= ~NO_DEFAULT_VALUE_FLAG; + else + def->flags|= NO_DEFAULT_VALUE_FLAG; + alter_it.remove(); + } } if (alter_info->alter_list.elements) { diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7181e7ff3b8..ba07a50319b 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4937,7 +4937,7 @@ static Sys_var_ulong Sys_wsrep_slave_threads( GLOBAL_VAR(wsrep_slave_threads), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1, 512), DEFAULT(1), BLOCK_SIZE(1), &PLock_wsrep_slave_threads, NOT_IN_BINLOG, - ON_CHECK(wsrep_slave_threads_check), + ON_CHECK(NULL), ON_UPDATE(wsrep_slave_threads_update)); static Sys_var_charptr Sys_wsrep_dbug_option( @@ -5049,21 +5049,13 @@ static Sys_var_mybool Sys_wsrep_certify_nonPK( GLOBAL_VAR(wsrep_certify_nonPK), CMD_LINE(OPT_ARG), DEFAULT(TRUE)); -static bool fix_wsrep_causal_reads(sys_var *self, THD* thd, enum_var_type var_type) -{ - if (var_type == OPT_GLOBAL) - wsrep_causal_reads_update(&global_system_variables); - else - wsrep_causal_reads_update(&thd->variables); - return false; -} static Sys_var_mybool Sys_wsrep_causal_reads( "wsrep_causal_reads", "Setting this variable is equivalent " "to setting wsrep_sync_wait READ flag", SESSION_VAR(wsrep_causal_reads), CMD_LINE(OPT_ARG, OPT_WSREP_CAUSAL_READS), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), - ON_UPDATE(fix_wsrep_causal_reads), + ON_UPDATE(wsrep_causal_reads_update), DEPRECATED("'@@wsrep_sync_wait=1'")); static Sys_var_uint Sys_wsrep_sync_wait( diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index c6a3c7e44f8..598951da406 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -308,6 +308,24 @@ static void threadpool_remove_connection(THD *thd) my_thread_end(); } + +/* + Ensure that proper error message is sent to client, + and "aborted" message appears in the log in case of + wait timeout. + + See also timeout handling in net_serv.cc +*/ +static void handle_wait_timeout(THD *thd) +{ + thd->get_stmt_da()->reset_diagnostics_area(); + thd->reset_killed(); + my_error(ER_NET_READ_INTERRUPTED, MYF(0)); + thd->net.last_errno= ER_NET_READ_INTERRUPTED; + thd->net.error= 2; +} + + /** Process a single client request or a single batch. */ @@ -323,6 +341,8 @@ static int threadpool_process_request(THD *thd) or KILL command. Return error. */ retval= 1; + if(thd->killed == KILL_WAIT_TIMEOUT) + handle_wait_timeout(thd); goto end; } @@ -458,7 +478,7 @@ void tp_timeout_handler(TP_connection *c) return; THD *thd=c->thd; mysql_mutex_lock(&thd->LOCK_thd_data); - thd->killed= KILL_CONNECTION; + thd->set_killed(KILL_WAIT_TIMEOUT); c->priority= TP_PRIORITY_HIGH; post_kill_notification(thd); mysql_mutex_unlock(&thd->LOCK_thd_data); diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index cef59513485..a299ddf074f 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -217,12 +217,15 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx, { THD* const thd((THD*)ctx); + assert(thd->wsrep_apply_toi == false); + // Allow tests to block the applier thread using the DBUG facilities. DBUG_EXECUTE_IF("sync.wsrep_apply_cb", { const char act[]= "now " - "wait_for signal.wsrep_apply_cb"; + "SIGNAL sync.wsrep_apply_cb_reached " + "WAIT_FOR signal.wsrep_apply_cb"; DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); @@ -382,7 +385,7 @@ wsrep_cb_status_t wsrep_commit_cb(void* const ctx, mysql_mutex_unlock(&LOCK_wsrep_slave_threads); } - if (*exit == false && thd->wsrep_applier) + if (thd->wsrep_applier) { /* From trans_begin() */ thd->variables.option_bits|= OPTION_BEGIN; diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 1121bb65fe3..1063b82fb8a 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -42,6 +42,7 @@ void wsrep_cleanup_transaction(THD *thd) thd->wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED; thd->wsrep_exec_mode= LOCAL_STATE; thd->wsrep_affected_rows= 0; + thd->wsrep_skip_wsrep_GTID= false; return; } diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 4c0a5570f16..02d0ee50e6b 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2,7 +2,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. + the Free Software Foundation; version 2 of the License.x1 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,6 +16,7 @@ #include <mysqld.h> #include <sql_class.h> #include <sql_parse.h> +#include <sql_base.h> /* find_temporary_table() */ #include "slave.h" #include "rpl_mi.h" #include "sql_repl.h" @@ -983,8 +984,6 @@ bool wsrep_must_sync_wait (THD* thd, uint mask) { return (thd->variables.wsrep_sync_wait & mask) && thd->variables.wsrep_on && - !(thd->variables.wsrep_dirty_reads && - !is_update_query(thd->lex->sql_command)) && !thd->in_active_multi_stmt_transaction() && thd->wsrep_conflict_state != REPLAYING && thd->wsrep_sync_wait_gtid.seqno == WSREP_SEQNO_UNDEFINED; @@ -1113,83 +1112,70 @@ static bool wsrep_prepare_keys_for_isolation(THD* thd, const TABLE_LIST* table_list, wsrep_key_arr_t* ka) { - ka->keys= 0; - ka->keys_len= 0; + ka->keys= 0; + ka->keys_len= 0; - if (db || table) + if (db || table) + { + if (!(ka->keys= (wsrep_key_t*)my_malloc(sizeof(wsrep_key_t), MYF(0)))) + { + WSREP_ERROR("Can't allocate memory for key_array"); + goto err; + } + ka->keys_len= 1; + if (!(ka->keys[0].key_parts= (wsrep_buf_t*) + my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) { - TABLE_LIST tmp_table; + WSREP_ERROR("Can't allocate memory for key_parts"); + goto err; + } + ka->keys[0].key_parts_num= 2; + if (!wsrep_prepare_key_for_isolation( + db, table, + (wsrep_buf_t*)ka->keys[0].key_parts, + &ka->keys[0].key_parts_num)) + { + WSREP_ERROR("Preparing keys for isolation failed (1)"); + goto err; + } + } - memset(&tmp_table, 0, sizeof(tmp_table)); - tmp_table.table_name= (char*)table; - tmp_table.db= (char*)db; - tmp_table.mdl_request.init(MDL_key::GLOBAL, (db) ? db : "", - (table) ? table : "", - MDL_INTENTION_EXCLUSIVE, MDL_STATEMENT); + for (const TABLE_LIST* table= table_list; table; table= table->next_global) + { + wsrep_key_t* tmp; + if (ka->keys) + tmp= (wsrep_key_t*)my_realloc(ka->keys, + (ka->keys_len + 1) * sizeof(wsrep_key_t), + MYF(0)); + else + tmp= (wsrep_key_t*)my_malloc((ka->keys_len + 1) * sizeof(wsrep_key_t), MYF(0)); - if (!table || !thd->find_temporary_table(&tmp_table)) - { - if (!(ka->keys= (wsrep_key_t*)my_malloc(sizeof(wsrep_key_t), MYF(0)))) - { - WSREP_ERROR("Can't allocate memory for key_array"); - goto err; - } - ka->keys_len= 1; - if (!(ka->keys[0].key_parts= (wsrep_buf_t*) - my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) - { - WSREP_ERROR("Can't allocate memory for key_parts"); - goto err; - } - ka->keys[0].key_parts_num= 2; - if (!wsrep_prepare_key_for_isolation( - db, table, - (wsrep_buf_t*)ka->keys[0].key_parts, - &ka->keys[0].key_parts_num)) - { - WSREP_ERROR("Preparing keys for isolation failed"); - goto err; - } - } + if (!tmp) + { + WSREP_ERROR("Can't allocate memory for key_array"); + goto err; } - - for (const TABLE_LIST* table= table_list; table; table= table->next_global) + ka->keys= tmp; + if (!(ka->keys[ka->keys_len].key_parts= (wsrep_buf_t*) + my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) { - if (!thd->find_temporary_table(table)) - { - wsrep_key_t* tmp; - tmp= (wsrep_key_t*)my_realloc( - ka->keys, (ka->keys_len + 1) * sizeof(wsrep_key_t), - MYF(MY_ALLOW_ZERO_PTR)); - - if (!tmp) - { - WSREP_ERROR("Can't allocate memory for key_array"); - goto err; - } - ka->keys= tmp; - if (!(ka->keys[ka->keys_len].key_parts= (wsrep_buf_t*) - my_malloc(sizeof(wsrep_buf_t)*2, MYF(0)))) - { - WSREP_ERROR("Can't allocate memory for key_parts"); - goto err; - } - ka->keys[ka->keys_len].key_parts_num= 2; - ++ka->keys_len; - if (!wsrep_prepare_key_for_isolation( - table->db, table->table_name, - (wsrep_buf_t*)ka->keys[ka->keys_len - 1].key_parts, - &ka->keys[ka->keys_len - 1].key_parts_num)) - { - WSREP_ERROR("Preparing keys for isolation failed"); - goto err; - } - } + WSREP_ERROR("Can't allocate memory for key_parts"); + goto err; } - return true; + ka->keys[ka->keys_len].key_parts_num= 2; + ++ka->keys_len; + if (!wsrep_prepare_key_for_isolation(table->db, table->table_name, + (wsrep_buf_t*)ka->keys[ka->keys_len - 1].key_parts, + &ka->keys[ka->keys_len - 1].key_parts_num)) + { + WSREP_ERROR("Preparing keys for isolation failed (2)"); + goto err; + } + } + return 0; err: wsrep_keys_free(ka); - return false; + return 1; } @@ -1404,6 +1390,84 @@ static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len); static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len); /* + Decide if statement should run in TOI. + + Look if table or table_list contain temporary tables. If the + statement affects only temporary tables, statement should not run + in TOI. If the table list contains mix of regular and temporary tables + (DROP TABLE, OPTIMIZE, ANALYZE), statement should be run in TOI but + should be rewritten at later time for replication to contain only + non-temporary tables. + */ +static bool wsrep_can_run_in_toi(THD *thd, const char *db, const char *table, + const TABLE_LIST *table_list) +{ + DBUG_ASSERT(!table || db); + DBUG_ASSERT(table_list || db); + + LEX* lex= thd->lex; + SELECT_LEX* select_lex= &lex->select_lex; + TABLE_LIST* first_table= select_lex->table_list.first; + + switch (lex->sql_command) + { + case SQLCOM_CREATE_TABLE: + DBUG_ASSERT(!table_list); + if (thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) + { + return false; + } + return true; + + case SQLCOM_CREATE_VIEW: + + DBUG_ASSERT(!table_list); + DBUG_ASSERT(first_table); /* First table is view name */ + /* + If any of the remaining tables refer to temporary table error + is returned to client, so TOI can be skipped + */ + for (TABLE_LIST* it= first_table->next_global; it; it= it->next_global) + { + if (thd->find_temporary_table(it)) + { + return false; + } + } + return true; + + case SQLCOM_CREATE_TRIGGER: + + DBUG_ASSERT(!table_list); + DBUG_ASSERT(first_table); + + if (thd->find_temporary_table(first_table)) + { + return false; + } + return true; + + default: + if (table && !thd->find_temporary_table(db, table)) + { + return true; + } + + if (table_list) + { + for (TABLE_LIST* table= first_table; table; table= table->next_global) + { + if (!thd->find_temporary_table(table->db, table->table_name)) + { + return true; + } + } + } + return !(table || table_list); + } +} + +/* returns: 0: statement was replicated as TOI 1: TOI replication was skipped @@ -1418,6 +1482,12 @@ static int wsrep_TOI_begin(THD *thd, const char *db_, const char *table_, int buf_err; int rc= 0; + if (wsrep_can_run_in_toi(thd, db_, table_, table_list) == false) + { + WSREP_DEBUG("No TOI for %s", WSREP_QUERY(thd)); + return 1; + } + WSREP_DEBUG("TO BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd), thd->wsrep_exec_mode, thd->query() ); switch (thd->lex->sql_command) @@ -1445,16 +1515,16 @@ static int wsrep_TOI_begin(THD *thd, const char *db_, const char *table_, } /* fallthrough */ default: - buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf, - &buf_len); + buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), + &buf, &buf_len); break; } wsrep_key_arr_t key_arr= {0, 0}; struct wsrep_buf buff = { buf, buf_len }; - if (!buf_err && - wsrep_prepare_keys_for_isolation(thd, db_, table_, table_list, &key_arr)&& - key_arr.keys_len > 0 && + if (!buf_err && + !wsrep_prepare_keys_for_isolation(thd, db_, table_, table_list, &key_arr) && + key_arr.keys_len > 0 && WSREP_OK == (ret = wsrep->to_execute_start(wsrep, thd->thread_id, key_arr.keys, key_arr.keys_len, &buff, 1, @@ -1651,9 +1721,12 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_, if (thd->variables.wsrep_on && thd->wsrep_exec_mode==LOCAL_STATE) { switch (thd->variables.wsrep_OSU_method) { - case WSREP_OSU_TOI: ret = wsrep_TOI_begin(thd, db_, table_, - table_list); break; - case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); break; + case WSREP_OSU_TOI: + ret = wsrep_TOI_begin(thd, db_, table_, table_list); + break; + case WSREP_OSU_RSU: + ret = wsrep_RSU_begin(thd, db_, table_); + break; default: WSREP_ERROR("Unsupported OSU method: %lu", thd->variables.wsrep_OSU_method); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 7eae366df7a..cb8a943b3c6 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -99,11 +99,12 @@ enum enum_wsrep_OSU_method { enum enum_wsrep_sync_wait { WSREP_SYNC_WAIT_NONE = 0x0, - // show, select, begin + // select, begin WSREP_SYNC_WAIT_BEFORE_READ = 0x1, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE = 0x2, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE = 0x4, - WSREP_SYNC_WAIT_MAX = 0x7 + WSREP_SYNC_WAIT_BEFORE_SHOW = 0x8, + WSREP_SYNC_WAIT_MAX = 0xF }; // MySQL status variables @@ -223,6 +224,8 @@ extern wsrep_seqno_t wsrep_locked_seqno; #define WSREP_PROVIDER_EXISTS \ (wsrep_provider && strncasecmp(wsrep_provider, WSREP_NONE, FN_REFLEN)) +#define WSREP_QUERY(thd) (thd->query()) + extern void wsrep_ready_wait(); class Ha_trx_info; diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 076da23967a..05cf36fd9dc 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -746,7 +746,7 @@ ssize_t wsrep_sst_prepare (void** msg) // Attempt 1: wsrep_sst_receive_address if (wsrep_sst_receive_address && - strcmp (wsrep_sst_receive_address, WSREP_SST_ADDRESS_AUTO)) + strcmp (wsrep_sst_receive_address, WSREP_SST_ADDRESS_AUTO)) { addr_in= wsrep_sst_receive_address; } @@ -886,16 +886,13 @@ static int sst_donate_mysqldump (const char* addr, { char host[256]; wsp::Address address(addr); - if (!address.is_valid()) { WSREP_ERROR("Could not parse SST address : %s", addr); return 0; } - memcpy(host, address.get_address(), address.get_address_len()); int port= address.get_port(); - int const cmd_len= 4096; wsp::string cmd_str(cmd_len); @@ -912,7 +909,7 @@ static int sst_donate_mysqldump (const char* addr, int ret= snprintf (cmd_str(), cmd_len, "wsrep_sst_mysqldump " - WSREP_SST_OPT_HOST" '%s' " + WSREP_SST_OPT_ADDR" '%s' " WSREP_SST_OPT_PORT" '%d' " WSREP_SST_OPT_LPORT" '%u' " WSREP_SST_OPT_SOCKET" '%s' " @@ -920,7 +917,7 @@ static int sst_donate_mysqldump (const char* addr, WSREP_SST_OPT_GTID" '%s:%lld' " WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'" "%s", - host, port, mysqld_port, mysqld_unix_port, + addr, port, mysqld_port, mysqld_unix_port, wsrep_defaults_file, uuid_str, (long long)seqno, wsrep_gtid_domain_id, bypass ? " " WSREP_SST_OPT_BYPASS : ""); diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index 9c77cb49256..1a358877a35 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -573,3 +573,17 @@ done: return ret; } +/* returns the length of the host part of the address string */ +size_t wsrep_host_len(const char* const addr, size_t const addr_len) +{ + // check for IPv6 notation first + const char* const bracket= ('[' == addr[0] ? strchr(addr, ']') : NULL); + + if (bracket) { // IPv6 + return (bracket - addr + 1); + } + else { // host part ends at ':' or end of string + const char* const colon= strchr(addr, ':'); + return (colon ? colon - addr : addr_len); + } +} diff --git a/sql/wsrep_utils.h b/sql/wsrep_utils.h index e4f421930f4..277cea9dc31 100644 --- a/sql/wsrep_utils.h +++ b/sql/wsrep_utils.h @@ -22,6 +22,9 @@ unsigned int wsrep_check_ip (const char* const addr, bool *is_ipv6); size_t wsrep_guess_ip (char* buf, size_t buf_len); +/* returns the length of the host part of the address string */ +size_t wsrep_host_len(const char* addr, size_t addr_len); + namespace wsp { class Address { diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index d7f55dbca60..8107ab12c6b 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -27,6 +27,8 @@ #include <cstdlib> +static long wsrep_prev_slave_threads = wsrep_slave_threads; + int wsrep_init_vars() { wsrep_provider = my_strdup(WSREP_NONE, MYF(MY_WME)); @@ -49,12 +51,23 @@ bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type) return false; } -bool wsrep_causal_reads_update (SV *sv) +bool wsrep_causal_reads_update (sys_var *self, THD* thd, enum_var_type var_type) { - if (sv->wsrep_causal_reads) { - sv->wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; + // global setting should not affect session setting. + // if (var_type == OPT_GLOBAL) { + // thd->variables.wsrep_causal_reads = global_system_variables.wsrep_causal_reads; + // } + if (thd->variables.wsrep_causal_reads) { + thd->variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; + } else { + thd->variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; + } + + // update global settings too. + if (global_system_variables.wsrep_causal_reads) { + global_system_variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ; } else { - sv->wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; + global_system_variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ; } return false; @@ -62,12 +75,17 @@ bool wsrep_causal_reads_update (SV *sv) bool wsrep_sync_wait_update (sys_var* self, THD* thd, enum_var_type var_type) { - if (var_type == OPT_GLOBAL) - global_system_variables.wsrep_causal_reads = - MY_TEST(global_system_variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ); - else - thd->variables.wsrep_causal_reads = - MY_TEST(thd->variables.wsrep_sync_wait & WSREP_SYNC_WAIT_BEFORE_READ); + // global setting should not affect session setting. + // if (var_type == OPT_GLOBAL) { + // thd->variables.wsrep_sync_wait = global_system_variables.wsrep_sync_wait; + // } + thd->variables.wsrep_causal_reads = thd->variables.wsrep_sync_wait & + WSREP_SYNC_WAIT_BEFORE_READ; + + // update global settings too + global_system_variables.wsrep_causal_reads = global_system_variables.wsrep_sync_wait & + WSREP_SYNC_WAIT_BEFORE_READ; + return false; } @@ -528,18 +546,15 @@ void wsrep_node_address_init (const char* value) wsrep_node_address = (value) ? my_strdup(value, MYF(0)) : NULL; } -bool wsrep_slave_threads_check (sys_var *self, THD* thd, set_var* var) +static void wsrep_slave_count_change_update () { - mysql_mutex_lock(&LOCK_wsrep_slave_threads); - wsrep_slave_count_change += (var->save_result.ulonglong_value - - wsrep_slave_threads); - mysql_mutex_unlock(&LOCK_wsrep_slave_threads); - - return 0; + wsrep_slave_count_change += (wsrep_slave_threads - wsrep_prev_slave_threads); + wsrep_prev_slave_threads = wsrep_slave_threads; } bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type) { + wsrep_slave_count_change_update(); if (wsrep_slave_count_change > 0) { wsrep_create_appliers(wsrep_slave_count_change); diff --git a/sql/wsrep_var.h b/sql/wsrep_var.h index 1509fc7d589..dde59d1503f 100644 --- a/sql/wsrep_var.h +++ b/sql/wsrep_var.h @@ -41,9 +41,7 @@ int wsrep_init_vars(); #define DEFAULT_ARGS (THD* thd, enum_var_type var_type) #define INIT_ARGS (const char* opt) -struct system_variables; -bool wsrep_causal_reads_update(struct system_variables *sv); - +extern bool wsrep_causal_reads_update UPDATE_ARGS; extern bool wsrep_on_update UPDATE_ARGS; extern bool wsrep_sync_wait_update UPDATE_ARGS; extern bool wsrep_start_position_check CHECK_ARGS; diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index a5ec515011c..2fabd12dcd0 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -264,13 +264,6 @@ IF(CONNECT_WITH_JDBC) JdbcInterface.java ApacheInterface.java MariadbInterface.java MysqlInterface.java OracleInterface.java PostgresqlInterface.java JavaWrappers.jar) - # TODO: Find how to compile and install the java wrapper classes - # Find required libraries and include directories - SET (JAVA_SOURCES JdbcInterface.java) - add_jar(JdbcInterface ${JAVA_SOURCES}) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar - ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar - DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) add_definitions(-DJDBC_SUPPORT) IF(CONNECT_WITH_MONGO) SET(CONNECT_SOURCES ${CONNECT_SOURCES} @@ -348,4 +341,31 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY}) +IF(NOT TARGET connect) + RETURN() +ENDIF() + +# Install some extra files that belong to connect engine +IF(WIN32) + # install ha_connect.lib + GET_TARGET_PROPERTY(CONNECT_LOCATION connect LOCATION) + STRING(REPLACE "dll" "lib" CONNECT_LIB ${CONNECT_LOCATION}) + IF(CMAKE_CONFIGURATION_TYPES) + STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" + CONNECT_LIB ${CONNECT_LIB}) + ENDIF() + INSTALL(FILES ${CONNECT_LIB} + DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) +ENDIF(WIN32) + +IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND) + # TODO: Find how to compile and install the java wrapper classes + # Find required libraries and include directories + SET (JAVA_SOURCES JdbcInterface.java) + add_jar(JdbcInterface ${JAVA_SOURCES}) + INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar + ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar + DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) +ENDIF() diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 91c5adc4f07..061ff1ce2ac 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -150,14 +150,7 @@ SET(INNOBASE_SOURCES ut/ut0wqueue.cc ut/ut0timer.cc) -IF(WITH_INNODB) - # Legacy option - SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) -ENDIF() - MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE -# MODULE_ONLY -# MODULE_OUTPUT_NAME ha_innodb DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} @@ -166,8 +159,8 @@ MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE ${LIBSYSTEMD} ${LINKER_SCRIPT}) -IF(WITH_INNOBASE_STORAGE_ENGINE) - ADD_DEPENDENCIES(innobase GenError) +IF(NOT TARGET innobase) + RETURN() ENDIF() # A GCC bug causes crash when compiling these files on ARM64 with -O1+ diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc index f427a137c4d..376a106bf8a 100644 --- a/storage/innobase/btr/btr0scrub.cc +++ b/storage/innobase/btr/btr0scrub.cc @@ -883,17 +883,15 @@ btr_scrub_update_total_stat(btr_scrub_t *scrub_data) memset(&scrub_data->scrub_stat, 0, sizeof(scrub_data->scrub_stat)); } -/**************************************************************//** -Complete iterating a space */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data) /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data) { + ut_ad(scrub_data->scrubbing); btr_scrub_table_close_for_thread(scrub_data); btr_scrub_update_total_stat(scrub_data); - return scrub_data->scrubbing; } /********************************************************************* diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index b318d1e9a3a..945a1543b72 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -44,6 +44,8 @@ Created April 08, 2011 Vasil Dimov #include <algorithm> +#include "mysql/service_wsrep.h" /* wsrep_recovery */ + enum status_severity { STATUS_VERBOSE, STATUS_INFO, @@ -807,7 +809,14 @@ DECLARE_THREAD(buf_dump_thread)(void*) buf_load_status(STATUS_VERBOSE, "Loading of buffer pool not started"); if (srv_buffer_pool_load_at_startup) { - buf_load(); + +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ + buf_load(); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } while (!SHUTTING_DOWN()) { @@ -831,8 +840,15 @@ DECLARE_THREAD(buf_dump_thread)(void*) } if (srv_buffer_pool_dump_at_shutdown && srv_fast_shutdown != 2) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ + buf_dump(FALSE /* ignore shutdown down flag, keep going even if we are in a shutdown state */); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } srv_buf_dump_thread_active = false; diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index b8b7643702e..3c2b697b0f4 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -105,6 +105,7 @@ flag is cleared and the x-lock released by an i/o-handler thread. @param[in] mode BUF_READ_IBUF_PAGES_ONLY, ..., @param[in] page_id page id @param[in] unzip true=request uncompressed page +@param[in] ignore_missing_space true=ignore missing space when reading @return 1 if a read request was queued, 0 if the page already resided in buf_pool, or if the page is in the doublewrite buffer blocks in which case it is never read into the pool, or if the tablespace does @@ -118,7 +119,8 @@ buf_read_page_low( ulint mode, const page_id_t& page_id, const page_size_t& page_size, - bool unzip) + bool unzip, + bool ignore_missing_space = false) { buf_page_t* bpage; @@ -178,7 +180,7 @@ buf_read_page_low( *err = fil_io( request, sync, page_id, page_size, 0, page_size.physical(), - dst, bpage); + dst, bpage, ignore_missing_space); if (sync) { thd_wait_end(NULL); @@ -478,13 +480,15 @@ buf_read_page_background( << " in the background" " in a non-existing or being-dropped tablespace"; break; + case DB_PAGE_CORRUPTED: case DB_DECRYPTION_FAILED: ib::error() - << "Background Page read failed to decrypt page " - << page_id; + << "Background Page read failed to " + "read or decrypt " << page_id; break; default: - ut_error; + ib::fatal() << "Error " << err << " in background read of " + << page_id; } srv_stats.buf_pool_reads.add(count); @@ -755,9 +759,10 @@ buf_read_ahead_linear( case DB_TABLESPACE_DELETED: case DB_ERROR: break; + case DB_PAGE_CORRUPTED: case DB_DECRYPTION_FAILED: ib::error() << "linear readahead failed to" - " decrypt page " + " read or decrypt " << page_id_t(page_id.space(), i); break; default: @@ -844,7 +849,7 @@ tablespace_deleted: sync && (i + 1 == n_stored), 0, BUF_READ_ANY_PAGE, page_id, page_size, - true); + true, true /* ignore_missing_space */); switch(err) { case DB_SUCCESS: @@ -853,8 +858,9 @@ tablespace_deleted: break; case DB_TABLESPACE_DELETED: goto tablespace_deleted; + case DB_PAGE_CORRUPTED: case DB_DECRYPTION_FAILED: - ib::error() << "Failed to decrypt page " << page_id + ib::error() << "Failed to read or decrypt " << page_id << " for change buffer merge"; break; default: @@ -936,8 +942,8 @@ buf_read_recv_pages( cur_page_id, page_size, true); } - if (err == DB_DECRYPTION_FAILED) { - ib::error() << "Recovery failed to decrypt page " + if (err == DB_DECRYPTION_FAILED || err == DB_PAGE_CORRUPTED) { + ib::error() << "Recovery failed to read or decrypt " << cur_page_id; } } diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index e1b5bcbc325..cdf3d9bd997 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -168,7 +168,12 @@ fil_crypt_get_latest_key_version( crypt_data->min_key_version, key_version, srv_fil_crypt_rotate_key_age)) { - os_event_set(fil_crypt_threads_event); + /* Below event seen as NULL-pointer at startup + when new database was created and we create a + checkpoint. Only seen when debugging. */ + if (fil_crypt_threads_inited) { + os_event_set(fil_crypt_threads_event); + } } } @@ -1335,12 +1340,12 @@ fil_crypt_realloc_iops( state->cnt_waited = 0; state->sum_waited_us = 0; } else { - DBUG_PRINT("ib_crypt", - ("thr_no: %u only waited " ULINTPF - "%% skip re-estimate.", - state->thread_no, - (100 * state->cnt_waited) / state->batch)); + ("thr_no: %u only waited " ULINTPF + "%% skip re-estimate.", + state->thread_no, + (100 * state->cnt_waited) + / (state->batch ? state->batch : 1))); } if (state->estimated_max_iops <= state->allocated_iops) { @@ -1443,7 +1448,7 @@ fil_crypt_find_space_to_rotate( /* we need iops to start rotating */ while (!state->should_shutdown() && !fil_crypt_alloc_iops(state)) { os_event_reset(fil_crypt_threads_event); - os_event_wait_time(fil_crypt_threads_event, 1000000); + os_event_wait_time(fil_crypt_threads_event, 100000); } if (state->should_shutdown()) { @@ -2078,7 +2083,8 @@ fil_crypt_complete_rotate_space( mutex_exit(&crypt_data->mutex); /* all threads must call btr_scrub_complete_space wo/ mutex held */ - if (btr_scrub_complete_space(&state->scrub_data) == true) { + if (state->scrub_data.scrubbing) { + btr_scrub_complete_space(&state->scrub_data); if (should_flush) { /* only last thread updates last_scrub_completed */ ut_ad(crypt_data); @@ -2252,7 +2258,7 @@ fil_crypt_set_thread_cnt( for (uint i = 0; i < add; i++) { os_thread_id_t rotation_thread_id; os_thread_create(fil_crypt_thread, NULL, &rotation_thread_id); - ib::info() << "Creating " + ib::info() << "Creating #" << i+1 << " encryption thread id " << os_thread_pf(rotation_thread_id) << " total threads " << new_cnt << "."; @@ -2266,7 +2272,13 @@ fil_crypt_set_thread_cnt( while(srv_n_fil_crypt_threads_started != srv_n_fil_crypt_threads) { os_event_reset(fil_crypt_event); - os_event_wait_time(fil_crypt_event, 1000000); + os_event_wait_time(fil_crypt_event, 100000); + } + + /* Send a message to encryption threads that there could be + something to do. */ + if (srv_n_fil_crypt_threads) { + os_event_set(fil_crypt_threads_event); } } @@ -2419,10 +2431,10 @@ fil_space_crypt_get_status( fil_crypt_read_crypt_data(const_cast<fil_space_t*>(space)); } - fil_space_crypt_t* crypt_data = space->crypt_data; - status->space = space->id; + status->space = ULINT_UNDEFINED; - if (crypt_data != NULL) { + if (fil_space_crypt_t* crypt_data = space->crypt_data) { + status->space = space->id; mutex_enter(&crypt_data->mutex); status->scheme = crypt_data->type; status->keyserver_requests = crypt_data->keyserver_requests; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 1cafb253630..f34619663ad 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1005,7 +1005,7 @@ skip_flush: @param[in] size desired size in number of pages @param[out] success whether the operation succeeded @return whether the operation should be retried */ -static UNIV_COLD __attribute__((warn_unused_result, nonnull)) +static ATTRIBUTE_COLD __attribute__((warn_unused_result, nonnull)) bool fil_space_extend_must_retry( fil_space_t* space, @@ -4341,11 +4341,18 @@ fil_ibd_open( skip_validate: if (err == DB_SUCCESS) { - fil_space_t* space = fil_space_create( - space_name, id, flags, purpose, - df_remote.is_open() ? df_remote.get_crypt_info() : - df_dict.is_open() ? df_dict.get_crypt_info() : - df_default.get_crypt_info()); + const byte* first_page = + df_default.is_open() ? df_default.get_first_page() : + df_dict.is_open() ? df_dict.get_first_page() : + df_remote.get_first_page(); + + fil_space_crypt_t* crypt_data = first_page + ? fil_space_read_crypt_data(page_size_t(flags), + first_page) + : NULL; + + fil_space_t* space = fil_space_create( + space_name, id, flags, purpose, crypt_data); /* We do not measure the size of the file, that is why we pass the 0 below */ @@ -4663,9 +4670,12 @@ fil_ibd_load( << FSP_FLAGS_MEM_COMPRESSION_LEVEL; } + const byte* first_page = file.get_first_page(); + fil_space_crypt_t* crypt_data = first_page + ? fil_space_read_crypt_data(page_size_t(flags), first_page) + : NULL; space = fil_space_create( - file.name(), space_id, flags, FIL_TYPE_TABLESPACE, - file.get_crypt_info()); + file.name(), space_id, flags, FIL_TYPE_TABLESPACE, crypt_data); if (space == NULL) { return(FIL_LOAD_INVALID); @@ -5148,6 +5158,7 @@ fil_report_invalid_page_access( aligned @param[in] message message for aio handler if non-sync aio used, else ignored +@param[in] ignore_missing_space true=ignore missing space duging read @return DB_SUCCESS, DB_TABLESPACE_DELETED or DB_TABLESPACE_TRUNCATED if we are trying to do i/o on a tablespace which does not exist */ dberr_t @@ -5159,7 +5170,8 @@ fil_io( ulint byte_offset, ulint len, void* buf, - void* message) + void* message, + bool ignore_missing_space) { os_offset_t offset; IORequest req_type(type); @@ -5238,7 +5250,7 @@ fil_io( mutex_exit(&fil_system->mutex); - if (!req_type.ignore_missing()) { + if (!req_type.ignore_missing() && !ignore_missing_space) { ib::error() << "Trying to do I/O to a tablespace which" " does not exist. I/O type: " diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 4f03ace9d8e..c21c9497735 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -58,11 +58,6 @@ Datafile::shutdown() ut_free(m_name); m_name = NULL; - - /* The fil_space_t::crypt_data was freed in - fil_space_free_low(). Invalidate our redundant pointer. */ - m_crypt_info = NULL; - free_filepath(); free_first_page(); } @@ -374,8 +369,6 @@ Datafile::read_first_page(bool read_only_mode) return(DB_CORRUPTION); } - m_crypt_info = fil_space_read_crypt_data(ps, m_first_page); - return(err); } diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 77b28d2c01b..80303314d9f 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -102,7 +102,7 @@ then we will not allocate more extents @param[in,out] space tablespace @param[in,out] header tablespace header @param[in,out] mtr mini-transaction */ -static UNIV_COLD +static ATTRIBUTE_COLD void fsp_fill_free_list( bool init_space, @@ -799,7 +799,11 @@ fsp_header_init(ulint space_id, ulint size, mtr_t* mtr) fsp_fill_free_list(!is_system_tablespace(space_id), space, header, mtr); - if (space->crypt_data) { + /* Write encryption metadata to page 0 if tablespace is + encrypted or encryption is disabled by table option. */ + if (space->crypt_data && + (space->crypt_data->should_encrypt() || + space->crypt_data->not_encrypted())) { space->crypt_data->write_page0(space, page, mtr); } } @@ -895,7 +899,7 @@ data file. @param[in,out] header tablespace header @param[in,out] mtr mini-transaction @return true if success */ -static UNIV_COLD MY_ATTRIBUTE((warn_unused_result)) +static ATTRIBUTE_COLD __attribute__((warn_unused_result)) bool fsp_try_extend_data_file_with_pages( fil_space_t* space, @@ -928,7 +932,7 @@ fsp_try_extend_data_file_with_pages( @param[in,out] mtr mini-transaction @return number of pages added @retval 0 if the tablespace was not extended */ -UNIV_COLD MY_ATTRIBUTE((nonnull)) +ATTRIBUTE_COLD __attribute__((nonnull)) static ulint fsp_try_extend_data_file(fil_space_t* space, fsp_header_t* header, mtr_t* mtr) @@ -2107,15 +2111,6 @@ fseg_create_general( fil_block_check_type(block, type, mtr); } - if (rw_lock_get_x_lock_count(&space->latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space_id == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - if (!has_done_reservation && !fsp_reserve_free_extents(&n_reserved, space_id, 2, FSP_NORMAL, mtr)) { @@ -2699,15 +2694,6 @@ fseg_alloc_free_page_general( space = mtr_x_lock_space(space_id, mtr); const page_size_t page_size(space->flags); - if (rw_lock_get_x_lock_count(&space->latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space_id == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - inode = fseg_inode_get(seg_header, space_id, page_size, mtr, &iblock); fil_block_check_type(iblock, FIL_PAGE_INODE, mtr); diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index 94fae3d973b..9ca2786b935 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -125,7 +125,7 @@ Tablespace::open_or_create(bool is_temp) m_name, m_space_id, FSP_FLAGS_PAGE_SSIZE(), is_temp ? FIL_TYPE_TEMPORARY : FIL_TYPE_TABLESPACE, - it->m_crypt_info); + NULL); } ut_a(fil_validate()); diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index e4bb11c9a22..cc156a5353a 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -562,8 +562,6 @@ SysTablespace::read_lsn_and_check_flags(lsn_t* flushed_lsn) err = it->read_first_page( m_ignore_read_only ? false : srv_read_only_mode); - m_crypt_info = it->m_crypt_info; - if (err != DB_SUCCESS) { return(err); } @@ -919,19 +917,10 @@ SysTablespace::open_or_create( /* Create the tablespace entry for the multi-file tablespace in the tablespace manager. */ - - if (!m_crypt_info) { - /* Create default crypt info for system - tablespace if it does not yet exists. */ - m_crypt_info = fil_space_create_crypt_data( - FIL_ENCRYPTION_DEFAULT, - FIL_DEFAULT_ENCRYPTION_KEY); - } - space = fil_space_create( name(), space_id(), flags(), is_temp ? FIL_TYPE_TEMPORARY : FIL_TYPE_TABLESPACE, - m_crypt_info); + NULL); } ut_a(fil_validate()); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 02225d9f49f..4dadfcf58ae 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3753,6 +3753,16 @@ static const char* deprecated_instrument_semaphores = "Using innodb_instrument_semaphores is deprecated" " and the parameter will be removed in MariaDB 10.3."; +static const char* deprecated_use_mtflush + = "Using innodb_use_mtflush is deprecated" + " and the parameter will be removed in MariaDB 10.3." + " Use innodb-page-cleaners instead. "; + +static const char* deprecated_mtflush_threads + = "Using innodb_mtflush_threads is deprecated" + " and the parameter will be removed in MariaDB 10.3." + " Use innodb-page-cleaners instead. "; + static my_bool innodb_instrument_semaphores; /** Update log_checksum_algorithm_ptr with a pointer to the function @@ -4113,6 +4123,14 @@ innobase_init( ib::warn() << deprecated_instrument_semaphores; } + if (srv_use_mtflush) { + ib::warn() << deprecated_use_mtflush; + } + + if (srv_use_mtflush && srv_mtflush_threads != MTFLUSH_DEFAULT_WORKER) { + ib::warn() << deprecated_mtflush_threads; + } + /* Validate the file format by animal name */ if (innobase_file_format_name != NULL) { @@ -17965,9 +17983,11 @@ innobase_commit_by_xid( { DBUG_ASSERT(hton == innodb_hton_ptr); - trx_t* trx = trx_get_trx_by_xid(xid); + if (high_level_read_only) { + return(XAER_RMFAIL); + } - if (trx != NULL) { + if (trx_t* trx = trx_get_trx_by_xid(xid)) { TrxInInnoDB trx_in_innodb(trx); innobase_commit_low(trx); @@ -17997,9 +18017,11 @@ innobase_rollback_by_xid( { DBUG_ASSERT(hton == innodb_hton_ptr); - trx_t* trx = trx_get_trx_by_xid(xid); + if (high_level_read_only) { + return(XAER_RMFAIL); + } - if (trx != NULL) { + if (trx_t* trx = trx_get_trx_by_xid(xid)) { TrxInInnoDB trx_in_innodb(trx); int ret = innobase_rollback_trx(trx); @@ -20482,7 +20504,7 @@ wsrep_fake_trx_id( mutex_enter(&trx_sys->mutex); trx_id_t trx_id = trx_sys_get_new_trx_id(); mutex_exit(&trx_sys->mutex); - + WSREP_DEBUG("innodb fake trx id: %lu thd: %s", trx_id, wsrep_thd_query(thd)); wsrep_ws_handle_for_trx(wsrep_thd_ws_handle(thd), trx_id); } @@ -21627,7 +21649,7 @@ static MYSQL_SYSVAR_ENUM(compression_algorithm, innodb_compression_algorithm, static MYSQL_SYSVAR_LONG(mtflush_threads, srv_mtflush_threads, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Number of multi-threaded flush threads", + "DEPRECATED. Number of multi-threaded flush threads", NULL, NULL, MTFLUSH_DEFAULT_WORKER, /* Default setting */ 1, /* Minimum setting */ @@ -21636,7 +21658,7 @@ static MYSQL_SYSVAR_LONG(mtflush_threads, srv_mtflush_threads, static MYSQL_SYSVAR_BOOL(use_mtflush, srv_use_mtflush, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, - "Use multi-threaded flush. Default FALSE.", + "DEPRECATED. Use multi-threaded flush. Default FALSE.", NULL, NULL, FALSE); static MYSQL_SYSVAR_ULONG(fatal_semaphore_wait_threshold, srv_fatal_semaphore_wait_threshold, diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index e3bc5fd5799..9bff7f17933 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -271,7 +271,7 @@ innobase_get_int_col_max_value( const Field* field); /*!< in: MySQL field */ /* Report an InnoDB error to the client by invoking my_error(). */ -static UNIV_COLD MY_ATTRIBUTE((nonnull)) +static ATTRIBUTE_COLD __attribute__((nonnull)) void my_error_innodb( /*============*/ diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 8f04f9d15ee..8880d21aafb 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -8606,6 +8606,12 @@ i_s_dict_fill_tablespaces_encryption( fil_space_crypt_get_status(space, &status); + /* If tablespace id does not match, we did not find + encryption information for this tablespace. */ + if (!space->crypt_data || space->id != status.space) { + goto skip; + } + OK(fields[TABLESPACES_ENCRYPTION_SPACE]->store(space->id, true)); OK(field_store_string(fields[TABLESPACES_ENCRYPTION_NAME], @@ -8640,6 +8646,7 @@ i_s_dict_fill_tablespaces_encryption( OK(schema_table_store_record(thd, table_to_fill)); +skip: DBUG_RETURN(0); } /*******************************************************************//** diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index d021f8c0085..eda6684e69f 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2104,6 +2104,8 @@ ibuf_remove_free_page(void) page_t* root; page_t* bitmap_page; + log_free_check(); + mtr_start(&mtr); fil_space_t* space = mtr.set_sys_modified(); const page_size_t page_size(space->flags); @@ -2211,19 +2213,7 @@ void ibuf_free_excess_pages(void) /*========================*/ { - ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL), RW_LOCK_X)); - - ut_ad(rw_lock_get_x_lock_count( - fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1); - - /* NOTE: We require that the thread did not own the latch before, - because then we know that we can obey the correct latching order - for ibuf latches */ - - if (!ibuf) { - /* Not yet initialized; not sure if this is possible, but - does no harm to check for it. */ - + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { return; } diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index a5409c3ad4c..1d7710a1496 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -172,7 +172,7 @@ btr_corruption_report( /*==================*/ const buf_block_t* block, /*!< in: corrupted block */ const dict_index_t* index) /*!< in: index tree */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Assert that a B-tree page is not corrupted. @param block buffer block containing a B-tree page diff --git a/storage/innobase/include/btr0scrub.h b/storage/innobase/include/btr0scrub.h index 608266c206d..8029cc91005 100644 --- a/storage/innobase/include/btr0scrub.h +++ b/storage/innobase/include/btr0scrub.h @@ -154,13 +154,10 @@ btr_scrub_start_space( ulint space, /*!< in: space */ btr_scrub_t* scrub_data); /*!< in/out: scrub data */ -/**************************************************************** -Complete iterating a space -* @return true if space was scrubbed */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data); /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data); #endif diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 8836e858018..04baf032ded 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1867,7 +1867,7 @@ dict_set_corrupted( dict_index_t* index, /*!< in/out: index */ trx_t* trx, /*!< in/out: transaction */ const char* ctx) /*!< in: context */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Flags an index corrupted in the data dictionary cache only. This is used mostly to mark a corrupted index when index's own dictionary diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 204f031bce2..3b53fa28be3 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1224,7 +1224,7 @@ fil_space_get_n_reserved_extents( aligned @param[in] message message for aio handler if non-sync aio used, else ignored - +@param[in] ignore_missing_space true=ignore missing space during read @return DB_SUCCESS, DB_TABLESPACE_DELETED or DB_TABLESPACE_TRUNCATED if we are trying to do i/o on a tablespace which does not exist */ dberr_t @@ -1236,7 +1236,9 @@ fil_io( ulint byte_offset, ulint len, void* buf, - void* message); + void* message, + bool ignore_missing_space = false); + /**********************************************************************//** Waits for an aio operation to complete. This function is used to write the handler for completed requests. The aio array of pending requests is divided diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h index 974de9c75ed..1f057be0877 100644 --- a/storage/innobase/include/fsp0file.h +++ b/storage/innobase/include/fsp0file.h @@ -66,8 +66,7 @@ public: m_first_page_buf(), m_first_page(), m_last_os_error(), - m_file_info(), - m_crypt_info() + m_file_info() { /* No op */ } @@ -89,8 +88,7 @@ public: m_first_page_buf(), m_first_page(), m_last_os_error(), - m_file_info(), - m_crypt_info() + m_file_info() { ut_ad(m_name != NULL); /* No op */ @@ -110,8 +108,7 @@ public: m_first_page_buf(), m_first_page(), m_last_os_error(), - m_file_info(), - m_crypt_info() + m_file_info() { m_name = mem_strdup(file.m_name); ut_ad(m_name != NULL); @@ -169,8 +166,6 @@ public: it should be reread if needed */ m_first_page_buf = NULL; m_first_page = NULL; - /* Do not copy crypt info it is read from first page */ - m_crypt_info = NULL; return(*this); } @@ -321,11 +316,6 @@ public: return(m_last_os_error); } - fil_space_crypt_t* get_crypt_info() const - { - return(m_crypt_info); - } - /** Test if the filepath provided looks the same as this filepath by string comparison. If they are two different paths to the same file, same_as() will be used to show that after the files are opened. @@ -339,6 +329,11 @@ public: @return true if it is the same file, else false */ bool same_as(const Datafile& other) const; + /** Get access to the first data page. + It is valid after open_read_only() succeeded. + @return the first data page */ + const byte* get_first_page() const { return(m_first_page); } + private: /** Free the filepath buffer. */ void free_filepath(); @@ -465,9 +460,6 @@ public: /* Use field st_ino. */ struct stat m_file_info; #endif /* WIN32 */ - - /** Encryption information */ - fil_space_crypt_t* m_crypt_info; }; diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h index b8890adad74..efbd4fc3f24 100644 --- a/storage/innobase/include/fsp0sysspace.h +++ b/storage/innobase/include/fsp0sysspace.h @@ -53,8 +53,7 @@ public: m_last_file_size_max(), m_created_new_raw(), m_is_tablespace_full(false), - m_sanity_checks_done(false), - m_crypt_info() + m_sanity_checks_done(false) { /* No op */ } @@ -264,9 +263,6 @@ private: /** if false, then sanity checks are still pending */ bool m_sanity_checks_done; - - /** Encryption information */ - fil_space_crypt_t* m_crypt_info; }; /* GLOBAL OBJECTS */ diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index d4430f5ebce..c240f5dacdd 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -128,10 +128,8 @@ os_thread_join( /** Exits the current thread. @param[in] detach if true, the thread will be detached right before exiting. If false, another thread is responsible for joining this thread */ -void -os_thread_exit( - bool detach = true) - UNIV_COLD MY_ATTRIBUTE((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_COLD +void os_thread_exit(bool detach = true); /*****************************************************************//** Returns the thread identifier of current thread. diff --git a/storage/innobase/include/row0log.h b/storage/innobase/include/row0log.h index 980facee427..5657e09cc22 100644 --- a/storage/innobase/include/row0log.h +++ b/storage/innobase/include/row0log.h @@ -101,7 +101,7 @@ row_log_online_op( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /******************************************************//** Gets the error status of the online index rebuild log. @@ -137,7 +137,7 @@ row_log_table_delete( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const byte* sys) /*!< in: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec */ - UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); + ATTRIBUTE_COLD __attribute__((nonnull(1,2,3))); /******************************************************//** Logs an update operation to a table that is being rebuilt. @@ -174,7 +174,7 @@ row_log_table_get_pk( byte* sys, /*!< out: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL */ mem_heap_t** heap) /*!< in/out: memory heap where allocated */ - UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,5), warn_unused_result)); + ATTRIBUTE_COLD __attribute__((nonnull(1,2,5), warn_unused_result)); /******************************************************//** Logs an insert to a table that is being rebuilt. @@ -195,7 +195,7 @@ row_log_table_blob_free( /*====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /******************************************************//** Notes that a BLOB is being allocated during online ALTER TABLE. */ void @@ -203,7 +203,7 @@ row_log_table_blob_alloc( /*=====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Apply the row_log_table log to a table upon completing rebuild. @param[in] thr query graph diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index 60f256fb200..d24ae37b13d 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, MariaDB Corporation. +Copyright (c) 2016, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -30,6 +30,7 @@ Created 4/20/1996 Heikki Tuuri #include "univ.i" #include "data0data.h" #include "dict0types.h" +#include "ibuf0ibuf.h" #include "trx0types.h" #include "que0types.h" #include "mtr0mtr.h" @@ -387,6 +388,34 @@ row_raw_format( in bytes */ MY_ATTRIBUTE((nonnull, warn_unused_result)); +/** Prepare to start a mini-transaction to modify an index. +@param[in,out] mtr mini-transaction +@param[in,out] index possibly secondary index +@param[in] pessimistic whether this is a pessimistic operation */ +inline +void +row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic) +{ + mtr->start(); + + switch (index->space) { + case IBUF_SPACE_ID: + if (pessimistic + && !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) { + ibuf_free_excess_pages(); + } + break; + case SRV_TMP_SPACE_ID: + mtr->set_log_mode(MTR_LOG_NO_REDO); + break; + default: + mtr->set_named_space(index->space); + break; + } + + log_free_check(); +} + #include "row0row.ic" #endif diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index e2b4e4d30fd..ebe70a1c70e 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -243,17 +243,22 @@ system header. */ void trx_sys_print_mysql_binlog_offset(); #ifdef WITH_WSREP -/** Update WSREP checkpoint XID in sys header. */ + +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( -/*============================*/ - const XID* xid, /*!< in: WSREP XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr); /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr); /** Read WSREP checkpoint XID from sys header. @param[out] xid WSREP XID @return whether the checkpoint was present */ +UNIV_INTERN bool trx_sys_read_wsrep_checkpoint(XID* xid); #endif /* WITH_WSREP */ @@ -420,13 +425,71 @@ impose the 7 bit restriction. e.g., mach_write_to_3() */ within that file */ #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */ +/** Memory map TRX_SYS_PAGE_NO = 5 when UNIV_PAGE_SIZE = 4096 + +0...37 FIL_HEADER +38...45 TRX_SYS_TRX_ID_STORE +46...55 TRX_SYS_FSEG_HEADER (FSEG_HEADER_SIZE == 10) +56 TRX_SYS_RSEGS + 56...59 TRX_SYS_RSEG_SPACE for slot 0 + 60...63 TRX_SYS_RSEG_PAGE_NO for slot 0 + 64...67 TRX_SYS_RSEG_SPACE for slot 1 + 68...71 TRX_SYS_RSEG_PAGE_NO for slot 1 +.... + 594..597 TRX_SYS_RSEG_SPACE for slot 72 + 598..601 TRX_SYS_RSEG_PAGE_NO for slot 72 +... + ...1063 TRX_SYS_RSEG_PAGE_NO for slot 126 + +(UNIV_PAGE_SIZE-3500 WSREP ::: FAIL would overwrite undo tablespace +space_id, page_no pairs :::) +596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +600 TRX_SYS_WSREP_XID_FORMAT +604 TRX_SYS_WSREP_XID_GTRID_LEN +608 TRX_SYS_WSREP_XID_BQUAL_LEN +612 TRX_SYS_WSREP_XID_DATA (len = 128) +739 TRX_SYS_WSREP_XID_DATA_END + +FIXED WSREP XID info offsets for 4k page size 10.0.32-galera +(UNIV_PAGE_SIZE-2500) +1596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +1600 TRX_SYS_WSREP_XID_FORMAT +1604 TRX_SYS_WSREP_XID_GTRID_LEN +1608 TRX_SYS_WSREP_XID_BQUAL_LEN +1612 TRX_SYS_WSREP_XID_DATA (len = 128) +1739 TRX_SYS_WSREP_XID_DATA_END + +(UNIV_PAGE_SIZE - 2000 MYSQL MASTER LOG) +2096 TRX_SYS_MYSQL_MASTER_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +2100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +2104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +2108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 1000 MYSQL LOG) +3096 TRX_SYS_MYSQL_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +3100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +3104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +3108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 200 DOUBLEWRITE) +3896 TRX_SYS_DOUBLEWRITE TRX_SYS_DOUBLEWRITE_FSEG +3906 TRX_SYS_DOUBLEWRITE_MAGIC +3910 TRX_SYS_DOUBLEWRITE_BLOCK1 +3914 TRX_SYS_DOUBLEWRITE_BLOCK2 +3918 TRX_SYS_DOUBLEWRITE_REPEAT +3930 TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N + +(UNIV_PAGE_SIZE - 8, TAILER) +4088..4096 FIL_TAILER + +*/ #ifdef WITH_WSREP -/* The offset to WSREP XID headers */ -#define TRX_SYS_WSREP_XID_INFO (UNIV_PAGE_SIZE - 3500) +/** The offset to WSREP XID headers */ +#define TRX_SYS_WSREP_XID_INFO std::max(srv_page_size - 3500, 1596UL) #define TRX_SYS_WSREP_XID_MAGIC_N_FLD 0 #define TRX_SYS_WSREP_XID_MAGIC_N 0x77737265 -/* XID field: formatID, gtrid_len, bqual_len, xid_data */ +/** XID field: formatID, gtrid_len, bqual_len, xid_data */ #define TRX_SYS_WSREP_XID_LEN (4 + 4 + 4 + XIDDATASIZE) #define TRX_SYS_WSREP_XID_FORMAT 4 #define TRX_SYS_WSREP_XID_GTRID_LEN 8 diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index cdf97b6a9cf..b1d442a9acf 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -319,7 +319,7 @@ void trx_undo_free_prepared( /*===================*/ trx_t* trx) /*!< in/out: PREPARED transaction */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /* Forward declaration. */ namespace undo { diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 21ca95bacb7..e797fd7bef7 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -258,23 +258,6 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ #endif #endif -#if defined(COMPILER_HINTS) \ - && defined __GNUC__ \ - && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3) - -/** Starting with GCC 4.3, the "cold" attribute is used to inform the -compiler that a function is unlikely executed. The function is -optimized for size rather than speed and on many targets it is placed -into special subsection of the text section so all cold functions -appears close together improving code locality of non-cold parts of -program. The paths leading to call of cold functions within code are -marked as unlikely by the branch prediction mechanism. optimize a -rarely invoked function for size instead for speed. */ -# define UNIV_COLD MY_ATTRIBUTE((cold)) -#else -# define UNIV_COLD /* empty */ -#endif - #define UNIV_INLINE static inline #define UNIV_WORD_SIZE SIZEOF_SIZE_T diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index a860196e3db..13228ad852f 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -39,13 +39,13 @@ Created 1/30/1994 Heikki Tuuri /*************************************************************//** Report a failed assertion. */ +ATTRIBUTE_NORETURN ATTRIBUTE_COLD __attribute__((nonnull(2))) void ut_dbg_assertion_failed( /*====================*/ const char* expr, /*!< in: the failed assertion */ const char* file, /*!< in: source file containing the assertion */ - unsigned line) /*!< in: line number of the assertion */ - UNIV_COLD MY_ATTRIBUTE((nonnull(2), noreturn)); + unsigned line); /*!< in: line number of the assertion */ /** Abort execution if EXPR does not evaluate to nonzero. @param EXPR assertion expression that should hold */ diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 7082d18da53..b8282b7d0de 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -299,7 +299,7 @@ void ut_print_timestamp( /*===============*/ FILE* file) /*!< in: file where to print */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); #ifndef UNIV_INNOCHECKSUM @@ -505,6 +505,7 @@ use this class directly, instead use one of the derived classes. */ class logger { public: template<typename T> + ATTRIBUTE_COLD logger& operator<<(const T& rhs) { m_oss << rhs; @@ -515,6 +516,7 @@ public: @param[in] buf the buffer whose contents will be logged. @param[in] count the length of the buffer buf. @return the output stream into which buffer was written. */ + ATTRIBUTE_COLD std::ostream& write( const char* buf, @@ -527,6 +529,7 @@ public: @param[in] buf the buffer whose contents will be logged. @param[in] count the length of the buffer buf. @return the output stream into which buffer was written. */ + ATTRIBUTE_COLD std::ostream& write( const byte* buf, @@ -539,6 +542,7 @@ public: protected: /* This class must not be used directly, hence making the default constructor protected. */ + ATTRIBUTE_COLD logger() {} }; @@ -555,6 +559,7 @@ statement. If a named object is created, then the log message will be emitted only when it goes out of scope or destroyed. */ class info : public logger { public: + ATTRIBUTE_COLD ~info(); }; @@ -562,6 +567,7 @@ public: class info for further details. */ class warn : public logger { public: + ATTRIBUTE_COLD ~warn(); }; @@ -569,6 +575,7 @@ public: documentation of class info for further details. */ class error : public logger { public: + ATTRIBUTE_COLD ~error(); }; @@ -577,6 +584,7 @@ by crashing it. Use this class when MySQL server needs to be stopped immediately. Refer to the documentation of class info for usage details. */ class fatal : public logger { public: + ATTRIBUTE_NORETURN ~fatal(); }; @@ -584,10 +592,12 @@ public: warning message */ class error_or_warn : public logger { public: + ATTRIBUTE_COLD error_or_warn(bool pred) : m_error(pred) {} + ATTRIBUTE_COLD ~error_or_warn(); private: const bool m_error; @@ -597,10 +607,12 @@ private: error message. */ class fatal_or_error : public logger { public: + ATTRIBUTE_COLD fatal_or_error(bool pred) : m_fatal(pred) {} + ATTRIBUTE_COLD ~fatal_or_error(); private: const bool m_fatal; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 6b3ef28a788..54af4140f64 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1020,10 +1020,10 @@ recv_find_max_checkpoint(ulint* max_field) } if (*max_field == 0) { - /* Before 5.7.9, we could get here during database + /* Before 10.2.2, we could get here during database initialization if we created an ib_logfile0 file that was filled with zeroes, and were killed. After - 5.7.9, we would reject such a file already earlier, + 10.2.2, we would reject such a file already earlier, when checking the file header. */ ib::error() << "No valid checkpoint found" " (corrupted redo log)." diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index fde743a9074..3986c4f4c44 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -174,9 +174,9 @@ os_thread_join( /** Exits the current thread. @param[in] detach if true, the thread will be detached right before exiting. If false, another thread is responsible for joining this thread */ +ATTRIBUTE_NORETURN void -os_thread_exit( - bool detach) +os_thread_exit(bool detach) { #ifdef UNIV_DEBUG_THREAD_CREATION ib::info() << "Thread exits, id " diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index ffe93ac8612..7c965f791be 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -158,7 +158,7 @@ TODO: Remove this function. Everything should use MYSQL_TYPE_NEWDECIMAL. @param[in] b_length length of b, in bytes (not UNIV_SQL_NULL) @return positive, 0, negative, if a is greater, equal, less than b, respectively */ -static UNIV_COLD +static ATTRIBUTE_COLD int cmp_decimal( const byte* a, diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 654f3ba286c..b5b2a703c2b 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -34,6 +34,7 @@ Created 4/20/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "que0que.h" #include "row0upd.h" #include "row0sel.h" @@ -3267,6 +3268,11 @@ row_ins_sec_index_entry( if (err == DB_FAIL) { mem_heap_empty(heap); + if (index->space == IBUF_SPACE_ID + && !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) { + ibuf_free_excess_pages(); + } + /* Try then pessimistic descent to the B-tree */ log_free_check(); diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index ef0c3ed9cc3..0fce0731307 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -193,19 +194,15 @@ row_undo_ins_remove_sec_low( dberr_t err = DB_SUCCESS; mtr_t mtr; enum row_search_result search_result; - ibool modify_leaf = false; + const bool modify_leaf = mode == BTR_MODIFY_LEAF; - log_free_check(); memset(&pcur, 0, sizeof(pcur)); - mtr_start(&mtr); - mtr.set_named_space(index->space); - dict_disable_redo_if_temporary(index->table, &mtr); + row_mtr_start(&mtr, index, !modify_leaf); - if (mode == BTR_MODIFY_LEAF) { + if (modify_leaf) { mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED; mtr_s_lock(dict_index_get_lock(index), &mtr); - modify_leaf = true; } else { ut_ad(mode == (BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE)); mtr_sx_lock(dict_index_get_lock(index), &mtr); @@ -216,7 +213,7 @@ row_undo_ins_remove_sec_low( } if (dict_index_is_spatial(index)) { - if (mode & BTR_MODIFY_LEAF) { + if (modify_leaf) { mode |= BTR_RTREE_DELETE_MARK; } btr_pcur_get_btr_cur(&pcur)->thr = thr; diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index a0c69fb97f9..0a2a68d1fef 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -34,6 +34,7 @@ Created 2/27/1997 Heikki Tuuri #include "trx0roll.h" #include "btr0btr.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "row0undo.h" #include "row0vers.h" #include "row0log.h" @@ -422,23 +423,15 @@ row_undo_mod_del_mark_or_remove_sec_low( mtr_t mtr; mtr_t mtr_vers; row_search_result search_result; - ibool modify_leaf = false; + const bool modify_leaf = mode == BTR_MODIFY_LEAF; - log_free_check(); - //mtr_start_trx(&mtr, thr_get_trx(thr)); - mtr_start(&mtr); - mtr.set_named_space(index->space); - dict_disable_redo_if_temporary(index->table, &mtr); - - if (mode == BTR_MODIFY_LEAF) { - modify_leaf = true; - } + row_mtr_start(&mtr, index, !modify_leaf); if (!index->is_committed()) { /* The index->online_status may change if the index is or was being created online, but not committed yet. It is protected by index->lock. */ - if (mode == BTR_MODIFY_LEAF) { + if (modify_leaf) { mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED; mtr_s_lock(dict_index_get_lock(index), &mtr); } else { @@ -459,7 +452,7 @@ row_undo_mod_del_mark_or_remove_sec_low( btr_cur = btr_pcur_get_btr_cur(&pcur); if (dict_index_is_spatial(index)) { - if (mode & BTR_MODIFY_LEAF) { + if (modify_leaf) { btr_cur->thr = thr; mode |= BTR_RTREE_DELETE_MARK; } @@ -631,11 +624,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( } try_again: - log_free_check(); - //mtr_start_trx(&mtr, thr_get_trx(thr)); - mtr_start(&mtr); - mtr.set_named_space(index->space); - dict_disable_redo_if_temporary(index->table, &mtr); + row_mtr_start(&mtr, index, !(mode & BTR_MODIFY_LEAF)); if (!index->is_committed()) { /* The index->online_status may change if the index is diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 56aaff3c2aa..76fd0e75427 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2300,17 +2300,18 @@ row_upd_sec_index_entry( "before_row_upd_sec_index_entry"); mtr_start_trx(&mtr, trx); - mtr.set_named_space(index->space); - /* Disable REDO logging as lifetime of temp-tables is limited to - server or connection lifetime and so REDO information is not needed - on restart for recovery. - Disable locking as temp-tables are not shared across connection. */ - if (dict_table_is_temporary(index->table)) { - flags = BTR_NO_LOCKING_FLAG; + switch (index->space) { + case SRV_TMP_SPACE_ID: mtr.set_log_mode(MTR_LOG_NO_REDO); - } else { + flags = BTR_NO_LOCKING_FLAG; + break; + default: + mtr.set_named_space(index->space); + /* fall through */ + case IBUF_SPACE_ID: flags = index->table->no_rollback() ? BTR_NO_ROLLBACK : 0; + break; } if (!index->is_committed()) { diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index d4922e33ef5..21c1343f5b3 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -78,7 +78,7 @@ Created 2/16/1996 Heikki Tuuri #include "btr0defragment.h" #include "fsp0sysspace.h" #include "row0trunc.h" -#include <mysql/service_wsrep.h> +#include "mysql/service_wsrep.h" /* wsrep_recovery */ #include "trx0rseg.h" #include "os0proc.h" #include "buf0flu.h" @@ -2710,6 +2710,7 @@ files_checked: */ if (!wsrep_recovery) { #endif /* WITH_WSREP */ + /* Create the buffer pool dump/load thread */ srv_buf_dump_thread_active = true; buf_dump_thread_handle= @@ -2728,6 +2729,7 @@ files_checked: will flush dirty pages and that might need e.g. fil_crypt_threads_event. */ fil_system_enter(); + btr_scrub_init(); fil_crypt_threads_init(); fil_system_exit(); @@ -2738,9 +2740,6 @@ files_checked: */ log_make_checkpoint_at(LSN_MAX, TRUE); - /* Init data for datafile scrub threads */ - btr_scrub_init(); - /* Initialize online defragmentation. */ btr_defragment_init(); btr_defragment_thread_active = true; diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index c35faede4b9..dc59260c31d 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -245,85 +245,83 @@ trx_sys_print_mysql_binlog_offset() static long long trx_sys_cur_xid_seqno = -1; static unsigned char trx_sys_cur_xid_uuid[16]; -long long read_wsrep_xid_seqno(const XID* xid) +/** Read WSREP XID seqno */ +static inline long long read_wsrep_xid_seqno(const XID* xid) { long long seqno; memcpy(&seqno, xid->data + 24, sizeof(long long)); return seqno; } -void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) +/** Read WSREP XID UUID */ +static inline void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) { memcpy(buf, xid->data + 8, 16); } #endif /* UNIV_DEBUG */ +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( -/*============================*/ - const XID* xid, /*!< in: transaction XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr) /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr) { + ut_ad(xid->formatID == 1); + ut_ad(wsrep_is_wsrep_xid(xid)); + + if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + != TRX_SYS_WSREP_XID_MAGIC_N) { + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD, + TRX_SYS_WSREP_XID_MAGIC_N, + MLOG_4BYTES, mtr); #ifdef UNIV_DEBUG - { + } else { /* Check that seqno is monotonically increasing */ unsigned char xid_uuid[16]; long long xid_seqno = read_wsrep_xid_seqno(xid); read_wsrep_xid_uuid(xid, xid_uuid); - if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 16)) - { - /* - This check is a protection against the initial seqno (-1) - assigned in read_wsrep_xid_uuid(), which, if not checked, - would cause the following assertion to fail. - */ - if (xid_seqno > -1 ) - { - ut_ad(xid_seqno > trx_sys_cur_xid_seqno); - } + + if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 8)) { + ut_ad(xid_seqno > trx_sys_cur_xid_seqno); + trx_sys_cur_xid_seqno = xid_seqno; } else { memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); } + trx_sys_cur_xid_seqno = xid_seqno; - } #endif /* UNIV_DEBUG */ + } - ut_ad(xid && mtr); - ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid(xid)); - - if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD) - != TRX_SYS_WSREP_XID_MAGIC_N) { - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD, - TRX_SYS_WSREP_XID_MAGIC_N, - MLOG_4BYTES, mtr); - } - - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_FORMAT, - (int)xid->formatID, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_GTRID_LEN, - (int)xid->gtrid_length, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_BQUAL_LEN, - (int)xid->bqual_length, - MLOG_4BYTES, mtr); - mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_DATA, - (const unsigned char*) xid->data, - XIDDATASIZE, mtr); - + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_FORMAT, + (int)xid->formatID, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_GTRID_LEN, + (int)xid->gtrid_length, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_BQUAL_LEN, + (int)xid->bqual_length, + MLOG_4BYTES, mtr); + mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_DATA, + (const unsigned char*) xid->data, + XIDDATASIZE, mtr); } /** Read WSREP checkpoint XID from sys header. @param[out] xid WSREP XID @return whether the checkpoint was present */ +UNIV_INTERN bool trx_sys_read_wsrep_checkpoint(XID* xid) { diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 31e70a5aaa6..ac23234179c 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -843,18 +843,9 @@ trx_resurrect_insert( << trx_get_id_for_print(trx) << " was in the XA prepared state."; - if (srv_force_recovery == 0) { - - trx->state = TRX_STATE_PREPARED; - ++trx_sys->n_prepared_trx; - ++trx_sys->n_prepared_recovered_trx; - } else { - - ib::info() << "Since innodb_force_recovery" - " > 0, we will force a rollback."; - - trx->state = TRX_STATE_ACTIVE; - } + trx->state = TRX_STATE_PREPARED; + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } @@ -914,24 +905,14 @@ trx_resurrect_update_in_prepared_state( ib::info() << "Transaction " << trx_get_id_for_print(trx) << " was in the XA prepared state."; - if (srv_force_recovery == 0) { - - ut_ad(trx->state != TRX_STATE_FORCED_ROLLBACK); - - if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { - ++trx_sys->n_prepared_trx; - ++trx_sys->n_prepared_recovered_trx; - } else { - ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); - } - - trx->state = TRX_STATE_PREPARED; + if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { - ib::info() << "Since innodb_force_recovery > 0, we" - " will rollback it anyway."; - - trx->state = TRX_STATE_ACTIVE; + ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); } + + trx->state = TRX_STATE_PREPARED; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc index fff1f0e6687..28643645de9 100644 --- a/storage/innobase/ut/ut0dbg.cc +++ b/storage/innobase/ut/ut0dbg.cc @@ -30,6 +30,7 @@ Created 1/30/1994 Heikki Tuuri /*************************************************************//** Report a failed assertion. */ +ATTRIBUTE_NORETURN void ut_dbg_assertion_failed( /*====================*/ diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 4eb9d45b0dc..7393a24b72c 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -834,6 +834,7 @@ error::~error() sql_print_error("InnoDB: %s", m_oss.str().c_str()); } +ATTRIBUTE_NORETURN fatal::~fatal() { sql_print_error("[FATAL] InnoDB: %s", m_oss.str().c_str()); diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 2b6f8164135..fc3d3492252 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -89,7 +89,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param, MARIA_PAGE *page, uint sortkey, File new_file, my_bool update_index); static my_bool write_log_record(HA_CHECK *param); -static void my_exit(int exit_code) __attribute__ ((noreturn)); +ATTRIBUTE_NORETURN static void my_exit(int exit_code); HA_CHECK check_param; diff --git a/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff b/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff index 4346545abcf..35d4f6b63d6 100644 --- a/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff +++ b/storage/myisammrg/mysql-test/storage_engine/parts/repair_table.rdiff @@ -1,6 +1,6 @@ ---- suite/storage_engine/parts/repair_table.result 2017-05-20 03:58:19.451939791 +0300 -+++ ../storage/myisammrg/mysql-test/storage_engine/parts/repair_table.reject 2017-05-24 02:42:31.130318292 +0300 -@@ -1,234 +1,115 @@ +--- suite/storage_engine/parts/repair_table.result 2017-08-28 19:29:20.491633306 +0300 ++++ suite/storage_engine/parts/repair_table.reject 2017-08-28 19:34:41.723633059 +0300 +@@ -1,235 +1,115 @@ call mtr.add_suppression("Table '.*t1.*' is marked as crashed and should be repaired"); DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2; @@ -144,7 +144,7 @@ call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table"); call mtr.add_suppression(" '\..test.t1'"); call mtr.add_suppression("Couldn't repair table: test.t1"); -+call mtr.add_suppression("Table 't1' is marked as crashed.*"); + call mtr.add_suppression("Table 't1' is marked as crashed.*"); CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2; +ERROR HY000: Engine cannot be used in partitioned tables +# ERROR: Statement ended with errno 1572, errname ER_PARTITION_MERGE_ERROR (expected to succeed) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result b/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result index 840ad9a723c..3bd87e9ffd6 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/cardinality.result @@ -1,4 +1,4 @@ -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1,t10,t11; create table t1( id bigint not null primary key, i1 bigint, #unique diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc index 6644d93cbc5..1fb9ef8a0e7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter.inc @@ -12,7 +12,6 @@ select case when variable_value-@c > 0 then 'true' else 'false' end as checked f END// DELIMITER ;// - #BF is sometimes invoked and useful --let $CF= --source bloomfilter_table_def.inc @@ -40,13 +39,25 @@ DELIMITER ;// # BUG: Prev() with prefix lookup should not use prefix bloom filter create table r1 (id1 bigint, id2 bigint, id3 bigint, v1 int, v2 text, primary key (id1, id2, id3)) engine=rocksdb DEFAULT CHARSET=latin1 collate latin1_bin; --disable_query_log -let $max = 100000; +let $max = 100; let $i = 1; + +create table t10(a int primary key); +insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t11(a int primary key); +insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; + +set @a=0; +set rocksdb_bulk_load=1; while ($i <= $max) { - let $insert = INSERT INTO r1 VALUES ($i,$i,$i,$i,$i); inc $i; - eval $insert; + eval insert into r1 select @a:=@a+1, @a, @a, @a, @a from t11; } +set rocksdb_bulk_load=0; + +drop table t10, t11; + --enable_query_log call bloom_start(); select * from r1 where id1=1 and id2 in (1) order by id3 asc; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test index 0bc0ae4e900..689753faf8d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test @@ -3,7 +3,7 @@ --source include/restart_mysqld.inc --disable_warnings -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1,t10,t11; --enable_warnings create table t1( @@ -18,13 +18,26 @@ create table t1( index t1_4(c1, c2), index t1_5(c2, c1) ) engine=rocksdb; + --disable_query_log +create table t10(a int primary key); +insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t11(a int primary key); +insert into t11 select A.a + B.a* 10 + C.a * 100 from t10 A, t10 B, t10 C; + +set @a=0; let $i=0; -while ($i<100000) +set rocksdb_bulk_load=1; +while ($i<100) { inc $i; - eval insert t1(id, i1, i2, c1, c2) values($i, $i, $i div 10, $i, $i div 10); + eval insert into t1 select (@a:=@a+1), @a, @a div 10, @a, @a div 10 from t11; } +set rocksdb_bulk_load=0; + +drop table t10; +drop table t11; --enable_query_log # Flush memtable out to SST and display index cardinalities diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index ce425e9a65e..e677ea3e674 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -4134,8 +4134,10 @@ void spider_db_discard_multiple_result( if (!conn->db_conn->cmp_request_key_to_snd(&request_key)) break; if ((result = conn->db_conn->use_result(&request_key, &error_num))) + { result->free_result(); delete result; + } } while (!conn->db_conn->next_result()); DBUG_VOID_RETURN; } diff --git a/storage/xtradb/btr/btr0scrub.cc b/storage/xtradb/btr/btr0scrub.cc index 24c84ed301b..1b10b79838d 100644 --- a/storage/xtradb/btr/btr0scrub.cc +++ b/storage/xtradb/btr/btr0scrub.cc @@ -886,17 +886,15 @@ btr_scrub_update_total_stat(btr_scrub_t *scrub_data) memset(&scrub_data->scrub_stat, 0, sizeof(scrub_data->scrub_stat)); } -/**************************************************************//** -Complete iterating a space */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data) /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data) { + ut_ad(scrub_data->scrubbing); btr_scrub_table_close_for_thread(scrub_data); btr_scrub_update_total_stat(scrub_data); - return scrub_data->scrubbing; } /********************************************************************* diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index 71b97b770e1..bf384390a98 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -41,6 +41,7 @@ Created April 08, 2011 Vasil Dimov #include "sync0rw.h" /* rw_lock_s_lock() */ #include "ut0byte.h" /* ut_ull_create() */ #include "ut0sort.h" /* UT_SORT_FUNCTION_BODY */ +#include "mysql/service_wsrep.h" /* wsrep_recovery */ enum status_severity { STATUS_INFO, @@ -693,7 +694,13 @@ DECLARE_THREAD(buf_dump_thread)(void*) buf_load_status(STATUS_INFO, "Loading buffer pool(s) not yet started"); if (srv_buffer_pool_load_at_startup) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ buf_load(); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } while (!SHUTTING_DOWN()) { @@ -717,8 +724,14 @@ DECLARE_THREAD(buf_dump_thread)(void*) } if (srv_buffer_pool_dump_at_shutdown && srv_fast_shutdown != 2) { +#ifdef WITH_WSREP + if (!wsrep_recovery) { +#endif /* WITH_WSREP */ buf_dump(FALSE /* ignore shutdown down flag, keep going even if we are in a shutdown state */); +#ifdef WITH_WSREP + } +#endif /* WITH_WSREP */ } srv_buf_dump_thread_active = false; diff --git a/storage/xtradb/buf/buf0rea.cc b/storage/xtradb/buf/buf0rea.cc index b2b737b8d40..76b71550710 100644 --- a/storage/xtradb/buf/buf0rea.cc +++ b/storage/xtradb/buf/buf0rea.cc @@ -428,13 +428,14 @@ read_ahead: space, i); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Random readahead failed to decrypt page " + "Random readahead failed to decrypt page or page corrupted " ULINTPF ":" ULINTPF ".", i, space); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in random readahead", err, ut_strerr(err)); } } } @@ -570,13 +571,14 @@ buf_read_page_async( break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Async page read failed to decrypt page " + "Async page read failed to decrypt page or page corrupted " ULINTPF ":" ULINTPF ".", space, offset); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in async page read", err, ut_strerr(err)); } srv_stats.buf_pool_reads.add(count); @@ -863,13 +865,14 @@ buf_read_ahead_linear( break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Linear readahead failed to decrypt page " + "Linear readahead failed to decrypt page or page corrupted" ULINTPF ":" ULINTPF ".", i, space); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in linear readahead", err, ut_strerr(err)); } } } @@ -963,13 +966,14 @@ tablespace_deleted: ibuf_delete_for_discarded_space(space_ids[i]); break; case DB_DECRYPTION_FAILED: + case DB_PAGE_CORRUPTED: ib_logf(IB_LOG_LEVEL_ERROR, - "Failed to decrypt insert buffer page " + "Failed to decrypt insert buffer page or page corrupted " ULINTPF ":" ULINTPF ".", space_ids[i], page_nos[i]); break; default: - ut_error; + ib_logf(IB_LOG_LEVEL_FATAL, "Error %u (%s) in insert buffer read", err, ut_strerr(err)); } } diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index fa4d105e7dc..81b1fd362af 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -191,7 +191,12 @@ fil_crypt_get_latest_key_version( crypt_data->min_key_version, key_version, srv_fil_crypt_rotate_key_age)) { - os_event_set(fil_crypt_threads_event); + /* Below event seen as NULL-pointer at startup + when new database was created and we create a + checkpoint. Only seen when debugging. */ + if (fil_crypt_threads_inited) { + os_event_set(fil_crypt_threads_event); + } } } @@ -1398,7 +1403,7 @@ fil_crypt_realloc_iops( DBUG_PRINT("ib_crypt", ("thr_no: %u only waited %lu%% skip re-estimate.", state->thread_no, - (100 * state->cnt_waited) / state->batch)); + (100 * state->cnt_waited) / (state->batch ? state->batch : 1))); } if (state->estimated_max_iops <= state->allocated_iops) { @@ -1501,7 +1506,7 @@ fil_crypt_find_space_to_rotate( /* we need iops to start rotating */ while (!state->should_shutdown() && !fil_crypt_alloc_iops(state)) { os_event_reset(fil_crypt_threads_event); - os_event_wait_time(fil_crypt_threads_event, 1000000); + os_event_wait_time(fil_crypt_threads_event, 100000); } if (state->should_shutdown()) { @@ -1649,20 +1654,6 @@ fil_crypt_find_page_to_rotate( return found; } -/*********************************************************************** -Check if a page is uninitialized (doesn't need to be rotated) -@param[in] frame Page to check -@param[in] zip_size zip_size or 0 -@return true if page is uninitialized, false if not. */ -static inline -bool -fil_crypt_is_page_uninitialized( - const byte *frame, - uint zip_size) -{ - return (buf_page_is_zeroes(frame, zip_size)); -} - #define fil_crypt_get_page_throttle(state,offset,mtr,sleeptime_ms) \ fil_crypt_get_page_throttle_func(state, offset, mtr, \ sleeptime_ms, __FILE__, __LINE__) @@ -1823,6 +1814,7 @@ fil_crypt_rotate_page( fil_space_crypt_t *crypt_data = space->crypt_data; ut_ad(space->n_pending_ops > 0); + ut_ad(offset > 0); /* In fil_crypt_thread where key rotation is done we have acquired space and checked that this space is not yet @@ -1851,31 +1843,40 @@ fil_crypt_rotate_page( byte* frame = buf_block_get_frame(block); uint kv = mach_read_from_4(frame+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - /* check if tablespace is closing after reading page */ - if (!space->is_stopping()) { - - if (kv == 0 && - fil_crypt_is_page_uninitialized(frame, zip_size)) { - ; - } else if (fil_crypt_needs_rotation( - crypt_data->encryption, - kv, key_state->key_version, - key_state->rotate_key_age)) { - - modified = true; - - /* force rotation by dummy updating page */ - mlog_write_ulint(frame + - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, - space_id, MLOG_4BYTES, &mtr); - - /* statistics */ - state->crypt_stat.pages_modified++; - } else { - if (crypt_data->is_encrypted()) { - if (kv < state->min_key_version_found) { - state->min_key_version_found = kv; - } + if (space->is_stopping()) { + /* The tablespace is closing (in DROP TABLE or + TRUNCATE TABLE or similar): avoid further access */ + } else if (!*reinterpret_cast<uint32_t*>(FIL_PAGE_OFFSET + + frame)) { + /* It looks like this page was never + allocated. Because key rotation is accessing + pages in a pattern that is unlike the normal + B-tree and undo log access pattern, we cannot + invoke fseg_page_is_free() here, because that + could result in a deadlock. If we invoked + fseg_page_is_free() and released the + tablespace latch before acquiring block->lock, + then the fseg_page_is_free() information + could be stale already. */ + ut_ad(kv == 0); + ut_ad(page_get_space_id(frame) == 0); + } else if (fil_crypt_needs_rotation( + crypt_data->encryption, + kv, key_state->key_version, + key_state->rotate_key_age)) { + + modified = true; + + /* force rotation by dummy updating page */ + mlog_write_ulint(frame + FIL_PAGE_SPACE_ID, + space_id, MLOG_4BYTES, &mtr); + + /* statistics */ + state->crypt_stat.pages_modified++; + } else { + if (crypt_data->is_encrypted()) { + if (kv < state->min_key_version_found) { + state->min_key_version_found = kv; } } @@ -2126,7 +2127,8 @@ fil_crypt_complete_rotate_space( mutex_exit(&crypt_data->mutex); /* all threads must call btr_scrub_complete_space wo/ mutex held */ - if (btr_scrub_complete_space(&state->scrub_data) == true) { + if (state->scrub_data.scrubbing) { + btr_scrub_complete_space(&state->scrub_data); if (should_flush) { /* only last thread updates last_scrub_completed */ ut_ad(crypt_data); @@ -2302,7 +2304,7 @@ fil_crypt_set_thread_cnt( os_thread_create(fil_crypt_thread, NULL, &rotation_thread_id); ib_logf(IB_LOG_LEVEL_INFO, - "Creating #%d thread id %lu total threads %u.", + "Creating #%d encryption thread id %lu total threads %u.", i+1, os_thread_pf(rotation_thread_id), new_cnt); } } else if (new_cnt < srv_n_fil_crypt_threads) { @@ -2314,7 +2316,13 @@ fil_crypt_set_thread_cnt( while(srv_n_fil_crypt_threads_started != srv_n_fil_crypt_threads) { os_event_reset(fil_crypt_event); - os_event_wait_time(fil_crypt_event, 1000000); + os_event_wait_time(fil_crypt_event, 100000); + } + + /* Send a message to encryption threads that there could be + something to do. */ + if (srv_n_fil_crypt_threads) { + os_event_set(fil_crypt_threads_event); } } @@ -2460,9 +2468,10 @@ fil_space_crypt_get_status( ut_ad(space->n_pending_ops > 0); fil_crypt_read_crypt_data(const_cast<fil_space_t*>(space)); - status->space = space->id; + status->space = ULINT_UNDEFINED; if (fil_space_crypt_t* crypt_data = space->crypt_data) { + status->space = space->id; mutex_enter(&crypt_data->mutex); status->scheme = crypt_data->type; status->keyserver_requests = crypt_data->keyserver_requests; diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index fdd09a6034e..a8752059b5b 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -654,7 +654,7 @@ fil_node_open_file( page = static_cast<byte*>(ut_align(buf2, UNIV_PAGE_SIZE)); success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE); - srv_stats.page0_read.add(1); + srv_stats.page0_read.inc(); const ulint space_id = fsp_header_get_space_id(page); ulint flags = fsp_header_get_flags(page); @@ -2268,7 +2268,7 @@ fil_write_flushed_lsn( /* If tablespace is not encrypted, stamp flush_lsn to first page of all system tablespace datafiles to avoid unnecessary error messages on possible downgrade. */ - if (space->crypt_data->min_key_version == 0) { + if (!space->crypt_data || space->crypt_data->min_key_version == 0) { fil_node_t* node; ulint sum_of_sizes = 0; @@ -2372,8 +2372,10 @@ the first page of a first data file at database startup. @param[out] space_id tablepspace ID @param[out] flushed_lsn flushed lsn value @param[out] crypt_data encryption crypt data -@retval NULL on success, or if innodb_force_recovery is set -@return pointer to an error message string */ +@param[in] check_first_page true if first page contents + should be checked +@return NULL on success, or if innodb_force_recovery is set +@retval pointer to an error message string */ UNIV_INTERN const char* fil_read_first_page( @@ -2382,7 +2384,8 @@ fil_read_first_page( ulint* flags, ulint* space_id, lsn_t* flushed_lsn, - fil_space_crypt_t** crypt_data) + fil_space_crypt_t** crypt_data, + bool check_first_page) { byte* buf; byte* page; @@ -2411,35 +2414,39 @@ fil_read_first_page( os_file_read(data_file, page, 0, UNIV_PAGE_SIZE); - srv_stats.page0_read.add(1); + srv_stats.page0_read.inc(); /* The FSP_HEADER on page 0 is only valid for the first file in a tablespace. So if this is not the first datafile, leave *flags and *space_id as they were read from the first file and do not validate the first page. */ if (!one_read_already) { - *space_id = fsp_header_get_space_id(page); - *flags = fsp_header_get_flags(page); - - if (flushed_lsn) { - *flushed_lsn = mach_read_from_8(page + + /* Undo tablespace does not contain correct FSP_HEADER, + and actually we really need to read only crypt_data. */ + if (check_first_page) { + *space_id = fsp_header_get_space_id(page); + *flags = fsp_header_get_flags(page); + + if (flushed_lsn) { + *flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - } + } - if (!fsp_flags_is_valid(*flags)) { - ulint cflags = fsp_flags_convert_from_101(*flags); - if (cflags == ULINT_UNDEFINED) { - ib_logf(IB_LOG_LEVEL_ERROR, - "Invalid flags 0x%x in tablespace %u", - unsigned(*flags), unsigned(*space_id)); - return "invalid tablespace flags"; - } else { - *flags = cflags; + if (!fsp_flags_is_valid(*flags)) { + ulint cflags = fsp_flags_convert_from_101(*flags); + if (cflags == ULINT_UNDEFINED) { + ib_logf(IB_LOG_LEVEL_ERROR, + "Invalid flags 0x%x in tablespace %u", + unsigned(*flags), unsigned(*space_id)); + return "invalid tablespace flags"; + } else { + *flags = cflags; + } } - } - if (!(IS_XTRABACKUP() && srv_backup_mode)) { - check_msg = fil_check_first_page(page, *space_id, *flags); + if (!(IS_XTRABACKUP() && srv_backup_mode)) { + check_msg = fil_check_first_page(page, *space_id, *flags); + } } /* Possible encryption crypt data is also stored only to first page diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index df8c6ffe222..02683e298cb 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -728,7 +729,11 @@ fsp_header_init(ulint space_id, ulint size, mtr_t* mtr) fil_space_t* space = fil_space_acquire(space_id); ut_ad(space); - if (space->crypt_data) { + /* Write encryption metadata to page 0 if tablespace is + encrypted or encryption is disabled by table option. */ + if (space->crypt_data && + (space->crypt_data->should_encrypt() || + space->crypt_data->not_encrypted())) { space->crypt_data->write_page0(page, mtr); } @@ -2044,15 +2049,6 @@ fseg_create_general( mtr_x_lock(latch, mtr); - if (rw_lock_get_x_lock_count(latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - if (!has_done_reservation) { success = fsp_reserve_free_extents(&n_reserved, space, 2, FSP_NORMAL, mtr); @@ -2623,15 +2619,6 @@ fseg_alloc_free_page_general( mtr_x_lock(latch, mtr); - if (rw_lock_get_x_lock_count(latch) == 1) { - /* This thread did not own the latch before this call: free - excess pages from the insert buffer free list */ - - if (space == IBUF_SPACE_ID) { - ibuf_free_excess_pages(); - } - } - inode = fseg_inode_get(seg_header, space, zip_size, mtr); if (!has_done_reservation diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 6b67a7e8ac0..627c0734b20 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -17107,6 +17107,10 @@ innobase_commit_by_xid( DBUG_ASSERT(hton == innodb_hton_ptr); + if (high_level_read_only) { + return(XAER_RMFAIL); + } + trx = trx_get_trx_by_xid(xid); if (trx) { @@ -17134,8 +17138,11 @@ innobase_rollback_by_xid( DBUG_ASSERT(hton == innodb_hton_ptr); - trx = trx_get_trx_by_xid(xid); + if (high_level_read_only) { + return(XAER_RMFAIL); + } + trx = trx_get_trx_by_xid(xid); if (trx) { int ret = innobase_rollback_trx(trx); trx_free_for_background(trx); @@ -19803,7 +19810,7 @@ wsrep_fake_trx_id( mutex_enter(&trx_sys->mutex); trx_id_t trx_id = trx_sys_get_new_trx_id(); mutex_exit(&trx_sys->mutex); - + WSREP_DEBUG("innodb fake trx id: %lu thd: %s", trx_id, wsrep_thd_query(thd)); wsrep_ws_handle_for_trx(wsrep_thd_ws_handle(thd), trx_id); } diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc index 9cef04c4244..ca2c76c31ad 100644 --- a/storage/xtradb/handler/i_s.cc +++ b/storage/xtradb/handler/i_s.cc @@ -8524,6 +8524,12 @@ i_s_dict_fill_tablespaces_encryption( fil_space_crypt_get_status(space, &status); + /* If tablespace id does not match, we did not find + encryption information for this tablespace. */ + if (!space->crypt_data || space->id != status.space) { + goto skip; + } + OK(fields[TABLESPACES_ENCRYPTION_SPACE]->store(space->id)); OK(field_store_string(fields[TABLESPACES_ENCRYPTION_NAME], @@ -8558,6 +8564,7 @@ i_s_dict_fill_tablespaces_encryption( OK(schema_table_store_record(thd, table_to_fill)); +skip: DBUG_RETURN(0); } /*******************************************************************//** diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc index 0445bb557e1..b920c2ae594 100644 --- a/storage/xtradb/ibuf/ibuf0ibuf.cc +++ b/storage/xtradb/ibuf/ibuf0ibuf.cc @@ -2216,6 +2216,8 @@ ibuf_remove_free_page(void) page_t* root; page_t* bitmap_page; + log_free_check(); + mtr_start(&mtr); /* Acquire the fsp latch before the ibuf header, obeying the latching @@ -2327,22 +2329,7 @@ ibuf_free_excess_pages(void) { ulint i; -#ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL), - RW_LOCK_EX)); -#endif /* UNIV_SYNC_DEBUG */ - - ut_ad(rw_lock_get_x_lock_count( - fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1); - - /* NOTE: We require that the thread did not own the latch before, - because then we know that we can obey the correct latching order - for ibuf latches */ - - if (!ibuf) { - /* Not yet initialized; not sure if this is possible, but - does no harm to check for it. */ - + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { return; } diff --git a/storage/xtradb/include/btr0scrub.h b/storage/xtradb/include/btr0scrub.h index 608266c206d..8029cc91005 100644 --- a/storage/xtradb/include/btr0scrub.h +++ b/storage/xtradb/include/btr0scrub.h @@ -154,13 +154,10 @@ btr_scrub_start_space( ulint space, /*!< in: space */ btr_scrub_t* scrub_data); /*!< in/out: scrub data */ -/**************************************************************** -Complete iterating a space -* @return true if space was scrubbed */ +/** Complete iterating a space. +@param[in,out] scrub_data scrub data */ UNIV_INTERN -bool -btr_scrub_complete_space( -/*=====================*/ - btr_scrub_t* scrub_data); /*!< in/out: scrub data */ +void +btr_scrub_complete_space(btr_scrub_t* scrub_data); #endif diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 6eab5db6883..a33cec65ed5 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -804,8 +804,10 @@ the first page of a first data file at database startup. @param[out] space_id tablepspace ID @param[out] flushed_lsn flushed lsn value @param[out] crypt_data encryption crypt data -@retval NULL on success, or if innodb_force_recovery is set -@return pointer to an error message string */ +@param[in] check_first_page true if first page contents + should be checked +@return NULL on success, or if innodb_force_recovery is set +@retval pointer to an error message string */ UNIV_INTERN const char* fil_read_first_page( @@ -814,7 +816,8 @@ fil_read_first_page( ulint* flags, ulint* space_id, lsn_t* flushed_lsn, - fil_space_crypt_t** crypt_data) + fil_space_crypt_t** crypt_data, + bool check_first_page=true) MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/include/trx0sys.h b/storage/xtradb/include/trx0sys.h index 9bfffd09532..859adef0f0f 100644 --- a/storage/xtradb/include/trx0sys.h +++ b/storage/xtradb/include/trx0sys.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -328,20 +329,29 @@ UNIV_INTERN void trx_sys_print_mysql_binlog_offset(void); /*===================================*/ + #ifdef WITH_WSREP -/** Update WSREP checkpoint XID in sys header. */ + +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( - const XID* xid, /*!< in: WSREP XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr); /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr); -/** Read WSREP checkpoint XID from sys header. +/** Read WSREP checkpoint XID from sys header. +@param[out] xid Transaction XID @return true on success, false on error. */ +UNIV_INTERN bool trx_sys_read_wsrep_checkpoint( XID* xid); /*!< out: WSREP XID */ #endif /* WITH_WSREP */ + /*****************************************************************//** Prints to stderr the MySQL master log offset info in the trx system header if the magic number shows it valid. */ @@ -570,13 +580,71 @@ this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */ within that file */ #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */ +/** Memory map TRX_SYS_PAGE_NO = 5 when UNIV_PAGE_SIZE = 4096 + +0...37 FIL_HEADER +38...45 TRX_SYS_TRX_ID_STORE +46...55 TRX_SYS_FSEG_HEADER (FSEG_HEADER_SIZE == 10) +56 TRX_SYS_RSEGS + 56...59 TRX_SYS_RSEG_SPACE for slot 0 + 60...63 TRX_SYS_RSEG_PAGE_NO for slot 0 + 64...67 TRX_SYS_RSEG_SPACE for slot 1 + 68...71 TRX_SYS_RSEG_PAGE_NO for slot 1 +.... + 594..597 TRX_SYS_RSEG_SPACE for slot 72 + 598..601 TRX_SYS_RSEG_PAGE_NO for slot 72 +... + ...1063 TRX_SYS_RSEG_PAGE_NO for slot 126 + +(UNIV_PAGE_SIZE-3500 WSREP ::: FAIL would overwrite undo tablespace +space_id, page_no pairs :::) +596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +600 TRX_SYS_WSREP_XID_FORMAT +604 TRX_SYS_WSREP_XID_GTRID_LEN +608 TRX_SYS_WSREP_XID_BQUAL_LEN +612 TRX_SYS_WSREP_XID_DATA (len = 128) +739 TRX_SYS_WSREP_XID_DATA_END + +FIXED WSREP XID info offsets for 4k page size 10.0.32-galera +(UNIV_PAGE_SIZE-2500) +1596 TRX_SYS_WSREP_XID_INFO TRX_SYS_WSREP_XID_MAGIC_N_FLD +1600 TRX_SYS_WSREP_XID_FORMAT +1604 TRX_SYS_WSREP_XID_GTRID_LEN +1608 TRX_SYS_WSREP_XID_BQUAL_LEN +1612 TRX_SYS_WSREP_XID_DATA (len = 128) +1739 TRX_SYS_WSREP_XID_DATA_END + +(UNIV_PAGE_SIZE - 2000 MYSQL MASTER LOG) +2096 TRX_SYS_MYSQL_MASTER_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +2100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +2104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +2108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 1000 MYSQL LOG) +3096 TRX_SYS_MYSQL_LOG_INFO TRX_SYS_MYSQL_LOG_MAGIC_N_FLD +3100 TRX_SYS_MYSQL_LOG_OFFSET_HIGH +3104 TRX_SYS_MYSQL_LOG_OFFSET_LOW +3108 TRX_SYS_MYSQL_LOG_NAME + +(UNIV_PAGE_SIZE - 200 DOUBLEWRITE) +3896 TRX_SYS_DOUBLEWRITE TRX_SYS_DOUBLEWRITE_FSEG +3906 TRX_SYS_DOUBLEWRITE_MAGIC +3910 TRX_SYS_DOUBLEWRITE_BLOCK1 +3914 TRX_SYS_DOUBLEWRITE_BLOCK2 +3918 TRX_SYS_DOUBLEWRITE_REPEAT +3930 TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N + +(UNIV_PAGE_SIZE - 8, TAILER) +4088..4096 FIL_TAILER + +*/ #ifdef WITH_WSREP -/* The offset to WSREP XID headers */ -#define TRX_SYS_WSREP_XID_INFO (UNIV_PAGE_SIZE - 3500) +/** The offset to WSREP XID headers */ +#define TRX_SYS_WSREP_XID_INFO (ut_max(UNIV_PAGE_SIZE - 3500, 1596)) #define TRX_SYS_WSREP_XID_MAGIC_N_FLD 0 #define TRX_SYS_WSREP_XID_MAGIC_N 0x77737265 -/* XID field: formatID, gtrid_len, bqual_len, xid_data */ +/** XID field: formatID, gtrid_len, bqual_len, xid_data */ #define TRX_SYS_WSREP_XID_LEN (4 + 4 + 4 + XIDDATASIZE) #define TRX_SYS_WSREP_XID_FORMAT 4 #define TRX_SYS_WSREP_XID_GTRID_LEN 8 diff --git a/storage/xtradb/log/log0recv.cc b/storage/xtradb/log/log0recv.cc index fb64309cee4..0137cb44571 100644 --- a/storage/xtradb/log/log0recv.cc +++ b/storage/xtradb/log/log0recv.cc @@ -842,10 +842,8 @@ not_consistent: fprintf(stderr, "InnoDB: No valid checkpoint found.\n" - "InnoDB: If you are attempting downgrade" - " from MySQL 5.7.9 or later,\n" - "InnoDB: please refer to " REFMAN - "upgrading-downgrading.html\n" + "InnoDB: A downgrade from MariaDB 10.2.2" + " or later is not supported.\n" "InnoDB: If this error appears when you are" " creating an InnoDB database,\n" "InnoDB: the problem may be that during" diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index 00b8ce17b26..33f8ec443dd 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -38,6 +38,7 @@ Created 4/20/1996 Heikki Tuuri #include "btr0btr.h" #include "btr0cur.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "que0que.h" #include "row0upd.h" #include "row0sel.h" @@ -936,7 +937,7 @@ row_ins_invalidate_query_cache( mem_free(buf); } #ifdef WITH_WSREP -dberr_t wsrep_append_foreign_key(trx_t *trx, +dberr_t wsrep_append_foreign_key(trx_t *trx, dict_foreign_t* foreign, const rec_t* clust_rec, dict_index_t* clust_index, @@ -1463,7 +1464,7 @@ row_ins_check_foreign_constraint( rec_offs_init(offsets_); #ifdef WITH_WSREP - upd_node= NULL; + upd_node= NULL; #endif /* WITH_WSREP */ run_again: #ifdef UNIV_SYNC_DEBUG @@ -1654,7 +1655,7 @@ run_again: err = wsrep_append_foreign_key( thr_get_trx(thr), foreign, - rec, + rec, check_index, check_ref, (upd_node) ? TRUE : FALSE); @@ -3064,6 +3065,11 @@ row_ins_sec_index_entry( if (err == DB_FAIL) { mem_heap_empty(heap); + if (index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } + /* Try then pessimistic descent to the B-tree */ log_free_check(); diff --git a/storage/xtradb/row/row0uins.cc b/storage/xtradb/row/row0uins.cc index f14a4ef9bcf..29660055fad 100644 --- a/storage/xtradb/row/row0uins.cc +++ b/storage/xtradb/row/row0uins.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -201,6 +202,10 @@ row_undo_ins_remove_sec_low( mtr_s_lock(dict_index_get_lock(index), &mtr); } else { ut_ad(mode == BTR_MODIFY_TREE); + if (index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } mtr_x_lock(dict_index_get_lock(index), &mtr); } diff --git a/storage/xtradb/row/row0umod.cc b/storage/xtradb/row/row0umod.cc index 8deba4f00a5..f23d7e9dc68 100644 --- a/storage/xtradb/row/row0umod.cc +++ b/storage/xtradb/row/row0umod.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -35,6 +36,7 @@ Created 2/27/1997 Heikki Tuuri #include "trx0roll.h" #include "btr0btr.h" #include "mach0data.h" +#include "ibuf0ibuf.h" #include "row0undo.h" #include "row0vers.h" #include "row0log.h" @@ -409,6 +411,11 @@ row_undo_mod_del_mark_or_remove_sec_low( log_free_check(); mtr_start_trx(&mtr, thr_get_trx(thr)); + if (mode == BTR_MODIFY_TREE + && index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the @@ -581,6 +588,11 @@ row_undo_mod_del_unmark_sec_and_undo_update( log_free_check(); mtr_start_trx(&mtr, thr_get_trx(thr)); + if (mode == BTR_MODIFY_TREE + && index->space == IBUF_SPACE_ID + && !dict_index_is_unique(index)) { + ibuf_free_excess_pages(); + } if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 1156cbe4b4c..b09021722be 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -1989,6 +1989,8 @@ row_upd_sec_index_entry( } #ifdef WITH_WSREP if (err == DB_SUCCESS && !referenced && + wsrep_on(trx->mysql_thd) && + !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && @@ -2277,7 +2279,7 @@ err_exit: } } #ifdef WITH_WSREP - if (!referenced && + if (!referenced && wsrep_on(trx->mysql_thd) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign @@ -2545,10 +2547,11 @@ row_upd_del_mark_clust_rec( node, pcur, index->table, index, offsets, thr, mtr); } #ifdef WITH_WSREP - if (err == DB_SUCCESS && !referenced && + trx_t* trx = thr_get_trx(thr) ; + + if (err == DB_SUCCESS && !referenced && trx && wsrep_on(trx->mysql_thd) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && - thr_get_trx(thr) && foreign ) { err = wsrep_row_upd_check_foreign_constraints( diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index fd129c3e55f..e89b4c4d323 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -73,8 +73,7 @@ Created 2/16/1996 Heikki Tuuri #include "btr0defragment.h" #include "ut0timer.h" #include "btr0scrub.h" - -#include <mysql/service_wsrep.h> +#include "mysql/service_wsrep.h" /* wsrep_recovery */ #ifndef UNIV_HOTBACKUP # include "trx0rseg.h" @@ -891,7 +890,7 @@ open_or_create_data_files( bool one_created = false; os_offset_t size; ulint flags; - ulint space; + ulint space = 0; ulint rounded_size_pages; char name[10000]; fil_space_crypt_t* crypt_data=NULL; @@ -1228,11 +1227,6 @@ check_first_page: ut_a(ret); if (i == 0) { - if (!crypt_data) { - crypt_data = fil_space_create_crypt_data(FIL_ENCRYPTION_DEFAULT, - FIL_DEFAULT_ENCRYPTION_KEY); - } - flags = FSP_FLAGS_PAGE_SSIZE(); fil_space_create(name, 0, flags, FIL_TABLESPACE, @@ -1369,11 +1363,30 @@ srv_undo_tablespace_open( size = os_file_get_size(fh); ut_a(size != (os_offset_t) -1); + /* Load the tablespace into InnoDB's internal + data structures. */ + + const char* check_msg; + fil_space_crypt_t* crypt_data = NULL; + + /* Set the compressed page size to 0 (non-compressed) */ + flags = FSP_FLAGS_PAGE_SSIZE(); + + /* Read first page to find out does the crypt_info + exists on undo tablespace. */ + check_msg = fil_read_first_page( + fh, FALSE, &flags, &space, + NULL, &crypt_data, false); + ret = os_file_close(fh); ut_a(ret); - /* Load the tablespace into InnoDB's internal - data structures. */ + if (check_msg) { + ib_logf(IB_LOG_LEVEL_ERROR, + "%s in data file %s", + check_msg, name); + return (err); + } /* We set the biggest space id to the undo tablespace because InnoDB hasn't opened any other tablespace apart @@ -1381,10 +1394,8 @@ srv_undo_tablespace_open( fil_set_max_space_id_if_bigger(space); - /* Set the compressed page size to 0 (non-compressed) */ - flags = FSP_FLAGS_PAGE_SSIZE(); fil_space_create(name, space, flags, FIL_TABLESPACE, - NULL /* no encryption */, + crypt_data, true /* create */); ut_a(fil_validate()); @@ -1491,6 +1502,18 @@ srv_undo_tablespaces_init( n_undo_tablespaces = n_conf_tablespaces; undo_tablespace_ids[n_conf_tablespaces] = ULINT_UNDEFINED; + + if (backup_mode) { + ut_ad(!create_new_db); + /* MDEV-13561 FIXME: Determine srv_undo_space_id_start + from the undo001 file. */ + srv_undo_space_id_start = 1; + + for (i = 0; i < n_undo_tablespaces; i++) { + undo_tablespace_ids[i] + = i + srv_undo_space_id_start; + } + } } /* Open all the undo tablespaces that are currently in use. If we @@ -3090,15 +3113,12 @@ files_checked: "wsrep recovery."); } #endif /* WITH_WSREP */ - /* Create thread(s) that handles key rotation */ fil_system_enter(); + btr_scrub_init(); fil_crypt_threads_init(); fil_system_exit(); - /* Init data for datafile scrub threads */ - btr_scrub_init(); - /* Initialize online defragmentation. */ btr_defragment_init(); btr_defragment_thread_active = true; diff --git a/storage/xtradb/trx/trx0sys.cc b/storage/xtradb/trx/trx0sys.cc index 9accb4ef303..d2b1a8f9f0d 100644 --- a/storage/xtradb/trx/trx0sys.cc +++ b/storage/xtradb/trx/trx0sys.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -327,121 +328,123 @@ trx_sys_print_mysql_binlog_offset(void) static long long trx_sys_cur_xid_seqno = -1; static unsigned char trx_sys_cur_xid_uuid[16]; -long long read_wsrep_xid_seqno(const XID* xid) +/** Read WSREP XID seqno */ +static inline long long read_wsrep_xid_seqno(const XID* xid) { - long long seqno; - memcpy(&seqno, xid->data + 24, sizeof(long long)); - return seqno; + long long seqno; + memcpy(&seqno, xid->data + 24, sizeof(long long)); + return seqno; } -void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) +/** Read WSREP XID UUID */ +static inline void read_wsrep_xid_uuid(const XID* xid, unsigned char* buf) { - memcpy(buf, xid->data + 8, 16); + memcpy(buf, xid->data + 8, 16); } #endif /* UNIV_DEBUG */ +/** Update WSREP XID info in sys_header of TRX_SYS_PAGE_NO = 5. +@param[in] xid Transaction XID +@param[in,out] sys_header sys_header +@param[in] mtr minitransaction */ +UNIV_INTERN void trx_sys_update_wsrep_checkpoint( - const XID* xid, /*!< in: transaction XID */ - trx_sysf_t* sys_header, /*!< in: sys_header */ - mtr_t* mtr) /*!< in: mtr */ + const XID* xid, + trx_sysf_t* sys_header, + mtr_t* mtr) { #ifdef UNIV_DEBUG - { - /* Check that seqno is monotonically increasing */ - unsigned char xid_uuid[16]; - long long xid_seqno = read_wsrep_xid_seqno(xid); - read_wsrep_xid_uuid(xid, xid_uuid); - if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 16)) - { - /* - This check is a protection against the initial seqno (-1) - assigned in read_wsrep_xid_uuid(), which, if not checked, - would cause the following assertion to fail. - */ - if (xid_seqno > -1 ) - { - ut_ad(xid_seqno > trx_sys_cur_xid_seqno); - } - } - else - { - memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); - } - trx_sys_cur_xid_seqno = xid_seqno; - } + if (xid->formatID != -1 + && mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + == TRX_SYS_WSREP_XID_MAGIC_N) { + /* Check that seqno is monotonically increasing */ + unsigned char xid_uuid[16]; + long long xid_seqno = read_wsrep_xid_seqno(xid); + read_wsrep_xid_uuid(xid, xid_uuid); + + if (!memcmp(xid_uuid, trx_sys_cur_xid_uuid, 8)) { + ut_ad(xid_seqno > trx_sys_cur_xid_seqno); + trx_sys_cur_xid_seqno = xid_seqno; + } else { + memcpy(trx_sys_cur_xid_uuid, xid_uuid, 16); + } + + trx_sys_cur_xid_seqno = xid_seqno; + } #endif /* UNIV_DEBUG */ - ut_ad(xid && mtr); - ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid(xid)); - - if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD) - != TRX_SYS_WSREP_XID_MAGIC_N) { - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD, - TRX_SYS_WSREP_XID_MAGIC_N, - MLOG_4BYTES, mtr); - } - - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_FORMAT, - (int)xid->formatID, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_GTRID_LEN, - (int)xid->gtrid_length, - MLOG_4BYTES, mtr); - mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_BQUAL_LEN, - (int)xid->bqual_length, - MLOG_4BYTES, mtr); - mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_DATA, - (const unsigned char*) xid->data, - XIDDATASIZE, mtr); + ut_ad(xid && mtr); + ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const XID *)xid)); + + if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD) + != TRX_SYS_WSREP_XID_MAGIC_N) { + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD, + TRX_SYS_WSREP_XID_MAGIC_N, + MLOG_4BYTES, mtr); + } + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_FORMAT, + (int)xid->formatID, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_GTRID_LEN, + (int)xid->gtrid_length, + MLOG_4BYTES, mtr); + mlog_write_ulint(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_BQUAL_LEN, + (int)xid->bqual_length, + MLOG_4BYTES, mtr); + mlog_write_string(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_DATA, + (const unsigned char*) xid->data, + XIDDATASIZE, mtr); } +/** Read WSREP XID from sys_header of TRX_SYS_PAGE_NO = 5. +@param[out] xid Transaction XID +@retval true if found, false if not */ +UNIV_INTERN bool trx_sys_read_wsrep_checkpoint(XID* xid) -/*===================================*/ { - trx_sysf_t* sys_header; - mtr_t mtr; - ulint magic; + trx_sysf_t* sys_header; + mtr_t mtr; + ulint magic; - ut_ad(xid); + ut_ad(xid); mtr_start(&mtr); sys_header = trx_sysf_get(&mtr); - if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO - + TRX_SYS_WSREP_XID_MAGIC_N_FLD)) - != TRX_SYS_WSREP_XID_MAGIC_N) { - memset(xid, 0, sizeof(*xid)); - long long seqno= -1; - memcpy(xid->data + 24, &seqno, sizeof(long long)); - xid->formatID = -1; - trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); - mtr_commit(&mtr); - return false; - } - - xid->formatID = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_FORMAT); - xid->gtrid_length = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_GTRID_LEN); - xid->bqual_length = (int)mach_read_from_4( - sys_header - + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_BQUAL_LEN); - ut_memcpy(xid->data, - sys_header + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA, - XIDDATASIZE); + if ((magic = mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO + + TRX_SYS_WSREP_XID_MAGIC_N_FLD)) + != TRX_SYS_WSREP_XID_MAGIC_N) { + memset(xid, 0, sizeof(*xid)); + xid->formatID = -1; + trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr); + mtr_commit(&mtr); + return false; + } + + xid->formatID = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_FORMAT); + xid->gtrid_length = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_GTRID_LEN); + xid->bqual_length = (int)mach_read_from_4( + sys_header + + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_BQUAL_LEN); + ut_memcpy(xid->data, + sys_header + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA, + XIDDATASIZE); mtr_commit(&mtr); return true; diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 1d2f7ada54e..cfc1f83053a 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -720,25 +720,9 @@ trx_resurrect_insert( "InnoDB: Transaction " TRX_ID_FMT " was in the" " XA prepared state.\n", trx->id); - if (srv_force_recovery == 0) { - - /* XtraBackup should rollback prepared XA - transactions */ - if (IS_XTRABACKUP()) { - trx->state = TRX_STATE_ACTIVE; - } - else { - trx->state = TRX_STATE_PREPARED; - trx_sys->n_prepared_trx++; - trx_sys->n_prepared_recovered_trx++; - } - } else { - fprintf(stderr, - "InnoDB: Since innodb_force_recovery" - " > 0, we will rollback it anyway.\n"); - - trx->state = TRX_STATE_ACTIVE; - } + trx->state = TRX_STATE_PREPARED; + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } @@ -796,25 +780,14 @@ trx_resurrect_update_in_prepared_state( "InnoDB: Transaction " TRX_ID_FMT " was in the XA prepared state.\n", trx->id); - if (srv_force_recovery == 0) { - if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { - if (!IS_XTRABACKUP()) { - trx_sys->n_prepared_trx++; - trx_sys->n_prepared_recovered_trx++; - } - } else { - ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); - } - /* XtraBackup should rollback prepared XA - transactions */ - trx->state = IS_XTRABACKUP()?TRX_STATE_ACTIVE: TRX_STATE_PREPARED; + if (trx_state_eq(trx, TRX_STATE_NOT_STARTED)) { + trx_sys->n_prepared_trx++; + trx_sys->n_prepared_recovered_trx++; } else { - fprintf(stderr, - "InnoDB: Since innodb_force_recovery" - " > 0, we will rollback it anyway.\n"); - - trx->state = TRX_STATE_ACTIVE; + ut_ad(trx_state_eq(trx, TRX_STATE_PREPARED)); } + + trx->state = TRX_STATE_PREPARED; } else { trx->state = TRX_STATE_COMMITTED_IN_MEMORY; } diff --git a/win/packaging/create_msi.cmake.in b/win/packaging/create_msi.cmake.in index 4b05e61decd..c37f7ca9d1d 100644 --- a/win/packaging/create_msi.cmake.in +++ b/win/packaging/create_msi.cmake.in @@ -78,13 +78,6 @@ ELSE() ENDIF() SET(ENV{VS_UNICODE_OUTPUT}) -# Workaround for CMake bug#11452 -# Switch off the monolithic install -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=0 ${CMAKE_BINARY_DIR} - OUTPUT_QUIET -) - INCLUDE(${CMAKE_BINARY_DIR}/CPackConfig.cmake) @@ -441,11 +434,4 @@ ENDIF() CONFIGURE_FILE(${CPACK_PACKAGE_FILE_NAME}.msi ${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}.msi COPYONLY) - -# Workaround for CMake bug#11452 -# Switch monolithic install on again -EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -DCPACK_MONOLITHIC_INSTALL=1 ${CMAKE_BINARY_DIR} - OUTPUT_QUIET -) |