diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-08-31 09:28:59 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-08-31 09:30:40 +0300 |
commit | a36c369bda753b66660ffe61f566639665af89d8 (patch) | |
tree | 20d8fcead2302b9688627c0742b2b2889ca0ab71 | |
parent | eca238aea7925b3f165db7c8a0e03c5b3b179cf9 (diff) | |
parent | b29f26d774033d9dda6c1a519657f1092c964f12 (diff) | |
download | mariadb-git-a36c369bda753b66660ffe61f566639665af89d8.tar.gz |
Merge 10.1 into 10.2
For running the Galera tests, the variable my_disable_leak_check
was set to true in order to avoid assertions due to memory leaks
at shutdown.
Some adjustments due to MDEV-13625 (merge InnoDB tests from MySQL 5.6)
were performed. The most notable behaviour changes from 10.0 and 10.1
are the following:
* innodb.innodb-table-online: adjustments for the DROP COLUMN
behaviour change (MDEV-11114, MDEV-13613)
* innodb.innodb-index-online-fk: the removal of a (1,NULL) record
from the result; originally removed in MySQL 5.7 in the
Oracle Bug #16244691 fix
https://github.com/mysql/mysql-server/commit/377774689bf6a16af74182753fe950d514c2c6dd
* innodb.create-index-debug: disabled due to MDEV-13680
(the MySQL Bug #77497 fix was not merged from 5.6 to 5.7.10)
* innodb.innodb-alter-autoinc: MariaDB 10.2 behaves like MySQL 5.6/5.7,
while MariaDB 10.0 and 10.1 assign different values when
auto_increment_increment or auto_increment_offset are used.
Also MySQL 5.6/5.7 exhibit different behaviour between
LGORITHM=INPLACE and ALGORITHM=COPY, so something needs to be tested
and fixed in both MariaDB 10.0 and 10.2.
* innodb.innodb-wl5980-alter: disabled because it would trigger an
InnoDB assertion failure (MDEV-13668 may need additional effort in 10.2)
208 files changed, 10256 insertions, 941 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index f8f9721d583..b4bd2b65276 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -4022,7 +4022,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/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/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/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 95c5967d463..f3f206e29c7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -197,6 +197,7 @@ my @DEFAULT_SUITES= qw( unit- vcol- wsrep- + galera- ); my $opt_suites; @@ -3090,14 +3091,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 ) { @@ -3116,13 +3119,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 @@ -3137,98 +3133,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, @@ -5153,6 +5159,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/mysqld--help.result b/mysql-test/r/mysqld--help.result index 9dc8b454568..bcc985a8a50 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/suite/encryption/disabled.def b/mysql-test/suite/encryption/disabled.def index d92d3495cb8..49f7f94729d 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 +innodb_encryption : an adjustment for MDEV-13583 is needed diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 5a10d161211..8c3c9550890 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -1,47 +1,57 @@ -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 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..2307c35361c 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort.result +++ b/mysql-test/suite/galera/r/galera_bf_abort.result @@ -1,8 +1,13 @@ 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 wsrep_local_aborts_increment 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_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_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_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_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_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_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_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..e1d6dd9d61d 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; 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_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_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/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_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_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/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/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/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/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 100644 --- 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/handler.cc b/sql/handler.cc index d5d57f3e9a8..6b7185ec1c7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -72,6 +72,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; @@ -648,6 +656,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; @@ -1659,6 +1671,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(); @@ -1853,7 +1870,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++; @@ -1870,19 +1887,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) @@ -1904,7 +1933,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/log.cc b/sql/log.cc index 5a5f3cdf808..de501d94100 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -9317,8 +9317,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 06e0c86ecf4..01d65413f08 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9311,8 +9311,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/sql_class.cc b/sql/sql_class.cc index 1b176d35512..e8fe4afc690 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -873,6 +873,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); @@ -1304,6 +1306,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) diff --git a/sql/sql_class.h b/sql/sql_class.h index ba72c46556d..e1be5dc91f0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4308,6 +4308,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 5ebc9f0087d..efa48c6e241 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3385,6 +3385,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; } @@ -3423,21 +3424,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; @@ -3566,6 +3567,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); @@ -4144,6 +4146,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; } @@ -4151,15 +4154,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: @@ -4223,8 +4224,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)) @@ -4235,6 +4235,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) && @@ -4277,9 +4278,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; } @@ -4349,10 +4348,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()) { @@ -4387,10 +4382,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) && @@ -4449,6 +4444,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); @@ -4572,6 +4568,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) && @@ -4632,6 +4629,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; @@ -4712,19 +4710,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 @@ -4734,6 +4719,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()); @@ -5047,9 +5046,7 @@ end_with_restore_list: db_name.length= lex->name.length; strmov(db_name.str, 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(&db_name)) { @@ -5104,9 +5101,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; @@ -5490,6 +5485,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; } @@ -5969,18 +5965,14 @@ end_with_restore_list: } case SQLCOM_SHOW_CREATE_PROC: { -#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 (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname)) goto error; break; } case SQLCOM_SHOW_CREATE_FUNC: { -#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 (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname)) goto error; break; @@ -5993,9 +5985,7 @@ end_with_restore_list: stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); -#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 (sp_cache_routine(thd, type, lex->spname, FALSE, &sp)) goto error; if (!sp || sp->show_routine_code(thd)) @@ -6017,9 +6007,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 +6465,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 f5e47206963..519b7cc8195 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -785,7 +785,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 8191782f24d..0d539758b68 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2090,6 +2090,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, DBUG_RETURN(TRUE); my_ok(thd); DBUG_RETURN(FALSE); + } @@ -2136,7 +2137,6 @@ static uint32 comment_length(THD *thd, uint32 comment_pos, return 0; } - /** Execute the drop of a normal or temporary table. @@ -2560,6 +2560,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(), @@ -2572,6 +2575,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(), @@ -2586,6 +2592,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(), @@ -2634,6 +2643,9 @@ err: } end: +#ifdef WITH_WSREP + thd->wsrep_skip_wsrep_GTID = false; +#endif /* WITH_WSREP */ DBUG_RETURN(error); } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index bbb2d36f2d5..76de63c6192 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4936,7 +4936,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( @@ -5048,21 +5048,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/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 e34f1b92d52..ba11d94e6fa 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 30ae2c77fa3..d95c85f3008 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, char *db_, 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, char *db_, 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, char *db_, 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 069801b43e3..3d46e17af99 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 b34fdf8b7ed..41a8f6c7eb0 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/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/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index f7fb1377fcf..c8e9e0bd9b7 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2257,7 +2257,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 << "."; @@ -2431,9 +2431,8 @@ fil_space_crypt_get_status( } status->space = ULINT_UNDEFINED; - fil_space_crypt_t* crypt_data = space->crypt_data; - 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; diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 5e89312a9de..9f499d7ca1e 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -804,7 +804,7 @@ fsp_header_init(ulint space_id, ulint size, mtr_t* mtr) if (space->crypt_data && (space->crypt_data->should_encrypt() || space->crypt_data->not_encrypted())) { - space->crypt_data->write_page0(space, page, mtr); + space->crypt_data->write_page0(space, page, mtr); } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index f0fd67baea2..dba7c0b0674 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -17949,9 +17949,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); @@ -17981,9 +17983,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); @@ -20466,7 +20470,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/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/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/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index d4922e33ef5..46eb60654aa 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= 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/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index bb5711de007..b8a295b10f8 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -4132,8 +4132,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/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/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index 2be598cc18f..99b080ba402 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1403,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) { @@ -1506,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()) { @@ -2303,7 +2303,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) { @@ -2315,7 +2315,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); } } @@ -2461,9 +2467,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 d0d98b4b77d..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; @@ -2414,7 +2414,7 @@ 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 diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc index a2c11224ffd..02683e298cb 100644 --- a/storage/xtradb/fsp/fsp0fsp.cc +++ b/storage/xtradb/fsp/fsp0fsp.cc @@ -729,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); } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 0e46f406753..86496288b51 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/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 3a9aa91d52e..33f8ec443dd 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -937,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, @@ -1464,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 @@ -1655,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); 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 fadbeacbc97..35981e79d43 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" @@ -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, @@ -3119,7 +3113,6 @@ files_checked: "wsrep recovery."); } #endif /* WITH_WSREP */ - /* Create thread(s) that handles key rotation */ fil_system_enter(); fil_crypt_threads_init(); 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; |