diff options
Diffstat (limited to 'mysql-test/suite')
160 files changed, 17121 insertions, 1030 deletions
diff --git a/mysql-test/suite/archive/archive.result b/mysql-test/suite/archive/archive.result index fa2b4f7ee00..022b400fd97 100644 --- a/mysql-test/suite/archive/archive.result +++ b/mysql-test/suite/archive/archive.result @@ -1,6 +1,5 @@ CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); -DROP TABLE if exists t1,t2,t3,t4,t5,t6; SET default_storage_engine=ARCHIVE; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, @@ -12881,6 +12880,9 @@ show warnings; Level Code Message Error 1194 Table 't1' is marked as crashed and should be repaired drop table t1; +# +# temporary archive +# create temporary table t1 (a int) engine=archive; insert t1 values (1),(2),(3); select * from t1; @@ -12906,3 +12908,14 @@ t1 CREATE TEMPORARY TABLE `t1` ( `b` varchar(10) DEFAULT NULL ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; +# +# End of 10.0 tests +# +# +# MDEV-27396 DESC index attribute remains in Archive table definition, despite being apparently ignored +# +create table t (t int auto_increment, key (t desc)) engine=archive; +ERROR HY000: Can't create table `test`.`t` (errno: 140 "Wrong create options") +# +# End of 10.8 tests +# diff --git a/mysql-test/suite/archive/archive.test b/mysql-test/suite/archive/archive.test index 2d184110a2d..b6920827005 100644 --- a/mysql-test/suite/archive/archive.test +++ b/mysql-test/suite/archive/archive.test @@ -7,10 +7,6 @@ CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); ---disable_warnings -DROP TABLE if exists t1,t2,t3,t4,t5,t6; ---enable_warnings - SET default_storage_engine=ARCHIVE; let $MYSQLD_DATADIR= `SELECT @@datadir`; @@ -1770,9 +1766,9 @@ select * from t1; show warnings; drop table t1; -# -# temporary archive -# +--echo # +--echo # temporary archive +--echo # create temporary table t1 (a int) engine=archive; insert t1 values (1),(2),(3); select * from t1; @@ -1782,3 +1778,16 @@ select * from t1; show create table t1; drop table t1; +--echo # +--echo # End of 10.0 tests +--echo # + +--echo # +--echo # MDEV-27396 DESC index attribute remains in Archive table definition, despite being apparently ignored +--echo # +--error ER_CANT_CREATE_TABLE +create table t (t int auto_increment, key (t desc)) engine=archive; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/suite/binlog/include/mysqlbinlog_gtid_strict_mode.inc b/mysql-test/suite/binlog/include/mysqlbinlog_gtid_strict_mode.inc new file mode 100644 index 00000000000..5150e9060b5 --- /dev/null +++ b/mysql-test/suite/binlog/include/mysqlbinlog_gtid_strict_mode.inc @@ -0,0 +1,421 @@ +# +# This file runs test cases for using --gtid-strict-mode with mariadb-binlog to +# ensure warnings are properly displayed +# +# param $is_strict_mode boolean (0 for false, 1 for true) to enable or +# disable strict mode for GTID processing +# + +--let MYSQLD_DATADIR=`select @@datadir` +--let OUT_FILE=$MYSQLTEST_VARDIR/tmp/binlog.out + +if ($is_strict_mode == 0) +{ + --let BINLOG_STRICT_MODE_PARAM=--skip-gtid-strict-mode +} +if ($is_strict_mode == 1) +{ + --let BINLOG_STRICT_MODE_PARAM=--gtid-strict-mode +} +if ($is_verbose == 1) +{ + --let BINLOG_STRICT_MODE_PARAM=$BINLOG_STRICT_MODE_PARAM -vvv +} + +--let $log_error_ = $MYSQLTEST_VARDIR/tmp/out.err +--let SEARCH_FILE=$log_error_ + +--echo # +--echo # Test Case 1: +--echo # Sequential sequence numbers results in no errors or warnings +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +INSERT INTO t1 values (3); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 2: +--echo # A skipped sequence number results in no errors or warnings if all +--echo # numbers are monotonic (i.e. gaps in sequence number are allowed +--echo # provided they never decrease) +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (3); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 3: +--echo # A sequence number lower than the last processed value results in a +--echo # warning or error +CREATE TABLE t1 (a int); +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 1; +INSERT INTO t1 values (1); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 4: +--echo # Skipping a GTID and later receiving it results in a warning or error +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (5); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 5: +--echo # Repeat sequence numbers produce a warning +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 6: +--echo # Warnings from different domains are all displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t2 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t2 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t2 values (4); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +DROP TABLE t2; +RESET MASTER; + +--echo # +--echo # Test Case 7: +--echo # A decreasing seq_no before a start-position is ignored +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +--let $start_binlog_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (3); +INSERT INTO t1 values (5); +FLUSH LOGS; + +--echo # GTID-based start-position +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-4 $BINLOG_STRICT_MODE_PARAM > log_error_ > OUT_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-4 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX +--source include/search_pattern_in_file.inc + +--echo # Position-based start-position +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=$start_binlog_pos $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX +--source include/search_pattern_in_file.inc + +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 8: +--echo # A decreasing seq_no inside of a --start/--stop position window is +--echo # displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +--let $start_binlog_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (4); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 6; +INSERT INTO t1 values (5); +--let $stop_binlog_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +FLUSH LOGS; + +--echo # GTID-based window +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --stop-position=0-1-6 $BINLOG_STRICT_MODE_PARAM > log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --stop-position=0-1-6 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc + +--echo # Position-based window +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --stop-position=stop_binlog_pos $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=$start_binlog_pos --stop-position=$stop_binlog_pos $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc + +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 9: +--echo # Error if --stop-position is not greater than or equal to +--echo # --start-position +--echo # +--echo # Note: Error is only displayed in strict mode, -vvv has no effect here +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2 --stop-position=0-1-1 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2 --stop-position=0-1-1 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=ERROR: Queried GTID range is invalid in strict mode +--source include/search_pattern_in_file.inc + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2,1-2-1 --stop-position=0-1-1,1-2-2 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2,1-2-1 --stop-position=0-1-1,1-2-2 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=ERROR: Queried GTID range is invalid in strict mode +--source include/search_pattern_in_file.inc +RESET MASTER; + +--echo # +--echo # Test Case 10: +--echo # Strict mode warnings should be independent of --offset option +--echo # specification +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --offset=8 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --offset=8 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 11: +--echo # Strict mode warnings should be independent of --start-timestamp +--echo # option specification +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +SET timestamp=@a; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +SET timestamp=@a+1; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +SET timestamp=@a+2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +SET timestamp=@a+3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --start-datetime="1970-01-21 15:32:24" $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--error $is_strict_mode +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --start-datetime="1970-01-21 15:32:24" $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=$DEFAULT_ERROR_PREFIX: Found out of order GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +RESET MASTER; + +--echo # +--echo # Test Case 12: +--echo # Specifying multiple binary logs with a log-position start should +--echo # skip GTID state verification +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +--let $b2_start_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +INSERT INTO t2 values (1); +FLUSH LOGS; +INSERT INTO t2 values (2); +FLUSH LOGS; +--let BINLOG_FILE1= query_get_value(SHOW BINARY LOGS, Log_name, 1) +# Skip file 2 as input +--let BINLOG_FILE2= query_get_value(SHOW BINARY LOGS, Log_name, 2) +--echo # MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE2 --start-position=b2_start_pos $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE1 $MYSQLD_DATADIR/$BINLOG_FILE2 --start-position=$b2_start_pos $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +DROP TABLE t1; +DROP TABLE t2; + + +--echo # +--echo # Test Case 13: +--echo # If multiple binary logs should be specified but a middle log is +--echo # missing, we should detect that and warn when using -vvv + +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +FLUSH LOGS; +INSERT INTO t1 values (1); +--let $b2_start_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +FLUSH LOGS; +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; + +--echo # +--echo # GLLE from each log for state reference +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 1) +--source include/show_gtid_list.inc +--let $binlog_file= +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2) +--source include/show_gtid_list.inc +--let $binlog_file= +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 3) +--source include/show_gtid_list.inc +--let $binlog_file= + +--let BINLOG_FILE1= query_get_value(SHOW BINARY LOGS, Log_name, 1) +# Skip file 2 as input +--let BINLOG_FILE3= query_get_value(SHOW BINARY LOGS, Log_name, 3) +--echo # MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE3 $BINLOG_STRICT_MODE_PARAM 2> log_error_ > OUT_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE1 $MYSQLD_DATADIR/$BINLOG_FILE3 $BINLOG_STRICT_MODE_PARAM 2> $log_error_ > $OUT_FILE +--echo # We should have two warnings about missing data from domains 0 and 1 if +--echo # -vvv is specified +--let SEARCH_FILE=$log_error_ +--let SEARCH_PATTERN=WARNING: Binary logs are missing data for domain 0[^\n]+the last seen event was +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=WARNING: Binary logs are missing data for domain 1[^\n]+neither the starting GTID position list nor any processed events +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +RESET MASTER; + +--echo # +--echo # Test Case 14: +--echo # If a --stop-position GTID occurs before the first specified binlog's +--echo # GLLE, error +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +FLUSH LOGS; +INSERT INTO t1 values (3); +FLUSH LOGS; + +--echo # +--echo # GLLE from each log for state reference +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 1) +--source include/show_gtid_list.inc +--let $binlog_file= +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2) +--source include/show_gtid_list.inc +--let $binlog_file= +--echo # MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE2 $BINLOG_STRICT_MODE_PARAM --stop-position=0-1-2 2> log_error_ > OUT_FILE +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2 $BINLOG_STRICT_MODE_PARAM --stop-position=0-1-2 2> $log_error_ > $OUT_FILE +--let SEARCH_PATTERN=ERROR: --stop-position GTID +--source include/search_pattern_in_file.inc +--remove_file $log_error_ +DROP TABLE t1; + +--remove_file $OUT_FILE diff --git a/mysql-test/suite/binlog/include/mysqlbinlog_gtid_window_test_cases.inc b/mysql-test/suite/binlog/include/mysqlbinlog_gtid_window_test_cases.inc new file mode 100644 index 00000000000..2830f3f665d --- /dev/null +++ b/mysql-test/suite/binlog/include/mysqlbinlog_gtid_window_test_cases.inc @@ -0,0 +1,606 @@ +# +# This file runs test cases for providing GTIDs to --start-position and +# --stop-position arguments in mariadb-binlog +# +# param $is_remote boolean (0 for false, 1 for true) to perform a local file +# or remote host analysis +# + +--let MYSQLD_DATADIR=`select @@datadir` +--let data_inconsistent_err= "table data is inconsistent after replaying binlog using GTID start/stop positions"; +--let $tmp_out_ = $MYSQLTEST_VARDIR/tmp/null.log + +## Initialize test data +# +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET timestamp=@a; +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +--let $empty_binlog_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +CREATE TABLE t1 (a int); +SET timestamp=@a+1; +INSERT INTO t1 values (1), (2); +--let test2_t1_mid_checksum= `CHECKSUM TABLE t1` + +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +SET timestamp=@a+2; +CREATE TABLE t2 (a int); +SET timestamp=@a+3; +INSERT INTO t2 values (1); +--let t2_mid_checksum= `CHECKSUM TABLE t2` + +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET timestamp=@a+4; +INSERT INTO t1 values (3), (4); +--let t1_final_checksum_pos= query_get_value(SHOW MASTER STATUS,Position, 1) +--let t1_final_checksum= `CHECKSUM TABLE t1` + +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +INSERT INTO t2 values (2); +--let test4_t2_good_checksum= `CHECKSUM TABLE t2` + +SET @@session.server_id= 3; +INSERT INTO t2 values (3); +--let test3_t2_good_checksum= `CHECKSUM TABLE t2` + +SET @@session.server_id= 2; +INSERT INTO t2 values (4); +--let t2_final_checksum= `CHECKSUM TABLE t2` + +FLUSH LOGS; + +# Multiple binlog file case, used by test 18 +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t3 (a int); +INSERT INTO t3 VALUES (1); +--let t3_final_checksum= `CHECKSUM TABLE t3` + +FLUSH LOGS; + +--echo # Gtid list event of the 2nd binlog file whose content is +--echo # matched against --start-position in the following tests: +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2) +--source include/show_gtid_list.inc +--let $binlog_file= + +--let BINLOG_FILE= query_get_value(SHOW BINARY LOGS, Log_name, 1) +--let BINLOG_FILE2= query_get_value(SHOW BINARY LOGS, Log_name, 2) + +if ($is_remote == 0) +{ + --let BINLOG_FILE_PARAM=$MYSQLD_DATADIR/$BINLOG_FILE.orig + --let BINLOG_FILE_PARAM2=$MYSQLD_DATADIR/$BINLOG_FILE2.orig +} +if ($is_remote == 1) +{ + --let BINLOG_FILE_PARAM= --read-from-remote-server $BINLOG_FILE + --let BINLOG_FILE_PARAM2= --read-from-remote-server $BINLOG_FILE2 +} + +--copy_file $MYSQLD_DATADIR/$BINLOG_FILE $MYSQLD_DATADIR/$BINLOG_FILE.orig +--copy_file $MYSQLD_DATADIR/$BINLOG_FILE2 $MYSQLD_DATADIR/$BINLOG_FILE2.orig + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + + +--echo # +--echo # Test Case 1: +--echo # The end of the binlog file resets the server and domain id of the +--echo # session + +# As gtid_domain_id and server_id should not change after reading binlog in GTID +# mode, change variables to otherwise-unused values to ensure they remain +--let $reset_gtid_domain_id = `select @@session.gtid_domain_id` +--let $reset_server_id = `select @@session.server_id` +SET @@session.gtid_domain_id= 10; +SET @@session.server_id= 20; + +# Replay the binlog +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | $MYSQL +--let $test_gtid_domain_id = `select @@session.gtid_domain_id` + +# Ensure variables haven't changed +--let $assert_text = session gtid_domain_id should not change when reading binlog in GTID mode +--let $assert_cond = @@session.gtid_domain_id = 10 +--source include/assert.inc +--let $assert_text = session server_id should not change when reading binlog in GTID mode +--let $assert_cond = @@session.server_id = 20 +--source include/assert.inc + +# Reset back to previous state +--eval SET @@session.gtid_domain_id= $reset_gtid_domain_id +--eval SET @@session.server_id= $reset_server_id +DROP TABLE t1; + + +--echo # +--echo # Test Case 2: +--echo # Single GTID range specified +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | $MYSQL + +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; + + +--echo # +--echo # Test Case 3: +--echo # Single GTID range with different server_ids +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | $MYSQL + +if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; +} +DROP TABLE t2; + + +--echo # +--echo # Test Case 4: +--echo # Multiple GTID ranges specified +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | $MYSQL + +# Reuse checksum spot from test 4 +if ($t1_final_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if ($test4_t2_good_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; +DROP TABLE t2; + + +--echo # +--echo # Test Case 5: +--echo # Multiple GTID ranges specified where the domain ids are listed in +--echo # different orders between start/stop position +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | $MYSQL + +# Reuse checksum spot from test 4 +if ($t1_final_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if ($test4_t2_good_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; +DROP TABLE t2; + + +--echo # +--echo # Test Case 6: +--echo # Only start position specified +CREATE TABLE t1 (a int); +INSERT INTO t1 values (3), (4); +--let test6_t1_mid_checksum= `CHECKSUM TABLE t1` +DROP TABLE t1; +CREATE TABLE t1 (a int); +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-2 | $MYSQL +if ($test6_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if ($t2_final_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; +DROP TABLE t2; + + +--echo # +--echo # Test Case 7: +--echo # Only stop position specified +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-2 | $MYSQL + +# Reuse checksum spot from test 2 +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; + + +--echo # +--echo # Test Case 8: +--echo # Seq_no=0 in --start-position includes all events for a domain +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | $MYSQL +if ($t1_final_checksum != `CHECKSUM TABLE t1`) +{ + die "t1 data should be complete as binlog replay should include domain 0 entirely in results"; +} +if ($t2_final_checksum != `CHECKSUM TABLE t2`) +{ + die "t2 data should be complete as binlog replay should include domain 1 entirely in results"; +} +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # Test Case 9: +--echo # Seq_no=0 in --stop-position excludes all events for a domain +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | $MYSQL +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should exclude domain 0 from results"; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from results"; +} + +--echo # +--echo # Test Case 10: +--echo # Output stops for all domain ids when all --stop-position GTID values +--echo # have been hit. +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-2 | $MYSQL +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from results"; +} +DROP TABLE t1; + +--echo # +--echo # Test Case 11: +--echo # All GTID events from other domains are printed until the +--echo # --stop-position values are hit +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=1-3-4 | $MYSQL +if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; +} +DROP TABLE t2; + +--echo # +--echo # Test Case 12: +--echo # Scalar and GTID values can be used together for stop or start +--echo # position +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=$empty_binlog_pos --stop-position=0-1-2 | $MYSQL +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=$t1_final_checksum_pos | $MYSQL +if ($t1_final_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if ($t2_mid_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # Test Case 13: +--echo # If the start position is delayed within the binlog, events occurring +--echo # before that position are ignored +CREATE TABLE t1 (a int); +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | $MYSQL +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from results"; +} +DROP TABLE t1; + +--echo # +--echo # Test Case 14: +--echo # If start position is repeated, the last specification overrides all +--echo # previous ones +CREATE TABLE t1 (a int); +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | $MYSQL +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from results"; +} +DROP TABLE t1; + +--echo # +--echo # Test Case 15: +--echo # If stop position is repeated, the last specification overrides all +--echo # previous ones +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | $MYSQL +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from results"; +} +DROP TABLE t1; + +--echo # +--echo # Test Case 16: +--echo # Start position with --offset=<n> skips n events after the first +--echo # GTID is found + +# t1 needs to be specified because its creation should be skipped from +# --offset specification +CREATE TABLE t1 (a int); + +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | $MYSQL +if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude events after GTID 0-1-2"; +} +DROP TABLE t1; + +--echo # +--echo # Test Case 17: +--echo # Start position with --start-datetime=<T> where T occurs after the +--echo # specified GTID results in no events before T +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | $MYSQL +if ($t2_mid_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should exclude events before the given start-datetime"; +} +DROP TABLE t2; + +--echo # +--echo # Test Case 18: +--echo # If --stop-position is specified, domains which are not present +--echo # in its list should be excluded from output +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=1-3-4 | $MYSQL + +if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; +} +DROP TABLE t2; + +--echo # +--echo # Test Case 19: +--echo # If the start and stop GTIDs in any domain are equal, the domain +--echo # should not have any output +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | $MYSQL + +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from stop position"; +} + +--echo # +--echo # Test Case 20: +--echo # If --start-position and --stop-position have different domain ids, +--echo # only events from GTIDs in the --stop-position list are output +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | $MYSQL +if ($t1_final_checksum != `CHECKSUM TABLE t1`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should exclude domain 1 from stop position"; +} +DROP TABLE t1; + +--echo # +--echo # Test Case 21: +--echo # Successive binary logs (e.g. logs with previous logs that have been +--echo # purged) will write events when the --start-position matches their +--echo # Gtid_list_log_event state +if ($is_remote == 1) +{ + --echo # + --echo # Reset server state + RESET MASTER; + --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL + FLUSH LOGS; + --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL + FLUSH LOGS; + --eval PURGE BINARY LOGS TO "$BINLOG_FILE2" + DROP TABLE t1; + DROP TABLE t2; + DROP TABLE t3; +} +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | $MYSQL +if ($t3_final_checksum != `CHECKSUM TABLE t3`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should not have any events from unspecified binlog file"; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should not have any events from unspecified binlog file"; +} +DROP TABLE t3; + +--echo # +--echo # Test Case 22: +--echo # Successive binary logs can be called with --stop-position and +--echo # without --start-position +if ($is_remote == 1) +{ + --echo # + --echo # Reset server state + RESET MASTER; + --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL + FLUSH LOGS; + --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL + FLUSH LOGS; + --eval PURGE BINARY LOGS TO "$BINLOG_FILE2" + DROP TABLE t1; + DROP TABLE t2; + DROP TABLE t3; +} +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --stop-position=0-1-4 | $MYSQL +if (`SELECT COUNT(*) FROM test.t3`) +{ + die $data_inconsistent_err; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) +{ + die "t1 should not exist as binlog replay should not have any events from unspecified binlog file"; +} +if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should not exist as binlog replay should not have any events from unspecified binlog file"; +} +DROP TABLE t3; + + +if ($is_remote == 1) +{ + --echo # + --echo # Remote-only setup for error cases + RESET MASTER; + --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL + FLUSH LOGS; + --exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL + FLUSH LOGS; + --eval PURGE BINARY LOGS TO "$BINLOG_FILE2" +} + +--echo # At the following error cases analysis +--echo # note incompatible --start-position with the value of +--echo # Gtid list event of the 2nd binlog file printed above. + +--let err_out_= $MYSQLTEST_VARDIR/tmp/err.out +--let SEARCH_FILE=$err_out_ + +--echo # +--echo # Error Case 1: +--echo # A GTID --start-position that does not mention all domains that make +--echo # up the binary log state should error +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_ +--error 1 +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-3 > $tmp_out_ 2> $err_out_ +if ($is_remote == 1) +{ + --let SEARCH_PATTERN=ERROR: Got error reading packet from server +} +if ($is_remote == 0) +{ + --let SEARCH_PATTERN=ERROR: Starting GTID position list does not specify an initial value +} +--source include/search_pattern_in_file.inc +--remove_file $err_out_ + +--echo # +--echo # Error Case 2: +--echo # A GTID --start-position with any sequence numbers which occur before +--echo # the binary log state should result in error +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_ +--error 1 +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > $tmp_out_ 2> $err_out_ +if ($is_remote == 1) +{ + --let SEARCH_PATTERN=ERROR: Got error reading packet from server +} +if ($is_remote == 0) +{ + --let SEARCH_PATTERN=ERROR: Binary logs are missing data for domain 0 +} +--source include/search_pattern_in_file.inc +--remove_file $err_out_ + +--echo # +--echo # Error Case 3: +--echo # A GTID --start-position with any sequence numbers that are not +--echo # eventually processed results in error +--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_ +--error 1 +--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > $tmp_out_ 2> $err_out_ +if ($is_remote == 1) +{ + --let SEARCH_PATTERN=ERROR: Got error reading packet from server +} +if ($is_remote == 0) +{ + --let SEARCH_PATTERN=ERROR: Binary logs never reached expected GTID state +} +--source include/search_pattern_in_file.inc +--remove_file $err_out_ + +if ($is_remote == 1) +{ + --echo # + --echo # Remote-only cleanup from error cases + DROP TABLE t1; + DROP TABLE t2; + DROP TABLE t3; + RESET MASTER; +} + +--remove_file $MYSQLD_DATADIR/$BINLOG_FILE.orig +--remove_file $MYSQLD_DATADIR/$BINLOG_FILE2.orig +--remove_file $tmp_out_ diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_glle_ordered.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_glle_ordered.result new file mode 100644 index 00000000000..2826cba99ae --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_glle_ordered.result @@ -0,0 +1,19 @@ +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.server_id= 1; +INSERT INTO t2 VALUES (1); +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/binlog_file > SEARCH_FILE +FOUND 1 /Gtid list \[0-1-1,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1\]/ in tmp_binlog.out +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_strict_mode.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_strict_mode.result new file mode 100644 index 00000000000..c2f7bac387c --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_strict_mode.result @@ -0,0 +1,925 @@ +############################### +# Test Setup +############################### +RESET MASTER; +#################################################### +# Test Case Group 1 +# +# Tests with --gtid-strict-mode should error and +# immediately quit with error on out of order GTIDs +#################################################### +# +# Test Case 1: +# Sequential sequence numbers results in no errors or warnings +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +INSERT INTO t1 values (3); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /ERROR/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 2: +# A skipped sequence number results in no errors or warnings if all +# numbers are monotonic (i.e. gaps in sequence number are allowed +# provided they never decrease) +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (3); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /ERROR/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 3: +# A sequence number lower than the last processed value results in a +# warning or error +CREATE TABLE t1 (a int); +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 1; +INSERT INTO t1 values (1); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 4: +# Skipping a GTID and later receiving it results in a warning or error +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (5); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 5: +# Repeat sequence numbers produce a warning +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 6: +# Warnings from different domains are all displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t2 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t2 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t2 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +DROP TABLE t2; +RESET MASTER; +# +# Test Case 7: +# A decreasing seq_no before a start-position is ignored +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (3); +INSERT INTO t1 values (5); +FLUSH LOGS; +# GTID-based start-position +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-4 --gtid-strict-mode > log_error_ > OUT_FILE +NOT FOUND /ERROR/ in out.err +# Position-based start-position +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /ERROR/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 8: +# A decreasing seq_no inside of a --start/--stop position window is +# displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (4); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 6; +INSERT INTO t1 values (5); +FLUSH LOGS; +# GTID-based window +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --stop-position=0-1-6 --gtid-strict-mode > log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +# Position-based window +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --stop-position=stop_binlog_pos --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 9: +# Error if --stop-position is not greater than or equal to +# --start-position +# +# Note: Error is only displayed in strict mode, -vvv has no effect here +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2 --stop-position=0-1-1 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Queried GTID range is invalid in strict mode/ in out.err +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2,1-2-1 --stop-position=0-1-1,1-2-2 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Queried GTID range is invalid in strict mode/ in out.err +RESET MASTER; +# +# Test Case 10: +# Strict mode warnings should be independent of --offset option +# specification +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --offset=8 --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 11: +# Strict mode warnings should be independent of --start-timestamp +# option specification +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +SET timestamp=@a; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +SET timestamp=@a+1; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +SET timestamp=@a+2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +SET timestamp=@a+3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --start-datetime="1970-01-21 15:32:24" --gtid-strict-mode 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 12: +# Specifying multiple binary logs with a log-position start should +# skip GTID state verification +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +INSERT INTO t2 values (1); +FLUSH LOGS; +INSERT INTO t2 values (2); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE2 --start-position=b2_start_pos --gtid-strict-mode 2> log_error_ > OUT_FILE +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 13: +# If multiple binary logs should be specified but a middle log is +# missing, we should detect that and warn when using -vvv +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +FLUSH LOGS; +INSERT INTO t1 values (1); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +FLUSH LOGS; +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; +# +# GLLE from each log for state reference +show binlog events in 'master-bin.000001' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-1] +show binlog events in 'master-bin.000003' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000003 # Gtid_list 1 # [0-1-2,1-2-1] +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE3 --gtid-strict-mode 2> log_error_ > OUT_FILE +# We should have two warnings about missing data from domains 0 and 1 if +# -vvv is specified +NOT FOUND /WARNING: Binary logs are missing data for domain 0[^\n]+the last seen event was/ in out.err +NOT FOUND /WARNING: Binary logs are missing data for domain 1[^\n]+neither the starting GTID position list nor any processed events/ in out.err +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +RESET MASTER; +# +# Test Case 14: +# If a --stop-position GTID occurs before the first specified binlog's +# GLLE, error +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +FLUSH LOGS; +INSERT INTO t1 values (3); +FLUSH LOGS; +# +# GLLE from each log for state reference +show binlog events in 'master-bin.000001' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-3] +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE2 --gtid-strict-mode --stop-position=0-1-2 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: --stop-position GTID/ in out.err +DROP TABLE t1; +#################################################### +# Test Case Group 2 +# +# Test cases with --skip-gtid-strict-mode -vvv +# should not quit early or with error when +# encountering out of order GTIDs; however should +# produce warnings after binlog processing +#################################################### +# +# Test Case 1: +# Sequential sequence numbers results in no errors or warnings +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +INSERT INTO t1 values (3); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +NOT FOUND /WARNING/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 2: +# A skipped sequence number results in no errors or warnings if all +# numbers are monotonic (i.e. gaps in sequence number are allowed +# provided they never decrease) +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (3); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +NOT FOUND /WARNING/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 3: +# A sequence number lower than the last processed value results in a +# warning or error +CREATE TABLE t1 (a int); +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 1; +INSERT INTO t1 values (1); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 4: +# Skipping a GTID and later receiving it results in a warning or error +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (5); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 5: +# Repeat sequence numbers produce a warning +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 6: +# Warnings from different domains are all displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t2 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t2 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t2 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 2 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +DROP TABLE t2; +RESET MASTER; +# +# Test Case 7: +# A decreasing seq_no before a start-position is ignored +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (3); +INSERT INTO t1 values (5); +FLUSH LOGS; +# GTID-based start-position +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-4 --skip-gtid-strict-mode -vvv > log_error_ > OUT_FILE +NOT FOUND /WARNING/ in out.err +# Position-based start-position +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +NOT FOUND /WARNING/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 8: +# A decreasing seq_no inside of a --start/--stop position window is +# displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (4); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 6; +INSERT INTO t1 values (5); +FLUSH LOGS; +# GTID-based window +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --stop-position=0-1-6 --skip-gtid-strict-mode -vvv > log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +# Position-based window +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --stop-position=stop_binlog_pos --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 9: +# Error if --stop-position is not greater than or equal to +# --start-position +# +# Note: Error is only displayed in strict mode, -vvv has no effect here +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2 --stop-position=0-1-1 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +NOT FOUND /ERROR: Queried GTID range is invalid in strict mode/ in out.err +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2,1-2-1 --stop-position=0-1-1,1-2-2 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +NOT FOUND /ERROR: Queried GTID range is invalid in strict mode/ in out.err +RESET MASTER; +# +# Test Case 10: +# Strict mode warnings should be independent of --offset option +# specification +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --offset=8 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 11: +# Strict mode warnings should be independent of --start-timestamp +# option specification +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +SET timestamp=@a; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +SET timestamp=@a+1; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +SET timestamp=@a+2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +SET timestamp=@a+3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --start-datetime="1970-01-21 15:32:24" --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +FOUND 1 /WARNING: Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 12: +# Specifying multiple binary logs with a log-position start should +# skip GTID state verification +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +INSERT INTO t2 values (1); +FLUSH LOGS; +INSERT INTO t2 values (2); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE2 --start-position=b2_start_pos --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 13: +# If multiple binary logs should be specified but a middle log is +# missing, we should detect that and warn when using -vvv +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +FLUSH LOGS; +INSERT INTO t1 values (1); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +FLUSH LOGS; +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; +# +# GLLE from each log for state reference +show binlog events in 'master-bin.000001' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-1] +show binlog events in 'master-bin.000003' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000003 # Gtid_list 1 # [0-1-2,1-2-1] +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE3 --skip-gtid-strict-mode -vvv 2> log_error_ > OUT_FILE +# We should have two warnings about missing data from domains 0 and 1 if +# -vvv is specified +FOUND 1 /WARNING: Binary logs are missing data for domain 0[^\n]+the last seen event was/ in out.err +FOUND 1 /WARNING: Binary logs are missing data for domain 1[^\n]+neither the starting GTID position list nor any processed events/ in out.err +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +RESET MASTER; +# +# Test Case 14: +# If a --stop-position GTID occurs before the first specified binlog's +# GLLE, error +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +FLUSH LOGS; +INSERT INTO t1 values (3); +FLUSH LOGS; +# +# GLLE from each log for state reference +show binlog events in 'master-bin.000001' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-3] +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE2 --skip-gtid-strict-mode -vvv --stop-position=0-1-2 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: --stop-position GTID/ in out.err +DROP TABLE t1; +#################################################### +# Test Case Group 3 +# +# Run test cases with --skip-gtid-strict-mode should +# neither produce errors nor warnings when +# encountering out of order GTIDs +#################################################### +# +# Test Case 1: +# Sequential sequence numbers results in no errors or warnings +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +INSERT INTO t1 values (3); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING)/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 2: +# A skipped sequence number results in no errors or warnings if all +# numbers are monotonic (i.e. gaps in sequence number are allowed +# provided they never decrease) +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (3); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING)/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 3: +# A sequence number lower than the last processed value results in a +# warning or error +CREATE TABLE t1 (a int); +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 1; +INSERT INTO t1 values (1); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 4: +# Skipping a GTID and later receiving it results in a warning or error +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (5); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 5: +# Repeat sequence numbers produce a warning +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 6: +# Warnings from different domains are all displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t2 values (2); +SET @@session.gtid_seq_no= 2; +INSERT INTO t2 values (3); +SET @@session.gtid_seq_no= 4; +INSERT INTO t2 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +DROP TABLE t2; +RESET MASTER; +# +# Test Case 7: +# A decreasing seq_no before a start-position is ignored +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (4); +INSERT INTO t1 values (3); +INSERT INTO t1 values (5); +FLUSH LOGS; +# GTID-based start-position +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-4 --skip-gtid-strict-mode > log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING)/ in out.err +# Position-based start-position +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING)/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 8: +# A decreasing seq_no inside of a --start/--stop position window is +# displayed +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 5; +INSERT INTO t1 values (4); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +SET @@session.gtid_seq_no= 6; +INSERT INTO t1 values (5); +FLUSH LOGS; +# GTID-based window +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --stop-position=0-1-6 --skip-gtid-strict-mode > log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +# Position-based window +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=start_binlog_pos --stop-position=stop_binlog_pos --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 9: +# Error if --stop-position is not greater than or equal to +# --start-position +# +# Note: Error is only displayed in strict mode, -vvv has no effect here +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2 --stop-position=0-1-1 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /ERROR: Queried GTID range is invalid in strict mode/ in out.err +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-2,1-2-1 --stop-position=0-1-1,1-2-2 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /ERROR: Queried GTID range is invalid in strict mode/ in out.err +RESET MASTER; +# +# Test Case 10: +# Strict mode warnings should be independent of --offset option +# specification +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --offset=8 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 11: +# Strict mode warnings should be independent of --start-timestamp +# option specification +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET @@session.gtid_seq_no= 1; +SET timestamp=@a; +CREATE TABLE t1 (a int); +SET @@session.gtid_seq_no= 3; +SET timestamp=@a+1; +INSERT INTO t1 values (1); +SET @@session.gtid_seq_no= 2; +SET timestamp=@a+2; +INSERT INTO t1 values (2); +SET @@session.gtid_seq_no= 4; +SET timestamp=@a+3; +INSERT INTO t1 values (3); +INSERT INTO t1 values (4); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1 --start-datetime="1970-01-21 15:32:24" --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +NOT FOUND /(ERROR|WARNING): Found out of order GTID/ in out.err +DROP TABLE t1; +RESET MASTER; +# +# Test Case 12: +# Specifying multiple binary logs with a log-position start should +# skip GTID state verification +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +INSERT INTO t2 values (1); +FLUSH LOGS; +INSERT INTO t2 values (2); +FLUSH LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE2 --start-position=b2_start_pos --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 13: +# If multiple binary logs should be specified but a middle log is +# missing, we should detect that and warn when using -vvv +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +FLUSH LOGS; +INSERT INTO t1 values (1); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +FLUSH LOGS; +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; +# +# GLLE from each log for state reference +show binlog events in 'master-bin.000001' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-1] +show binlog events in 'master-bin.000003' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000003 # Gtid_list 1 # [0-1-2,1-2-1] +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE1 MYSQLD_DATADIR/BINLOG_FILE3 --skip-gtid-strict-mode 2> log_error_ > OUT_FILE +# We should have two warnings about missing data from domains 0 and 1 if +# -vvv is specified +NOT FOUND /WARNING: Binary logs are missing data for domain 0[^\n]+the last seen event was/ in out.err +NOT FOUND /WARNING: Binary logs are missing data for domain 1[^\n]+neither the starting GTID position list nor any processed events/ in out.err +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +RESET MASTER; +# +# Test Case 14: +# If a --stop-position GTID occurs before the first specified binlog's +# GLLE, error +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +INSERT INTO t1 values (1); +INSERT INTO t1 values (2); +FLUSH LOGS; +INSERT INTO t1 values (3); +FLUSH LOGS; +# +# GLLE from each log for state reference +show binlog events in 'master-bin.000001' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-3] +# MYSQL_BINLOG MYSQLD_DATADIR/BINLOG_FILE2 --skip-gtid-strict-mode --stop-position=0-1-2 2> log_error_ > OUT_FILE +FOUND 1 /ERROR: --stop-position GTID/ in out.err +DROP TABLE t1; +############################## +# Cleanup +############################## +SET @@global.gtid_domain_id= 0; +SET @@global.server_id= 1; +End of the tests diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_window.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_window.result new file mode 100644 index 00000000000..fce5f95ce82 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_window.result @@ -0,0 +1,468 @@ +############################### +# Test Setup +############################### +RESET MASTER; +###################################### +# Test Group 1 +# Run test cases on local log file +###################################### +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET timestamp=@a; +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET timestamp=@a+1; +INSERT INTO t1 values (1), (2); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +SET timestamp=@a+2; +CREATE TABLE t2 (a int); +SET timestamp=@a+3; +INSERT INTO t2 values (1); +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET timestamp=@a+4; +INSERT INTO t1 values (3), (4); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +INSERT INTO t2 values (2); +SET @@session.server_id= 3; +INSERT INTO t2 values (3); +SET @@session.server_id= 2; +INSERT INTO t2 values (4); +FLUSH LOGS; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t3 (a int); +INSERT INTO t3 VALUES (1); +FLUSH LOGS; +# Gtid list event of the 2nd binlog file whose content is +# matched against --start-position in the following tests: +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-3,1-3-4,1-2-5] +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +# +# Test Case 1: +# The end of the binlog file resets the server and domain id of the +# session +SET @@session.gtid_domain_id= 10; +SET @@session.server_id= 20; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL +include/assert.inc [session gtid_domain_id should not change when reading binlog in GTID mode] +include/assert.inc [session server_id should not change when reading binlog in GTID mode] +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +DROP TABLE t1; +# +# Test Case 2: +# Single GTID range specified +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 3: +# Single GTID range with different server_ids +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL +DROP TABLE t2; +# +# Test Case 4: +# Multiple GTID ranges specified +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 5: +# Multiple GTID ranges specified where the domain ids are listed in +# different orders between start/stop position +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 6: +# Only start position specified +CREATE TABLE t1 (a int); +INSERT INTO t1 values (3), (4); +DROP TABLE t1; +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 7: +# Only stop position specified +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 8: +# Seq_no=0 in --start-position includes all events for a domain +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 9: +# Seq_no=0 in --stop-position excludes all events for a domain +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL +# +# Test Case 10: +# Output stops for all domain ids when all --stop-position GTID values +# have been hit. +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 11: +# All GTID events from other domains are printed until the +# --stop-position values are hit +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL +DROP TABLE t2; +# +# Test Case 12: +# Scalar and GTID values can be used together for stop or start +# position +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 13: +# If the start position is delayed within the binlog, events occurring +# before that position are ignored +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 14: +# If start position is repeated, the last specification overrides all +# previous ones +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 15: +# If stop position is repeated, the last specification overrides all +# previous ones +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 16: +# Start position with --offset=<n> skips n events after the first +# GTID is found +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL +DROP TABLE t1; +# +# Test Case 17: +# Start position with --start-datetime=<T> where T occurs after the +# specified GTID results in no events before T +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL +DROP TABLE t2; +# +# Test Case 18: +# If --stop-position is specified, domains which are not present +# in its list should be excluded from output +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL +DROP TABLE t2; +# +# Test Case 19: +# If the start and stop GTIDs in any domain are equal, the domain +# should not have any output +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL +# +# Test Case 20: +# If --start-position and --stop-position have different domain ids, +# only events from GTIDs in the --stop-position list are output +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL +DROP TABLE t1; +# +# Test Case 21: +# Successive binary logs (e.g. logs with previous logs that have been +# purged) will write events when the --start-position matches their +# Gtid_list_log_event state +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL +DROP TABLE t3; +# +# Test Case 22: +# Successive binary logs can be called with --stop-position and +# without --start-position +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL +DROP TABLE t3; +# At the following error cases analysis +# note incompatible --start-position with the value of +# Gtid list event of the 2nd binlog file printed above. +# +# Error Case 1: +# A GTID --start-position that does not mention all domains that make +# up the binary log state should error +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_ +FOUND 2 /ERROR: Starting GTID position list does not specify an initial value/ in err.out +# +# Error Case 2: +# A GTID --start-position with any sequence numbers which occur before +# the binary log state should result in error +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_ +FOUND 1 /ERROR: Binary logs are missing data for domain 0/ in err.out +# +# Error Case 3: +# A GTID --start-position with any sequence numbers that are not +# eventually processed results in error +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_ +FOUND 2 /ERROR: Binary logs never reached expected GTID state/ in err.out +###################################### +# Test Group 2 +# Run test cases on remote host +###################################### +set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); +SET timestamp=@a; +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET timestamp=@a+1; +INSERT INTO t1 values (1), (2); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +SET timestamp=@a+2; +CREATE TABLE t2 (a int); +SET timestamp=@a+3; +INSERT INTO t2 values (1); +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +SET timestamp=@a+4; +INSERT INTO t1 values (3), (4); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +INSERT INTO t2 values (2); +SET @@session.server_id= 3; +INSERT INTO t2 values (3); +SET @@session.server_id= 2; +INSERT INTO t2 values (4); +FLUSH LOGS; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t3 (a int); +INSERT INTO t3 VALUES (1); +FLUSH LOGS; +# Gtid list event of the 2nd binlog file whose content is +# matched against --start-position in the following tests: +show binlog events in 'master-bin.000002' limit 1,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid_list 1 # [0-1-3,1-3-4,1-2-5] +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +# +# Test Case 1: +# The end of the binlog file resets the server and domain id of the +# session +SET @@session.gtid_domain_id= 10; +SET @@session.server_id= 20; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL +include/assert.inc [session gtid_domain_id should not change when reading binlog in GTID mode] +include/assert.inc [session server_id should not change when reading binlog in GTID mode] +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +DROP TABLE t1; +# +# Test Case 2: +# Single GTID range specified +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 3: +# Single GTID range with different server_ids +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL +DROP TABLE t2; +# +# Test Case 4: +# Multiple GTID ranges specified +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 5: +# Multiple GTID ranges specified where the domain ids are listed in +# different orders between start/stop position +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 6: +# Only start position specified +CREATE TABLE t1 (a int); +INSERT INTO t1 values (3), (4); +DROP TABLE t1; +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 7: +# Only stop position specified +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 8: +# Seq_no=0 in --start-position includes all events for a domain +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 9: +# Seq_no=0 in --stop-position excludes all events for a domain +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL +# +# Test Case 10: +# Output stops for all domain ids when all --stop-position GTID values +# have been hit. +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 11: +# All GTID events from other domains are printed until the +# --stop-position values are hit +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL +DROP TABLE t2; +# +# Test Case 12: +# Scalar and GTID values can be used together for stop or start +# position +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL +DROP TABLE t1; +DROP TABLE t2; +# +# Test Case 13: +# If the start position is delayed within the binlog, events occurring +# before that position are ignored +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 14: +# If start position is repeated, the last specification overrides all +# previous ones +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 15: +# If stop position is repeated, the last specification overrides all +# previous ones +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL +DROP TABLE t1; +# +# Test Case 16: +# Start position with --offset=<n> skips n events after the first +# GTID is found +CREATE TABLE t1 (a int); +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL +DROP TABLE t1; +# +# Test Case 17: +# Start position with --start-datetime=<T> where T occurs after the +# specified GTID results in no events before T +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL +DROP TABLE t2; +# +# Test Case 18: +# If --stop-position is specified, domains which are not present +# in its list should be excluded from output +# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL +DROP TABLE t2; +# +# Test Case 19: +# If the start and stop GTIDs in any domain are equal, the domain +# should not have any output +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL +# +# Test Case 20: +# If --start-position and --stop-position have different domain ids, +# only events from GTIDs in the --stop-position list are output +# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL +DROP TABLE t1; +# +# Test Case 21: +# Successive binary logs (e.g. logs with previous logs that have been +# purged) will write events when the --start-position matches their +# Gtid_list_log_event state +# +# Reset server state +RESET MASTER; +FLUSH LOGS; +FLUSH LOGS; +PURGE BINARY LOGS TO "master-bin.000002"; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL +DROP TABLE t3; +# +# Test Case 22: +# Successive binary logs can be called with --stop-position and +# without --start-position +# +# Reset server state +RESET MASTER; +FLUSH LOGS; +FLUSH LOGS; +PURGE BINARY LOGS TO "master-bin.000002"; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL +DROP TABLE t3; +# +# Remote-only setup for error cases +RESET MASTER; +FLUSH LOGS; +FLUSH LOGS; +PURGE BINARY LOGS TO "master-bin.000002"; +# At the following error cases analysis +# note incompatible --start-position with the value of +# Gtid list event of the 2nd binlog file printed above. +# +# Error Case 1: +# A GTID --start-position that does not mention all domains that make +# up the binary log state should error +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_ +FOUND 1 /ERROR: Got error reading packet from server/ in err.out +# +# Error Case 2: +# A GTID --start-position with any sequence numbers which occur before +# the binary log state should result in error +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_ +FOUND 1 /ERROR: Got error reading packet from server/ in err.out +# +# Error Case 3: +# A GTID --start-position with any sequence numbers that are not +# eventually processed results in error +# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_ +FOUND 1 /ERROR: Got error reading packet from server/ in err.out +# +# Remote-only cleanup from error cases +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +RESET MASTER; +# +# Error Case 4: +# User provides invalid positions +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=z +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1- +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=-1 +# +# Error Case 5: +# User provides GTID ranges with repeated domain ids +# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 +############################## +# Cleanup +############################## +SET @@global.gtid_domain_id= 0; +SET @@global.server_id= 1; +# End of the tests diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_start_alter_verbose.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_start_alter_verbose.result new file mode 100644 index 00000000000..b6b67bc1380 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_start_alter_verbose.result @@ -0,0 +1,15 @@ +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +RESET MASTER; +create table myt (a int) engine=InnoDB; +alter table myt add column (b int); +FLUSH LOGS; +# Exec MYSQL_BINLOG --base64-output=decode-rows -v MYSQLD_DATADIR/BINLOG_FILENAME > MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql +Verbose statements from : master-bin.000001 +select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%'; +stmt +### alter table myt add column (b int) +### alter table myt add column (b int) +drop table raw_binlog_rows; +drop table myt; +set global binlog_alter_two_phase=0; diff --git a/mysql-test/suite/binlog/r/start_alter_mysqlbinlog_replay.result b/mysql-test/suite/binlog/r/start_alter_mysqlbinlog_replay.result new file mode 100644 index 00000000000..14bc2d3bf78 --- /dev/null +++ b/mysql-test/suite/binlog/r/start_alter_mysqlbinlog_replay.result @@ -0,0 +1,42 @@ +# +# Test verifies replay of binary logs which contain +# SA/RA/CA works fine. +# Generate a binary log with alter events and use mysqlbinlog tool to +# generate a sql file for replay. Source it on an clean master and +# verify the correctness. Use the latest binlog and repeat the same +# process mentioned above and observe replay works fine. +# +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +create table t1 (f1 int primary key) engine=InnoDB; +create table t2 (f1 int primary key, constraint c1 foreign key (f1) references t1(f1)) engine=innodb; +alter table t2 add constraint c1 foreign key (f1) references t1(f1); +ERROR HY000: Can't create table `test`.`t2` (errno: 121 "Duplicate key on write or update") +drop table t2, t1; +select @@gtid_binlog_state; +@@gtid_binlog_state +0-1-5 +FLUSH LOGS; +# reset the binlog +RESET MASTER; +# execute the binlog +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +0-1-5 +FLUSH LOGS; +# Replay 1: One more time to simulate S->S case +RESET MASTER; +# execute the binlog +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +0-1-5 +FLUSH LOGS; +# Replay 2: One more time to simulate S->S case +RESET MASTER; +# execute the binlog +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +0-1-5 +# clean up +RESET MASTER; +set global binlog_alter_two_phase=0; diff --git a/mysql-test/suite/binlog/t/binlog_innodb.test b/mysql-test/suite/binlog/t/binlog_innodb.test index 153dcdd155a..5f372e6d5fd 100644 --- a/mysql-test/suite/binlog/t/binlog_innodb.test +++ b/mysql-test/suite/binlog/t/binlog_innodb.test @@ -180,7 +180,7 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; SET @old_flush = @@GLOBAL.innodb_flush_log_at_trx_commit; SET GLOBAL innodb_flush_log_at_trx_commit=1; ---let $syncs1 = query_get_value(SHOW STATUS LIKE 'Innodb_os_log_fsyncs', Value, 1) +--let $syncs1 = query_get_value(SHOW STATUS LIKE 'Innodb_data_fsyncs', Value, 1) --let $ROWS = 100 --disable_query_log let $count = $ROWS; @@ -188,7 +188,7 @@ while ($count) { eval INSERT INTO t1 VALUES ($count); dec $count; } ---let $syncs2 = query_get_value(SHOW STATUS LIKE 'Innodb_os_log_fsyncs', Value, 1) +--let $syncs2 = query_get_value(SHOW STATUS LIKE 'Innodb_data_fsyncs', Value, 1) eval SET @num_sync = $syncs2 - $syncs1; --enable_query_log diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_glle_ordered.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_glle_ordered.test new file mode 100644 index 00000000000..9c79925b4bd --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_glle_ordered.test @@ -0,0 +1,43 @@ +# +# Purpose: +# This test validates that GTIDs are ordered when mysqlbinlog outputs +# Gtid_list events. +# +# Methodology: +# Write multiple events to the binlog with different domain ids and server +# ids, and ensure that the Gtid_list event GTIDs are ordered first by domain id +# (ascending), and then sequence number (ascending). +# +# References: +# MDEV-4989: Support for GTID in mysqlbinlog +# +--source include/have_log_bin.inc + +RESET MASTER; +SET @@session.gtid_domain_id= 0; +SET @@session.server_id= 1; +CREATE TABLE t1 (a int); +SET @@session.gtid_domain_id= 1; +SET @@session.server_id= 2; +CREATE TABLE t2 (a int); +SET @@session.server_id= 1; +INSERT INTO t2 VALUES (1); +SET @@session.gtid_domain_id= 2; +SET @@session.server_id= 3; +CREATE TABLE t3 (a int); +FLUSH LOGS; +FLUSH LOGS; + +--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2) +--let $MYSQLD_DATADIR=`select @@datadir` +--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/tmp_binlog.out + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/binlog_file > SEARCH_FILE +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file > $SEARCH_FILE + +--let SEARCH_PATTERN= Gtid list \[0-1-1,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1\] +--source include/search_pattern_in_file.inc + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_strict_mode.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_strict_mode.test new file mode 100644 index 00000000000..166826408d9 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_strict_mode.test @@ -0,0 +1,105 @@ +# +# Purpose: +# +# This test ensures that the mariadb-binlog CLI tool properly displays errors +# and warnings for out of order GTIDs. +# +# +# Methodology: +# +# We simulate invalid sequence numberings by manually changing gtid_seq_no to +# differ from its expected linear sequence. Specifically, we test the following +# cases: +# Test Case 1) Sequential sequence numbers results in no warnings +# Test Case 2) A skipped sequence number results in no warnings if all numbers +# are monotonic (i.e. gaps in sequence number are allowed +# provided they never decrease) +# Test Case 3) A sequence number lower than the last processed value results +# in a warning +# Test Case 4) Skipping a GTID and later receiving it results in a warning +# Test Case 5) Repeat sequence numbers result in a warning +# Test Case 6) Warnings from different domains are all displayed +# Test Case 7) A decreasing seq_no before a start-position is ignored +# Test Case 8) A decreasing seq_no inside of a --start/--stop position window +# is displayed +# Test Case 9) Error if --stop-position is not greater than or equal to +# --start-position +# Test Case 10) Strict mode warnings should be independent of --offset option +# specification +# Test Case 11) Strict mode warnings should be independent of +# --start-timestamp option specification +# Test Case 12) Specifying multiple binary logs with a log-position start +# should skip GTID state verification +# Test Case 13) If multiple binary logs should be specified but a middle log +# is missing, we should detect that and warn when using -vvv +# Test Case 14) If a --stop-position GTID occurs before the first specified +# binlog's GLLE, error +# +# Note that test cases are tested under three scenarios: +# 1) --gtid-strict-mode should error and immediately quit with error on out of +# order GTIDs +# 2) --skip-gtid-strict-mode -vvv should not quit early or with error when +# encountering out of order GTIDs; however should produce warnings after +# binlog processing +# 3) --skip-gtid-strict-mode should neither produce errors nor warnings when +# encountering out of order GTIDs +# +# References: +# MDEV-4989: Support for GTID in mysqlbinlog +# + +--source include/have_log_bin.inc + +--echo ############################### +--echo # Test Setup +--echo ############################### + +## Save old state +# +let orig_gtid_domain_id = `select @@session.gtid_domain_id`; +let orig_server_id = `select @@session.server_id`; +RESET MASTER; + +--echo #################################################### +--echo # Test Case Group 1 +--echo # +--echo # Tests with --gtid-strict-mode should error and +--echo # immediately quit with error on out of order GTIDs +--echo #################################################### +--let is_strict_mode= 1 +--let is_verbose= 0 +--let DEFAULT_ERROR_PREFIX=ERROR +--source include/mysqlbinlog_gtid_strict_mode.inc + +--echo #################################################### +--echo # Test Case Group 2 +--echo # +--echo # Test cases with --skip-gtid-strict-mode -vvv +--echo # should not quit early or with error when +--echo # encountering out of order GTIDs; however should +--echo # produce warnings after binlog processing +--echo #################################################### +--let is_strict_mode= 0 +--let is_verbose= 1 +--let DEFAULT_ERROR_PREFIX=WARNING +--source include/mysqlbinlog_gtid_strict_mode.inc + +--echo #################################################### +--echo # Test Case Group 3 +--echo # +--echo # Run test cases with --skip-gtid-strict-mode should +--echo # neither produce errors nor warnings when +--echo # encountering out of order GTIDs +--echo #################################################### +--let is_strict_mode= 0 +--let is_verbose= 0 +--let DEFAULT_ERROR_PREFIX=(ERROR|WARNING) +--source include/mysqlbinlog_gtid_strict_mode.inc + +--echo ############################## +--echo # Cleanup +--echo ############################## +--eval SET @@global.gtid_domain_id= $orig_gtid_domain_id +--eval SET @@global.server_id= $orig_server_id + +--echo End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_window.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_window.test new file mode 100644 index 00000000000..3efb8d025b9 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_gtid_window.test @@ -0,0 +1,151 @@ +# +# Purpose: +# +# This test ensures that the mariadb-binlog CLI tool can filter log events +# using GTID ranges. More specifically, this test ensures the following +# capabilities: +# 1) GTIDs can be used to filter results on local binlog files +# 2) GTIDs can be used to filter results from remote servers +# 3) For a given GTID range, its start-position is exclusive and its +# stop-position is inclusive. This allows users to receive events strictly +# after what they already have. +# 4) After the events have been written, the session server id and domain id +# are reset to their former values +# +# +# Methodology: +# +# This test validates the expected capabilities using the following test cases +# on both a local binlog file and remote server for all binlog formats. +# Test Case 1) The end of the binlog file resets the server and domain id of +# the session +# Test Case 2) Single GTID range specified +# Test Case 3) Single GTID range with different server_ids +# Test Case 4) Multiple GTID ranges specified +# Test Case 5) Multiple GTID ranges specified where the domain ids are +# listed in different orders between start/stop position +# Test Case 6) Only start position specified +# Test Case 7) Only stop position specified +# Test Case 8) Seq_no=0 in --start-position includes all events for a domain +# Test Case 9) Seq_no=0 in --stop-position excludes all events for a domain +# Test Case 10) Output stops for all domain ids when all --stop-position GTID +# values have been hit. +# Test Case 11) All GTID events from other domains are printed until +# the --stop-position values are hit +# Test Case 12) Scalar and GTID values can be used together for stop or start +# position +# Test Case 13) If the start position is delayed within the binlog, events +# occurring before that position are ignored +# Test Case 14) If start position is repeated, the last specification +# overrides all previous ones +# Test Case 15) If stop position is repeated, the last specification +# overrides all previous ones +# Test Case 16) Start position with --offset=<n> skips n events after the +# first GTID is found +# Test Case 17) Start position with --start-datetime=<T> where T occurs +# after the specified GTID results in no events before T +# Test Case 18) If --stop-position is specified, domains which are not present +# in its list should be excluded from output +# Test Case 19) If the start and stop GTIDs in any domain are equal, the +# domain should not have any output +# Test Case 20) If --start-position and --stop-position have different domain +# ids, only events from GTIDs in the --stop-position list are +# output +# Test Case 21) Successive binary logs (e.g. logs with previous logs that +# have been purged) will write events when the --start-position +# matches their Gtid_list_log_event state +# Test Case 22) Successive binary logs can be called with --stop-position and +# without --start-position +# +# To validate for data consistency, each test case compares a checksum of +# correct data against a variant created after replaying the binlog using +# --(start|stop)-position. If the checksums are identical, the test passes. +# If the checksums differ, data has been changed and the test fails. +# +# Additionally, this test validates the following error scenarios: +# Error Case 1) A GTID --start-position that does not mention all domains +# that make up the binary log state should error +# Error Case 2) A GTID --start-position with any sequence numbers which +# occur before the binary log state should result in error +# Error Case 3) A GTID --start-position with any sequence numbers that are not +# eventually processed results in error +# Error Case 4) User provides invalid positions +# Error Case 5) User provides GTID ranges with repeated domain ids +# +# References: +# MDEV-4989: Support for GTID in mysqlbinlog +# + +--source include/have_log_bin.inc + +--echo ############################### +--echo # Test Setup +--echo ############################### + +## Save old state +# +let orig_gtid_domain_id = `select @@session.gtid_domain_id`; +let orig_server_id = `select @@session.server_id`; +RESET MASTER; + + +--echo ###################################### +--echo # Test Group 1 +--echo # Run test cases on local log file +--echo ###################################### +--let is_remote= 0 +--source include/mysqlbinlog_gtid_window_test_cases.inc + +--echo ###################################### +--echo # Test Group 2 +--echo # Run test cases on remote host +--echo ###################################### +--let is_remote= 1 +--source include/mysqlbinlog_gtid_window_test_cases.inc + +# Note that error cases 1-3 are in mysqlbinlog_gtid_window_test_cases.inc +# because we validate for error consistency of GTID state between +# mariadb-binlog working on local files and receiving errors from a server + +--let err_out_= $MYSQLTEST_VARDIR/tmp/err.out +--let tmp_out_= $MYSQLTEST_VARDIR/tmp/std.out + +--let $MYSQLD_DATADIR=`select @@datadir` +--echo # +--echo # Error Case 4: +--echo # User provides invalid positions +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=z +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=z + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1- +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1- + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- + +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=-1 +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=-1 + +--echo # +--echo # Error Case 5: +--echo # User provides GTID ranges with repeated domain ids +--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 + + +--echo ############################## +--echo # Cleanup +--echo ############################## +--eval SET @@global.gtid_domain_id= $orig_gtid_domain_id +--eval SET @@global.server_id= $orig_server_id + +--echo # End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_start_alter_verbose.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_start_alter_verbose.test new file mode 100644 index 00000000000..338326d144f --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_start_alter_verbose.test @@ -0,0 +1,58 @@ +# +# Purpose: +# +# This test ensures that mysqlbinlog prints a comment when two-phase alter +# is enabled which shows the original alter query issued. +# +# +# References: +# MENT-662: Finalize MDEV-11675 "Lag Free Alter On Slave" +# + +# Just row format for faster testing +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc + +#--- +# Setup +#--- +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +RESET MASTER; +create table myt (a int) engine=InnoDB; + + +#--- +# Issue ALTER +#--- +alter table myt add column (b int); + + +#--- +# Check binlog output +#--- +FLUSH LOGS; + +--disable_query_log +--let $MYSQLD_DATADIR= `select @@datadir` +--let $BINLOG_FILENAME= query_get_value(SHOW BINARY LOGS, Log_name, 1) + +--echo # Exec MYSQL_BINLOG --base64-output=decode-rows -v MYSQLD_DATADIR/BINLOG_FILENAME > MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql +--exec $MYSQL_BINLOG --base64-output=decode-rows -v $MYSQLD_DATADIR/$BINLOG_FILENAME > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql + +create table raw_binlog_rows (txt varchar(1000)); +--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n' +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql +--enable_query_log +--echo Verbose statements from : $BINLOG_FILENAME +# Output --verbose lines, with extra Windows CR's trimmed +select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%'; + +#--- +# Cleanup +#--- +drop table raw_binlog_rows; +drop table myt; +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase diff --git a/mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test b/mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test new file mode 100644 index 00000000000..d59456d72f6 --- /dev/null +++ b/mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test @@ -0,0 +1,61 @@ +# +# MENT-662: Lag Free Alter On Slave +# + +--echo # +--echo # Test verifies replay of binary logs which contain +--echo # SA/RA/CA works fine. +--echo # Generate a binary log with alter events and use mysqlbinlog tool to +--echo # generate a sql file for replay. Source it on an clean master and +--echo # verify the correctness. Use the latest binlog and repeat the same +--echo # process mentioned above and observe replay works fine. +--echo # +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_binlog_format_statement.inc + +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +create table t1 (f1 int primary key) engine=InnoDB; +create table t2 (f1 int primary key, constraint c1 foreign key (f1) references t1(f1)) engine=innodb; + +--error ER_CANT_CREATE_TABLE +alter table t2 add constraint c1 foreign key (f1) references t1(f1); + +drop table t2, t1; +select @@gtid_binlog_state; +FLUSH LOGS; + +let MYSQLD_DATADIR= `select @@datadir;`; +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_1.sql + +--echo # reset the binlog +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_1.sql" +SELECT @@gtid_binlog_state; +FLUSH LOGS; +--echo # Replay 1: One more time to simulate S->S case +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_2.sql + +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_2.sql" +SELECT @@gtid_binlog_state; +FLUSH LOGS; +--echo # Replay 2: One more time to simulate S->S case +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_3.sql +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_3.sql" +SELECT @@gtid_binlog_state; + +--echo # clean up +remove_file $MYSQLTEST_VARDIR/tmp/slave_1.sql; +remove_file $MYSQLTEST_VARDIR/tmp/slave_2.sql; +remove_file $MYSQLTEST_VARDIR/tmp/slave_3.sql; +RESET MASTER; + +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase diff --git a/mysql-test/suite/compat/oracle/r/sp-cursor.result b/mysql-test/suite/compat/oracle/r/sp-cursor.result index d7e88430bc7..aa9c5de8bc9 100644 --- a/mysql-test/suite/compat/oracle/r/sp-cursor.result +++ b/mysql-test/suite/compat/oracle/r/sp-cursor.result @@ -977,3 +977,46 @@ $$ CALL p1(); DROP PROCEDURE p1; DROP TABLE t1; +# +# Start of 10.8 tests +# +# +# MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +# +DECLARE +va INT; +CURSOR cur (a IN INT) IS SELECT a FROM dual; +BEGIN +OPEN cur(1); +FETCH cur INTO va; +CLOSE cur; +SELECT va; +END; +$$ +va +1 +DECLARE +va INT; +CURSOR cur (a OUT INT) IS SELECT a FROM dual; +BEGIN +OPEN cur(1); +FETCH cur INTO va; +CLOSE cur; +SELECT va; +END; +$$ +ERROR 42000: This version of MariaDB doesn't yet support 'OUT/INOUT cursor parameter' +DECLARE +va INT; +CURSOR cur (a INOUT INT) IS SELECT a FROM dual; +BEGIN +OPEN cur(1); +FETCH cur INTO va; +CLOSE cur; +SELECT va; +END; +$$ +ERROR 42000: This version of MariaDB doesn't yet support 'OUT/INOUT cursor parameter' +# +# End of 10.8 tests +# diff --git a/mysql-test/suite/compat/oracle/r/sp-inout.result b/mysql-test/suite/compat/oracle/r/sp-inout.result new file mode 100644 index 00000000000..fa6f5076d59 --- /dev/null +++ b/mysql-test/suite/compat/oracle/r/sp-inout.result @@ -0,0 +1,2571 @@ +# +# MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +# +SET sql_mode=ORACLE; +# +# CREATE PACKAGE with procedure and function with IN, OUT, INOUT qualifiers +# And SHOW CREATE PACKAGE +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); +FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS +res INT; +BEGIN +res := func_sub(d, a, b, c); +d := d + c + res; +END; +FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT +AS +BEGIN +c := c + 6; +d := 10; +RETURN a - b; +END; +END; +$$ +SHOW CREATE PACKAGE pkg2; +Package sql_mode Create Package character_set_client collation_connection Database Collation +pkg2 PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT CREATE DEFINER="root"@"localhost" PACKAGE "pkg2" AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); +FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT; +END latin1 latin1_swedish_ci latin1_swedish_ci +SHOW CREATE PACKAGE BODY pkg2; +Package body sql_mode Create Package Body character_set_client collation_connection Database Collation +pkg2 PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT CREATE DEFINER="root"@"localhost" PACKAGE BODY "pkg2" AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS +res INT; +BEGIN +res := func_sub(d, a, b, c); +d := d + c + res; +END; +FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT +AS +BEGIN +c := c + 6; +d := 10; +RETURN a - b; +END; +END latin1 latin1_swedish_ci latin1_swedish_ci +DROP PACKAGE pkg2; +# +# CREATE FUNCTION with IN, OUT, INOUT qualifiers +# SHOW CREATE FUNCTION +# +CREATE OR REPLACE FUNCTION add_func(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT +AS +BEGIN +c := 100; +d := d + 1; +RETURN a + b; +END; +$$ +SHOW CREATE FUNCTION add_func; +Function sql_mode Create Function character_set_client collation_connection Database Collation +add_func PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT CREATE DEFINER="root"@"localhost" FUNCTION "add_func"(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN int(11) +AS +BEGIN +c := 100; +d := d + 1; +RETURN a + b; +END latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION add_func; +# +# CREATE PROCEDURE with IN, OUT, INOUT qualifiers +# SHOW CREATE PROCEDURE +# +CREATE OR REPLACE PROCEDURE add_proc(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS +BEGIN +d := a + b + c + d; +END; +$$ +SHOW CREATE PROCEDURE add_proc; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +add_proc PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT CREATE DEFINER="root"@"localhost" PROCEDURE "add_proc"(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS +BEGIN +d := a + b + c + d; +END latin1 latin1_swedish_ci latin1_swedish_ci +DROP PROCEDURE add_proc; +# +# Call function from SELECT query +# SELECT > FUNCTION(IN) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION add_func2 (a IN INT, b IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION add_func2(a IN INT, b IN INT) RETURN INT +AS +BEGIN +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +select pkg2.add_func2(@a, @b); +pkg2.add_func2(@a, @b) +5 +DROP PACKAGE pkg2; +# +# Call function from SELECT query +# SELECT > FUNCTION(OUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION add_func3 (a IN INT, b IN INT, c OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION add_func3(a IN INT, b IN INT, c OUT INT) RETURN INT +AS +BEGIN +c := 100; +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +select pkg2.add_func3(@a, @b, @c); +ERROR HY000: OUT or INOUT argument 3 for function pkg2.add_func3 is not allowed here +DROP PACKAGE pkg2; +# +# Call function from SELECT query +# SELECT > FUNCTION(INOUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION add_func4 (a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION add_func4(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT +AS +BEGIN +c := 100; +d := d + 1; +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +set @d = 9; +select pkg2.add_func4(@a, @b, @c, @d); +ERROR HY000: OUT or INOUT argument 3 for function pkg2.add_func4 is not allowed here +DROP PACKAGE pkg2; +# +# Call from procedure +# PROCEDURE(OUT) > FUNCTION(IN) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE add_proc2 (a IN INT, b IN INT, c OUT INT); +FUNCTION add_func2 (a IN INT, b IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE add_proc2(a IN INT, b IN INT, c OUT INT) +AS +BEGIN +c := add_func2(a, b); +END; +FUNCTION add_func2(a IN INT, b IN INT) RETURN INT +AS +BEGIN +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.add_proc2(@a, @b, @c); +select @c; +@c +5 +DROP PACKAGE pkg2; +# +# Call from procedure +# PROCEDURE(OUT) > FUNCTION(OUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE add_proc3 (a IN INT, b IN INT, c OUT INT); +FUNCTION add_func3 (a IN INT, b IN INT, c OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE add_proc3(a IN INT, b IN INT, c OUT INT) +AS +res INT; +BEGIN +res := add_func3(a, b, c); +END; +FUNCTION add_func3(a IN INT, b IN INT, c OUT INT) RETURN INT +AS +BEGIN +c := 100; +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.add_proc3(@a, @b, @c); +select @c; +@c +100 +DROP PACKAGE pkg2; +# +# Call from procedure +# PROCEDURE(OUT) > FUNCTION(INOUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE add_proc4 (a IN INT, b IN INT, c OUT INT); +FUNCTION add_func4 (a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE add_proc4(a IN INT, b IN INT, res OUT INT) +AS +c INT; +d INT; +BEGIN +d := 30; +res := add_func4(a, b, c, d); +res := c + d; +END; +FUNCTION add_func4(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT +AS +BEGIN +c := 100; +d := d + 1; +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @res = 0; +call pkg2.add_proc4(@a, @b, @res); +select @res; +@res +131 +DROP PACKAGE pkg2; +# +# Call from procedure +# PROCEDURE(OUT) > PROCEDURE(OUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE test_proc1 (a IN INT, b IN INT, c OUT INT); +PROCEDURE add_proc (a IN INT, b IN INT, c OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE test_proc1(a IN INT, b IN INT, c OUT INT) +AS +BEGIN +call pkg2.add_proc(a, b, c); +END; +PROCEDURE add_proc(a IN INT, b IN INT, c OUT INT) +AS +BEGIN +c := a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.test_proc1(@a, @b, @c); +select @c; +@c +5 +DROP PACKAGE pkg2; +# +# Argument's order change +# PROCEDURE(a IN, b IN, c OUT) > FUNCTION(b IN, a IN, c OUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT); +FUNCTION func_sub(b IN INT, a IN INT, c OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT) +AS +res INT; +BEGIN +res := func_sub(b, a, c); +END; +FUNCTION func_sub(b IN INT, a IN INT, c OUT INT) RETURN INT +AS +res INT; +BEGIN +c := a - b; +res := a; +RETURN res; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.proc_main(@a, @b, @c); +select @c; +@c +-1 +DROP PACKAGE pkg2; +# +# Argument's order change +# PROCEDURE(a IN, b IN, c OUT) > FUNCTION(c OUT, b IN, a IN) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT); +FUNCTION func_sub(c OUT INT, b IN INT, a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT) +AS +res INT; +BEGIN +res := func_sub(c, b, a); +END; +FUNCTION func_sub(c OUT INT, b IN INT, a IN INT) RETURN INT +AS +res INT; +BEGIN +c := a - b; +res := a; +RETURN res; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.proc_main(@a, @b, @c); +select @c; +@c +-1 +DROP PACKAGE pkg2; +# +# Argument's order change +# PROCEDURE(a IN, b IN, c INOUT, d OUT) > FUNCTION(d OUT, a IN, b IN, c INOUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); +FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS +res INT; +BEGIN +res := func_sub(d, a, b, c); +d := d + c + res; +END; +FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT +AS +BEGIN +c := c + 6; +d := 10; +RETURN a - b; +END; +END; +$$ +set @a = 15; +set @b = 5; +set @c = 4; +set @d= 0; +call pkg2.proc_main(@a, @b, @c, @d); +select @d; +@d +30 +DROP PACKAGE pkg2; +# +# Argument's order change +# PROCEDURE(a IN INT, b IN INT, c INOUT INT, d OUT INT) > FUNCTION1(c INOUT INT, b IN INT) > FUNCTION2(d OUT INT, a IN INT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); +FUNCTION func_sub1(c INOUT INT, b IN INT) RETURN INT; +FUNCTION func_sub2(d OUT INT, a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS +res1 INT; +res2 INT; +BEGIN +res1 := func_sub1(c, b); +res2 := func_sub2(d, a); +d := d + c; +END; +FUNCTION func_sub1(c INOUT INT, b IN INT) RETURN INT +AS +BEGIN +c := c + b; +RETURN 0; +END; +FUNCTION func_sub2(d OUT INT, a IN INT) RETURN INT +AS +BEGIN +d := 5 + a; +RETURN 0; +END; +END; +$$ +set @a = 15; +set @b = 6; +set @c = 4; +set @d= 0; +call pkg2.proc_main(@a, @b, @c, @d); +select @d; +@d +30 +DROP PACKAGE pkg2; +# +# Argument's order change +# FUNCTION1(a IN, b IN) > FUNCTION2(b IN, c OUT, a IN) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT, b IN INT) RETURN INT; +FUNCTION func_sub(b IN INT, c OUT INT, a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT, b IN INT) RETURN INT +AS +c INT; +res INT; +BEGIN +res := func_sub(b, c, a); +RETURN res + c; +END; +FUNCTION func_sub(b IN INT, c OUT INT, a IN INT) RETURN INT +AS +BEGIN +c := 100; +RETURN a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +select pkg2.func_main(@a, @b); +pkg2.func_main(@a, @b) +105 +DROP PACKAGE pkg2; +# +# Call procedure inside function +# FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b IN, c OUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(b IN INT, a IN INT) RETURN INT; +PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(b IN INT, a IN INT) RETURN INT +AS +c INT; +BEGIN +call proc_sub(a, b, c); +RETURN c; +END; +PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT) +AS +BEGIN +c := a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +select pkg2.func_main(@a, @b); +pkg2.func_main(@a, @b) +5 +DROP PACKAGE pkg2; +# +# Call procedure inside function +# FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b INOUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(b IN INT, a IN INT) RETURN INT; +PROCEDURE proc_sub(a IN INT, b INOUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(b IN INT, a IN INT) RETURN INT +AS +BEGIN +call proc_sub(a, b); +RETURN b; +END; +PROCEDURE proc_sub(a IN INT, b INOUT INT) +AS +BEGIN +b := a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +select pkg2.func_main(@a, @b); +pkg2.func_main(@a, @b) +5 +DROP PACKAGE pkg2; +# +# Call procedure inside function +# FUNCTION1(a IN, b IN, c OUT) > PROCEDURE(a IN, b IN, c OUT) +# +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(b IN INT, a IN INT, c OUT INT) RETURN INT; +PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(b IN INT, a IN INT, c OUT INT) RETURN INT +AS +res INT; +BEGIN +call proc_sub(a, b, c); +RETURN 0; +END; +PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT) +AS +BEGIN +c := a + b; +END; +END; +$$ +set @a = 2; +set @b = 3; +set @c = 0; +select pkg2.func_main(@a, @b, @c); +ERROR HY000: OUT or INOUT argument 3 for function pkg2.func_main is not allowed here +DROP PACKAGE pkg2; +# +# Call function from UPDATE query +# UPDATE <table> SET <column> = FUNCTION(a IN) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a IN INT) RETURN INT +AS +BEGIN +RETURN a * 10; +END; +END; +$$ +set @a = 5; +UPDATE Persons SET Age = pkg2.func(@a) WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# Call function from UPDATE query +# UPDATE <table> SET <column> = FUNCTION(a OUT) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT +AS +BEGIN +a := 5; +RETURN 80; +END; +END; +$$ +set @a = 0; +UPDATE Persons SET Age = pkg2.func(@a) WHERE ID = 1; +ERROR HY000: OUT or INOUT argument 1 for function pkg2.func is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# Call function from INSERT query +# INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a IN) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a IN INT) RETURN INT +AS +BEGIN +RETURN a * 10; +END; +END; +$$ +set @a = 4; +INSERT INTO Persons SELECT 4, 'DDD', PKG2.func(@a); +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# Call function from INSERT query +# INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a OUT) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT +AS +BEGIN +a := 45; +RETURN 40; +END; +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +set @a = 0; +INSERT INTO Persons SELECT 5, 'EEE', PKG2.func(@a); +ERROR HY000: OUT or INOUT argument 1 for function PKG2.func is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# Call function from DELETE query +# DELETE FROM <table> WHERE <column> = FUNCTION(a IN) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a IN INT) RETURN INT +AS +BEGIN +RETURN a; +END; +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +set @a = 4; +DELETE FROM Persons WHERE ID = PKG2.func(@a); +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# Call function from DELETE query +# DELETE FROM <table> WHERE <column> = FUNCTION(a OUT) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT +AS +BEGIN +a := 40; +RETURN 4; +END; +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +set @a = 0; +DELETE FROM Persons WHERE ID = PKG2.func(@a); +ERROR HY000: OUT or INOUT argument 1 for function PKG2.func is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# SELECT query inside function +# FUNCTION(a IN) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT +AS +c INT; +BEGIN +SELECT AGE INTO c FROM Persons WHERE ID = a; +RETURN c; +END; +END; +$$ +set @a = 3; +select pkg2.func_main(@a); +pkg2.func_main(@a) +30 +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# SELECT query inside function +# FUNCTION(a OUT) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a OUT INT) RETURN INT +AS +BEGIN +SELECT AGE INTO a FROM Persons WHERE ID = 3; +RETURN 0; +END; +END; +$$ +set @a = 0; +select pkg2.func_main(@a); +ERROR HY000: OUT or INOUT argument 1 for function pkg2.func_main is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# SELECT query inside function +# FUNCTION(a INOUT) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a INOUT INT) RETURN INT +AS +BEGIN +SELECT AGE INTO a FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +set @a = 1; +select pkg2.func_main(@a); +ERROR HY000: OUT or INOUT argument 1 for function pkg2.func_main is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# SELECT query inside function +# FUNCTION(a IN) > FUNCTION(a IN, b OUT) > SELECT … FROM <table> +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT +AS +b INT; +res INT; +BEGIN +res := func_sub(a, b); +RETURN b; +END; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +set @a = 2; +select pkg2.func_main(@a); +pkg2.func_main(@a) +20 +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# UPDATE query inside function +# FUNCTION(a IN) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT +AS +c INT; +BEGIN +UPDATE Persons SET AGE = 50 WHERE ID = a; +SELECT AGE INTO c FROM Persons WHERE ID = a; +RETURN c; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +set @a = 5; +select pkg2.func_main(@a); +pkg2.func_main(@a) +50 +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# UPDATE query inside function +# FUNCTION(a IN, b OUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +UPDATE Persons SET AGE = 60 WHERE ID = a; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +set @a = 5; +set @b = 0; +select pkg2.func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function pkg2.func_main is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# UPDATE query inside function +# FUNCTION(a IN, b INOUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT +AS +BEGIN +UPDATE Persons SET AGE = 60 WHERE ID = a; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +set @a = 5; +set @b = 0; +select pkg2.func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function pkg2.func_main is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# UPDATE query inside function +# FUNCTION(a IN) > FUNCTION(a IN, b OUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 80); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT +AS +b INT; +res INT; +BEGIN +res := func_sub(a, b); +RETURN b; +END; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +UPDATE Persons SET AGE = 10 WHERE ID = a; +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 80 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +set @a = 1; +select pkg2.func_main(@a); +pkg2.func_main(@a) +10 +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# INSERT query inside function +# FUNCTION(a IN) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT +AS +b INT; +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN b; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +set @a = 6; +select pkg2.func_main(@a); +pkg2.func_main(@a) +60 +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +6 FFF 60 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# INSERT query inside function +# FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 50 +set @a = 6; +set @b = 0; +select pkg2.func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function pkg2.func_main is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# INSERT query inside function +# FUNCTION(a IN, b INOUT) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT +AS +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +set @a = 6; +set @b = 0; +select pkg2.func_main(@a, @b); +ERROR HY000: OUT or INOUT argument 2 for function pkg2.func_main is not allowed here +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# INSERT query inside function +# FUNCTION(a IN) > FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func_main(a IN INT) RETURN INT +AS +b INT; +res INT; +BEGIN +res := func_sub(a, b); +RETURN b; +END; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 60); +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +set @a = 6; +select pkg2.func_main(@a); +pkg2.func_main(@a) +60 +select * from Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 EEE 40 +6 FFF 60 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(IN) > SELECT FROM <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +BEGIN +b := func_sub(a); +END; +FUNCTION func_sub(a IN INT) RETURN INT +AS +b INT; +BEGIN +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN b; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +set @a = 2; +set @b = 0; +call pkg2.proc_main(@a, @b); +select @b; +@b +20 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(OUT) > SELECT FROM <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +res INT; +BEGIN +res := func_sub(a, b); +END; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +SELECT AGE INTO b FROM Persons WHERE ID = a; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +set @a = 1; +set @b = 0; +call pkg2.proc_main(@a, @b); +select @b; +@b +50 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(INOUT) > SELECT FROM <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +c INT; +res INT; +BEGIN +c := 5; +res := func_sub(a, c); +b := c; +END; +FUNCTION func_sub(a IN INT, c INOUT INT) RETURN INT +AS +res INT; +BEGIN +SELECT AGE INTO res FROM Persons WHERE ID = a; +c := c * 100; +RETURN res; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +set @a = 2; +set @b = 0; +call pkg2.proc_main(@a, @b); +select @b; +@b +500 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(IN) > INSESRT INTO <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +BEGIN +b := func_sub(a); +END; +FUNCTION func_sub(a IN INT) RETURN INT +AS +BEGIN +INSERT INTO Persons VALUE (a, 'FFF', 50); +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +set @a = 5; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(OUT) > INSESRT INTO <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +res INT; +BEGIN +res := func_sub(a, b); +END; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +INSERT INTO Persons VALUE (a, 'GGG', 60); +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +set @a = 6; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(INOUT) > INSESRT INTO <table> … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +c INT; +res INT; +BEGIN +c := 5; +res := func_sub(a, c); +b := c; +END; +FUNCTION func_sub(a IN INT, c INOUT INT) RETURN INT +AS +res INT; +BEGIN +INSERT INTO Persons VALUE (a, 'HHH', 70); +c := c * 100; +RETURN res; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +set @a = 7; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +7 HHH 70 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(IN) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +BEGIN +b := func_sub(a); +END; +FUNCTION func_sub(a IN INT) RETURN INT +AS +BEGIN +UPDATE Persons SET AGE = 100 WHERE ID = a; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 50 +6 GGG 60 +7 HHH 70 +set @a = 5; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 60 +7 HHH 70 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +res INT; +BEGIN +res := func_sub(a, b); +END; +FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT +AS +BEGIN +UPDATE Persons SET AGE = 100 WHERE ID = a; +b := 1; +RETURN 0; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 60 +7 HHH 70 +set @a = 6; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 100 +7 HHH 70 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# PROCEDURE > FUNCTION > SQL query +# PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE <table> SET … +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 100); +INSERT INTO Persons VALUES (7, 'HHH', 70); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT); +FUNCTION func_sub(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc_main(a IN INT, b OUT INT) +AS +c INT; +res INT; +BEGIN +c := 5; +res := func_sub(a, c); +b := c; +END; +FUNCTION func_sub(a IN INT, c INOUT INT) RETURN INT +AS +res INT; +BEGIN +UPDATE Persons SET AGE = 100 WHERE ID = a; +c := c * 100; +RETURN res; +END; +END; +$$ +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 100 +7 HHH 70 +set @a = 7; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +4 DDD 40 +5 FFF 100 +6 GGG 100 +7 HHH 100 +DROP TABLE Persons; +DROP PACKAGE pkg2; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 20 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 20 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(IN) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a IN INT) RETURN INT +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +DECLARE +a INT; +res INT; +BEGIN +a := 10; +res := 0; +res := pkg2.func(a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 30 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(OUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 40); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a OUT INT) RETURN INT +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +a := 100; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +DECLARE +a INT; +res INT; +BEGIN +a := 10; +res := 0; +res := pkg2.func(a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 40 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(INOUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +FUNCTION func(a INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +FUNCTION func(a INOUT INT) RETURN INT +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +a := 100; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +DECLARE +a INT; +res INT; +BEGIN +a := 10; +res := 0; +res := pkg2.func(a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 60 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(IN) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a IN INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a IN INT) +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 30 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a OUT INT) +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(INOUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a INOUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a INOUT INT) +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +a := 100; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +set @a = 2; +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 50 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(IN) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a OUT INT); +FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a OUT INT) +AS +res INT; +BEGIN +a := 100; +res := func(a); +END; +FUNCTION func(a IN INT) RETURN INT +AS +BEGIN +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 60 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a OUT INT); +FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a OUT INT) +AS +res INT; +BEGIN +a := 100; +res := func(a); +END; +FUNCTION func(a OUT INT) RETURN INT +AS +BEGIN +a := 200; +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 80 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE TABLE2 +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a OUT INT); +FUNCTION func(a INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a OUT INT) +AS +res INT; +BEGIN +a := 100; +res := func(a); +END; +FUNCTION func(a INOUT INT) RETURN INT +AS +BEGIN +a := 200; +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 90 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 90 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +1 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Trigger +# TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 with OUT argument (to check if OUT is returning by reference) +# +CREATE TABLE Persons ( +ID int, +Name varchar(255), +Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +CREATE TABLE PersonsLog ( +UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); +CREATE OR REPLACE PACKAGE pkg2 +AS +PROCEDURE proc(a OUT INT); +FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS +PROCEDURE proc(a OUT INT) +AS +res INT; +BEGIN +res := func(a); +UPDATE PersonsLog SET UpdateCount = a; +END; +FUNCTION func(a OUT INT) RETURN INT +AS +BEGIN +a := 111; +UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +RETURN 0; +END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN +call pkg2.proc(@a); +END; +$$ +SELECT * FROM Persons; +ID Name Age +1 AAA 10 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +0 +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +ID Name Age +1 AAA 80 +2 BBB 20 +3 CCC 30 +SELECT * FROM PersonsLog; +UpdateCount +111 +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; +# +# Package BODY variables as OUT parameters +# +CREATE PACKAGE pkg1 AS +FUNCTION f1(b IN OUT INT) RETURN INT; +FUNCTION show_private_variables() RETURN TEXT; +END; +$$ +CREATE PACKAGE BODY pkg1 AS +pa INT:= 0; +pb INT:= 10; +FUNCTION f1(b IN OUT INT) RETURN INT AS +BEGIN +b:= b + 100; +RETURN 500+b-100; +END; +FUNCTION show_private_variables() RETURN TEXT AS +BEGIN +RETURN 'Private variables: pa=' || pa || ' pb=' || pb; +END; +BEGIN +SET pa=f1(pb); +END; +$$ +SELECT pkg1.show_private_variables(); +pkg1.show_private_variables() +Private variables: pa=510 pb=110 +DROP PACKAGE pkg1; diff --git a/mysql-test/suite/compat/oracle/t/sp-cursor.test b/mysql-test/suite/compat/oracle/t/sp-cursor.test index 03b8b016ee0..d7e2a5dee68 100644 --- a/mysql-test/suite/compat/oracle/t/sp-cursor.test +++ b/mysql-test/suite/compat/oracle/t/sp-cursor.test @@ -987,3 +987,58 @@ DELIMITER ;$$ CALL p1(); DROP PROCEDURE p1; DROP TABLE t1; + + +--echo # +--echo # Start of 10.8 tests +--echo # + +--echo # +--echo # MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +--echo # + +DELIMITER $$; +DECLARE + va INT; + CURSOR cur (a IN INT) IS SELECT a FROM dual; +BEGIN + OPEN cur(1); + FETCH cur INTO va; + CLOSE cur; + SELECT va; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_NOT_SUPPORTED_YET +DECLARE + va INT; + CURSOR cur (a OUT INT) IS SELECT a FROM dual; +BEGIN + OPEN cur(1); + FETCH cur INTO va; + CLOSE cur; + SELECT va; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_NOT_SUPPORTED_YET +DECLARE + va INT; + CURSOR cur (a INOUT INT) IS SELECT a FROM dual; +BEGIN + OPEN cur(1); + FETCH cur INTO va; + CLOSE cur; + SELECT va; +END; +$$ +DELIMITER ;$$ + + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/suite/compat/oracle/t/sp-inout.test b/mysql-test/suite/compat/oracle/t/sp-inout.test new file mode 100644 index 00000000000..9f9d3bdb26a --- /dev/null +++ b/mysql-test/suite/compat/oracle/t/sp-inout.test @@ -0,0 +1,2497 @@ +--echo # +--echo # MDEV-10654 IN, OUT, INOUT parameters in CREATE FUNCTION +--echo # + +SET sql_mode=ORACLE; + +--echo # +--echo # CREATE PACKAGE with procedure and function with IN, OUT, INOUT qualifiers +--echo # And SHOW CREATE PACKAGE +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); + FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) + AS + res INT; + BEGIN + res := func_sub(d, a, b, c); + d := d + c + res; + END; + FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT + AS + BEGIN + c := c + 6; + d := 10; + RETURN a - b; + END; +END; +$$ +DELIMITER ;$$ + +SHOW CREATE PACKAGE pkg2; +SHOW CREATE PACKAGE BODY pkg2; +DROP PACKAGE pkg2; + +--echo # +--echo # CREATE FUNCTION with IN, OUT, INOUT qualifiers +--echo # SHOW CREATE FUNCTION +--echo # + +DELIMITER $$; +CREATE OR REPLACE FUNCTION add_func(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT +AS + BEGIN + c := 100; + d := d + 1; + RETURN a + b; + END; +$$ +DELIMITER ;$$ + +SHOW CREATE FUNCTION add_func; +DROP FUNCTION add_func; + +--echo # +--echo # CREATE PROCEDURE with IN, OUT, INOUT qualifiers +--echo # SHOW CREATE PROCEDURE +--echo # + +DELIMITER $$; +CREATE OR REPLACE PROCEDURE add_proc(a IN INT, b IN INT, c INOUT INT, d OUT INT) +AS + BEGIN + d := a + b + c + d; + END; +$$ +DELIMITER ;$$ + +SHOW CREATE PROCEDURE add_proc; +DROP PROCEDURE add_proc; + +--echo # +--echo # Call function from SELECT query +--echo # SELECT > FUNCTION(IN) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION add_func2 (a IN INT, b IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION add_func2(a IN INT, b IN INT) RETURN INT + AS + BEGIN + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +select pkg2.add_func2(@a, @b); +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from SELECT query +--echo # SELECT > FUNCTION(OUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION add_func3 (a IN INT, b IN INT, c OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION add_func3(a IN INT, b IN INT, c OUT INT) RETURN INT + AS + BEGIN + c := 100; + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.add_func3(@a, @b, @c); +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from SELECT query +--echo # SELECT > FUNCTION(INOUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION add_func4 (a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION add_func4(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT + AS + BEGIN + c := 100; + d := d + 1; + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +set @d = 9; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.add_func4(@a, @b, @c, @d); +DROP PACKAGE pkg2; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > FUNCTION(IN) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE add_proc2 (a IN INT, b IN INT, c OUT INT); + FUNCTION add_func2 (a IN INT, b IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE add_proc2(a IN INT, b IN INT, c OUT INT) + AS + BEGIN + c := add_func2(a, b); + END; + + FUNCTION add_func2(a IN INT, b IN INT) RETURN INT + AS + BEGIN + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.add_proc2(@a, @b, @c); +select @c; +DROP PACKAGE pkg2; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > FUNCTION(OUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE add_proc3 (a IN INT, b IN INT, c OUT INT); + FUNCTION add_func3 (a IN INT, b IN INT, c OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE add_proc3(a IN INT, b IN INT, c OUT INT) + AS + res INT; + BEGIN + res := add_func3(a, b, c); + END; + FUNCTION add_func3(a IN INT, b IN INT, c OUT INT) RETURN INT + AS + BEGIN + c := 100; + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.add_proc3(@a, @b, @c); +select @c; +DROP PACKAGE pkg2; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE add_proc4 (a IN INT, b IN INT, c OUT INT); + FUNCTION add_func4 (a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE add_proc4(a IN INT, b IN INT, res OUT INT) + AS + c INT; + d INT; + BEGIN + d := 30; + res := add_func4(a, b, c, d); + res := c + d; + END; + FUNCTION add_func4(a IN INT, b IN INT, c OUT INT, d INOUT INT) RETURN INT + AS + BEGIN + c := 100; + d := d + 1; + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @res = 0; +call pkg2.add_proc4(@a, @b, @res); +select @res; +DROP PACKAGE pkg2; + +--echo # +--echo # Call from procedure +--echo # PROCEDURE(OUT) > PROCEDURE(OUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE test_proc1 (a IN INT, b IN INT, c OUT INT); + PROCEDURE add_proc (a IN INT, b IN INT, c OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE test_proc1(a IN INT, b IN INT, c OUT INT) + AS + BEGIN + call pkg2.add_proc(a, b, c); + END; + PROCEDURE add_proc(a IN INT, b IN INT, c OUT INT) + AS + BEGIN + c := a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.test_proc1(@a, @b, @c); +select @c; +DROP PACKAGE pkg2; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN, b IN, c OUT) > FUNCTION(b IN, a IN, c OUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT); + FUNCTION func_sub(b IN INT, a IN INT, c OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT) + AS + res INT; + BEGIN + res := func_sub(b, a, c); + END; + FUNCTION func_sub(b IN INT, a IN INT, c OUT INT) RETURN INT + AS + res INT; + BEGIN + c := a - b; + res := a; + RETURN res; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.proc_main(@a, @b, @c); +select @c; +DROP PACKAGE pkg2; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN, b IN, c OUT) > FUNCTION(c OUT, b IN, a IN) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT); + FUNCTION func_sub(c OUT INT, b IN INT, a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c OUT INT) + AS + res INT; + BEGIN + res := func_sub(c, b, a); + END; + FUNCTION func_sub(c OUT INT, b IN INT, a IN INT) RETURN INT + AS + res INT; + BEGIN + c := a - b; + res := a; + RETURN res; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +call pkg2.proc_main(@a, @b, @c); +select @c; +DROP PACKAGE pkg2; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN, b IN, c INOUT, d OUT) > FUNCTION(d OUT, a IN, b IN, c INOUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); + FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) + AS + res INT; + BEGIN + res := func_sub(d, a, b, c); + d := d + c + res; + END; + FUNCTION func_sub(d OUT INT, a IN INT, b IN INT, c INOUT INT) RETURN INT + AS + BEGIN + c := c + 6; + d := 10; + RETURN a - b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 15; +set @b = 5; +set @c = 4; +set @d= 0; +call pkg2.proc_main(@a, @b, @c, @d); +select @d; +DROP PACKAGE pkg2; + +--echo # +--echo # Argument's order change +--echo # PROCEDURE(a IN INT, b IN INT, c INOUT INT, d OUT INT) > FUNCTION1(c INOUT INT, b IN INT) > FUNCTION2(d OUT INT, a IN INT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT); + FUNCTION func_sub1(c INOUT INT, b IN INT) RETURN INT; + FUNCTION func_sub2(d OUT INT, a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b IN INT, c INOUT INT, d OUT INT) + AS + res1 INT; + res2 INT; + BEGIN + res1 := func_sub1(c, b); + res2 := func_sub2(d, a); + d := d + c; + END; + FUNCTION func_sub1(c INOUT INT, b IN INT) RETURN INT + AS + BEGIN + c := c + b; + RETURN 0; + END; + FUNCTION func_sub2(d OUT INT, a IN INT) RETURN INT + AS + BEGIN + d := 5 + a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 15; +set @b = 6; +set @c = 4; +set @d= 0; +call pkg2.proc_main(@a, @b, @c, @d); +select @d; +DROP PACKAGE pkg2; + +--echo # +--echo # Argument's order change +--echo # FUNCTION1(a IN, b IN) > FUNCTION2(b IN, c OUT, a IN) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT, b IN INT) RETURN INT; + FUNCTION func_sub(b IN INT, c OUT INT, a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT, b IN INT) RETURN INT + AS + c INT; + res INT; + BEGIN + res := func_sub(b, c, a); + RETURN res + c; + END; + FUNCTION func_sub(b IN INT, c OUT INT, a IN INT) RETURN INT + AS + BEGIN + c := 100; + RETURN a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +select pkg2.func_main(@a, @b); +DROP PACKAGE pkg2; + +--echo # +--echo # Call procedure inside function +--echo # FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b IN, c OUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(b IN INT, a IN INT) RETURN INT; + PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(b IN INT, a IN INT) RETURN INT + AS + c INT; + BEGIN + call proc_sub(a, b, c); + RETURN c; + END; + PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT) + AS + BEGIN + c := a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +select pkg2.func_main(@a, @b); +DROP PACKAGE pkg2; + +--echo # +--echo # Call procedure inside function +--echo # FUNCTION1(a IN, b IN) > PROCEDURE(a IN, b INOUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(b IN INT, a IN INT) RETURN INT; + PROCEDURE proc_sub(a IN INT, b INOUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(b IN INT, a IN INT) RETURN INT + AS + BEGIN + call proc_sub(a, b); + RETURN b; + END; + PROCEDURE proc_sub(a IN INT, b INOUT INT) + AS + BEGIN + b := a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +select pkg2.func_main(@a, @b); +DROP PACKAGE pkg2; + +--echo # +--echo # Call procedure inside function +--echo # FUNCTION1(a IN, b IN, c OUT) > PROCEDURE(a IN, b IN, c OUT) +--echo # + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(b IN INT, a IN INT, c OUT INT) RETURN INT; + PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(b IN INT, a IN INT, c OUT INT) RETURN INT + AS + res INT; + BEGIN + call proc_sub(a, b, c); + RETURN 0; + END; + PROCEDURE proc_sub(a IN INT, b IN INT, c OUT INT) + AS + BEGIN + c := a + b; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +set @b = 3; +set @c = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a, @b, @c); +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from UPDATE query +--echo # UPDATE <table> SET <column> = FUNCTION(a IN) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a IN INT) RETURN INT + AS + BEGIN + RETURN a * 10; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 5; +UPDATE Persons SET Age = pkg2.func(@a) WHERE ID = 1; +SELECT * FROM Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from UPDATE query +--echo # UPDATE <table> SET <column> = FUNCTION(a OUT) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT + AS + BEGIN + a := 5; + RETURN 80; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +UPDATE Persons SET Age = pkg2.func(@a) WHERE ID = 1; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from INSERT query +--echo # INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a IN) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a IN INT) RETURN INT + AS + BEGIN + RETURN a * 10; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 4; +INSERT INTO Persons SELECT 4, 'DDD', PKG2.func(@a); +SELECT * FROM Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from INSERT query +--echo # INSERT INTO <table> SELECT <val1>, <val2>, FUNCTION(a OUT) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT + AS + BEGIN + a := 45; + RETURN 40; + END; +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +set @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +INSERT INTO Persons SELECT 5, 'EEE', PKG2.func(@a); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from DELETE query +--echo # DELETE FROM <table> WHERE <column> = FUNCTION(a IN) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a IN INT) RETURN INT + AS + BEGIN + RETURN a; + END; +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +set @a = 4; +DELETE FROM Persons WHERE ID = PKG2.func(@a); +SELECT * FROM Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # Call function from DELETE query +--echo # DELETE FROM <table> WHERE <column> = FUNCTION(a OUT) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT + AS + BEGIN + a := 40; + RETURN 4; + END; +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +set @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +DELETE FROM Persons WHERE ID = PKG2.func(@a); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a IN) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT + AS + c INT; + BEGIN + SELECT AGE INTO c FROM Persons WHERE ID = a; + RETURN c; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 3; +select pkg2.func_main(@a); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a OUT) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a OUT INT) RETURN INT + AS + BEGIN + SELECT AGE INTO a FROM Persons WHERE ID = 3; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a INOUT) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a INOUT INT) RETURN INT + AS + BEGIN + SELECT AGE INTO a FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 1; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # SELECT query inside function +--echo # FUNCTION(a IN) > FUNCTION(a IN, b OUT) > SELECT … FROM <table> +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT + AS + b INT; + res INT; + BEGIN + res := func_sub(a, b); + RETURN b; + END; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 2; +select pkg2.func_main(@a); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT + AS + c INT; + BEGIN + UPDATE Persons SET AGE = 50 WHERE ID = a; + + SELECT AGE INTO c FROM Persons WHERE ID = a; + RETURN c; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 5; +select pkg2.func_main(@a); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN, b OUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + UPDATE Persons SET AGE = 60 WHERE ID = a; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 5; +set @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a, @b); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN, b INOUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT + AS + BEGIN + UPDATE Persons SET AGE = 60 WHERE ID = a; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +set @a = 5; +set @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a, @b); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # UPDATE query inside function +--echo # FUNCTION(a IN) > FUNCTION(a IN, b OUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 80); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT + AS + b INT; + res INT; + BEGIN + res := func_sub(a, b); + RETURN b; + END; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + UPDATE Persons SET AGE = 10 WHERE ID = a; + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 1; +select pkg2.func_main(@a); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT + AS + b INT; + BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN b; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 6; +select pkg2.func_main(@a); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 50); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 6; +set @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a, @b); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN, b INOUT) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT, b INOUT INT) RETURN INT + AS + BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 6; +set @b = 0; +--error ER_SF_OUT_INOUT_ARG_NOT_ALLOWED +select pkg2.func_main(@a, @b); +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # INSERT query inside function +--echo # FUNCTION(a IN) > FUNCTION(a IN, b OUT) > INSERT INTO <table> VALUES … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'EEE', 40); + + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func_main(a IN INT) RETURN INT + AS + b INT; + res INT; + BEGIN + res := func_sub(a, b); + RETURN b; + END; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 60); + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 6; +select pkg2.func_main(@a); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(IN) > SELECT FROM <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + BEGIN + b := func_sub(a); + END; + FUNCTION func_sub(a IN INT) RETURN INT + AS + b INT; + BEGIN + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN b; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 2; +set @b = 0; +call pkg2.proc_main(@a, @b); +select @b; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(OUT) > SELECT FROM <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + res INT; + BEGIN + res := func_sub(a, b); + END; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + SELECT AGE INTO b FROM Persons WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 1; +set @b = 0; +call pkg2.proc_main(@a, @b); +select @b; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) > SELECT FROM <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + c INT; + res INT; + BEGIN + c := 5; + res := func_sub(a, c); + b := c; + END; + FUNCTION func_sub(a IN INT, c INOUT INT) RETURN INT + AS + res INT; + BEGIN + SELECT AGE INTO res FROM Persons WHERE ID = a; + c := c * 100; + RETURN res; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 2; +set @b = 0; +call pkg2.proc_main(@a, @b); +select @b; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(IN) > INSESRT INTO <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + BEGIN + b := func_sub(a); + END; + FUNCTION func_sub(a IN INT) RETURN INT + AS + BEGIN + INSERT INTO Persons VALUE (a, 'FFF', 50); + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 5; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(OUT) > INSESRT INTO <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + res INT; + BEGIN + res := func_sub(a, b); + END; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + INSERT INTO Persons VALUE (a, 'GGG', 60); + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 6; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) > INSESRT INTO <table> … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + c INT; + res INT; + BEGIN + c := 5; + res := func_sub(a, c); + b := c; + END; + FUNCTION func_sub(a IN INT, c INOUT INT) RETURN INT + AS + res INT; + BEGIN + INSERT INTO Persons VALUE (a, 'HHH', 70); + c := c * 100; + RETURN res; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 7; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(IN) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 50); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + BEGIN + b := func_sub(a); + END; + FUNCTION func_sub(a IN INT) RETURN INT + AS + BEGIN + UPDATE Persons SET AGE = 100 WHERE ID = a; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 5; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 60); +INSERT INTO Persons VALUES (7, 'HHH', 70); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + res INT; + BEGIN + res := func_sub(a, b); + END; + FUNCTION func_sub(a IN INT, b OUT INT) RETURN INT + AS + BEGIN + UPDATE Persons SET AGE = 100 WHERE ID = a; + b := 1; + RETURN 0; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 6; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # PROCEDURE > FUNCTION > SQL query +--echo # PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE <table> SET … +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); +INSERT INTO Persons VALUES (4, 'DDD', 40); +INSERT INTO Persons VALUES (5, 'FFF', 100); +INSERT INTO Persons VALUES (6, 'GGG', 100); +INSERT INTO Persons VALUES (7, 'HHH', 70); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT); + FUNCTION func_sub(a IN INT, b INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc_main(a IN INT, b OUT INT) + AS + c INT; + res INT; + BEGIN + c := 5; + res := func_sub(a, c); + b := c; + END; + FUNCTION func_sub(a IN INT, c INOUT INT) RETURN INT + AS + res INT; + BEGIN + UPDATE Persons SET AGE = 100 WHERE ID = a; + c := c * 100; + RETURN res; + END; +END; +$$ +DELIMITER ;$$ + +select * from Persons; +set @a = 7; +set @b = 0; +call pkg2.proc_main(@a, @b); +select * from Persons; +DROP TABLE Persons; +DROP PACKAGE pkg2; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 20 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(IN) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a IN INT) RETURN INT + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +DECLARE + a INT; + res INT; +BEGIN + a := 10; + res := 0; + res := pkg2.func(a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(OUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 40); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a OUT INT) RETURN INT + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + a := 100; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +DECLARE + a INT; + res INT; +BEGIN + a := 10; + res := 0; + res := pkg2.func(a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > FUNCTION(INOUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 50); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + FUNCTION func(a INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + FUNCTION func(a INOUT INT) RETURN INT + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + a := 100; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +DECLARE + a INT; + res INT; +BEGIN + a := 10; + res := 0; + res := pkg2.func(a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(IN) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a IN INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a IN INT) + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 30 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a OUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a OUT INT) + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(INOUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a INOUT INT); +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a INOUT INT) + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + a := 100; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + set @a = 2; + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 50 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(IN) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a OUT INT); + FUNCTION func(a IN INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a OUT INT) + AS + res INT; + BEGIN + a := 100; + res := func(a); + END; + FUNCTION func(a IN INT) RETURN INT + AS + BEGIN + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 60 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a OUT INT); + FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a OUT INT) + AS + res INT; + BEGIN + a := 100; + res := func(a); + END; + FUNCTION func(a OUT INT) RETURN INT + AS + BEGIN + a := 200; + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(INOUT) > UPDATE TABLE2 +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a OUT INT); + FUNCTION func(a INOUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a OUT INT) + AS + res INT; + BEGIN + a := 100; + res := func(a); + END; + FUNCTION func(a INOUT INT) RETURN INT + AS + BEGIN + a := 200; + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 90 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + +--echo # +--echo # Trigger +--echo # TRIGGER AFTER UPDATE ON TABLE1 > PROCEDURE(OUT) > FUNCTION(OUT) > UPDATE TABLE2 with OUT argument (to check if OUT is returning by reference) +--echo # + +CREATE TABLE Persons ( + ID int, + Name varchar(255), + Age int +); +INSERT INTO Persons VALUES (1, 'AAA', 10); +INSERT INTO Persons VALUES (2, 'BBB', 20); +INSERT INTO Persons VALUES (3, 'CCC', 30); + +CREATE TABLE PersonsLog ( + UpdateCount int +); +INSERT INTO PersonsLog VALUES (0); + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg2 +AS + PROCEDURE proc(a OUT INT); + FUNCTION func(a OUT INT) RETURN INT; +END; +$$ +CREATE OR REPLACE PACKAGE BODY pkg2 +AS + PROCEDURE proc(a OUT INT) + AS + res INT; + BEGIN + res := func(a); + UPDATE PersonsLog SET UpdateCount = a; + END; + FUNCTION func(a OUT INT) RETURN INT + AS + BEGIN + a := 111; + UPDATE PersonsLog SET UpdateCount = UpdateCount+1; + RETURN 0; + END; +END; +$$ +CREATE OR REPLACE TRIGGER my_trigger +AFTER UPDATE ON Persons +FOR EACH ROW +BEGIN + call pkg2.proc(@a); +END; +$$ +DELIMITER ;$$ + +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +UPDATE Persons SET Age = 80 WHERE ID = 1; +SELECT * FROM Persons; +SELECT * FROM PersonsLog; +DROP TRIGGER my_trigger; +DROP PACKAGE pkg2; +DROP TABLE Persons; +DROP TABLE PersonsLog; + + +--echo # +--echo # Package BODY variables as OUT parameters +--echo # + +DELIMITER $$; +CREATE PACKAGE pkg1 AS + FUNCTION f1(b IN OUT INT) RETURN INT; + FUNCTION show_private_variables() RETURN TEXT; +END; +$$ +CREATE PACKAGE BODY pkg1 AS + pa INT:= 0; + pb INT:= 10; + FUNCTION f1(b IN OUT INT) RETURN INT AS + BEGIN + b:= b + 100; + RETURN 500+b-100; + END; + + FUNCTION show_private_variables() RETURN TEXT AS + BEGIN + RETURN 'Private variables: pa=' || pa || ' pb=' || pb; + END; +BEGIN + SET pa=f1(pb); +END; +$$ +DELIMITER ;$$ +SELECT pkg1.show_private_variables(); +DROP PACKAGE pkg1; diff --git a/mysql-test/suite/encryption/r/innodb_encrypt_log_corruption.result b/mysql-test/suite/encryption/r/innodb_encrypt_log_corruption.result index 8d1eb447b03..3c3e4831d8a 100644 --- a/mysql-test/suite/encryption/r/innodb_encrypt_log_corruption.result +++ b/mysql-test/suite/encryption/r/innodb_encrypt_log_corruption.result @@ -12,16 +12,15 @@ WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint/ in mysqld.1.err -FOUND 2 /Plugin 'InnoDB' registration as a STORAGE ENGINE failed/ in mysqld.1.err # redo log from before MariaDB 10.2.2, with corrupted log block # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err +FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint/ in mysqld.1.err # empty redo log from before MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); @@ -29,53 +28,55 @@ COUNT(*) 1 FOUND 1 /InnoDB: Upgrading redo log:/ in mysqld.1.err # Corrupted multi-file redo log from before MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 0 -FOUND 2 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err -# Empty multi-file redo log from before MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err +# Empty multi-file redo log (wrong offset) from before MariaDB 10.2.2 +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) -1 -FOUND 2 /InnoDB: Upgrading redo log:/ in mysqld.1.err +0 +FOUND 3 /Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint\./ in mysqld.1.err # Multi-file redo log with size mismatch from after MariaDB 10.2.2 # Corrupted multi-file redo log from after MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 0 -FOUND 1 /InnoDB: Log file .*ib_logfile1 is of different size 1048576 bytes than other log files 2097152 bytes!/ in mysqld.1.err -FOUND 1 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with BogoDB 1\.2\.3\.4, and it appears corrupted\./ in mysqld.1.err -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +FOUND 3 /Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint\./ in mysqld.1.err +FOUND 1 /InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\.2\.3\.4\./ in mysqld.1.err +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 0 -FOUND 2 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with BogoDB 1\.2\.3\.4, and it appears corrupted\./ in mysqld.1.err +FOUND 1 /InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files 1048576 bytes!/ in mysqld.1.err +FOUND 2 /InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\.2\.3\.4\./ in mysqld.1.err # Empty multi-file redo log from after MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) -1 -FOUND 3 /InnoDB: Upgrading redo log:/ in mysqld.1.err +0 +FOUND 3 /InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\.2\.3\.4\./ in mysqld.1.err # redo log from "after" MariaDB 10.2.2, but with invalid header checksum # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Invalid redo log header checksum/ in mysqld.1.err +FOUND 1 /InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files 4194304 bytes!/ in mysqld.1.err +FOUND 1 /InnoDB: Invalid log header checksum/ in mysqld.1.err # distant future redo log format, with valid header checksum # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -89,14 +90,14 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: No valid checkpoint found .corrupted redo log/ in mysqld.1.err +FOUND 1 /InnoDB: No valid checkpoint was found; the log was created with malicious intentions, or perhaps\./ in mysqld.1.err # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err +FOUND 2 /InnoDB: Invalid log header checksum/ in mysqld.1.err FOUND 1 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with malicious intentions, or perhaps, and it appears corrupted\./ in mysqld.1.err # same, but with current-version header # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 @@ -104,7 +105,7 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 2 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err +FOUND 3 /InnoDB: Invalid log header checksum/ in mysqld.1.err # --innodb-force-recovery=6 (skip the entire redo log) # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=6 SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -112,7 +113,7 @@ WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS InnoDB YES Supports transactions, row-level locking, foreign keys and encryption for tables YES YES YES -FOUND 1 /\[Note\] InnoDB: .* started; log sequence number 0/ in mysqld.1.err +FOUND 1 /\[Note\] InnoDB: log sequence number 0.*; transaction id 0/ in mysqld.1.err # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -141,8 +142,9 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 2454333373 found: 150151/ in mysqld.1.err -FOUND 3 /\[ERROR\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1, and it appears corrupted\./ in mysqld.1.err +NOT FOUND /InnoDB: Invalid log header checksum +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1, and it appears corrupted\./ in mysqld.1.err # valid header, invalid checkpoint 1, valid checkpoint 2, invalid log record # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -165,21 +167,29 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS FOUND 3 /\[ERROR\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1\./ in mysqld.1.err # Empty 10.3 redo log -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 1 -FOUND 1 /InnoDB: .* started; log sequence number 1213964; transaction id 0/ in mysqld.1.err +FOUND 1 /InnoDB: log sequence number 1213964\b.*; transaction id 0/ in mysqld.1.err # Empty 10.2 redo log -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m +SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +COUNT(*) +1 +FOUND 3 /InnoDB: Upgrading redo log:/ in mysqld.1.err +# Empty 10.5 redo log +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 1 -FOUND 5 /InnoDB: Upgrading redo log:/ in mysqld.1.err +FOUND 4 /InnoDB: Upgrading redo log:/ in mysqld.1.err # Minimal MariaDB 10.1.21 encrypted redo log # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 SELECT COUNT(*) `1` FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb' diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index fb4738a1fed..2ef3fa6624c 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -1409,18 +1409,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t0.a" + "sorts": [ + { + "filesort": { + "sort_key": "t0.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t0", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } } @@ -1440,18 +1446,24 @@ EXPLAIN "filesort": { "sort_key": "t1.a", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "sum(t1.b)" + "sorts": [ + { + "filesort": { + "sort_key": "sum(t1.b)" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } } @@ -1469,18 +1481,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "sum(t1.b)" + "sorts": [ + { + "filesort": { + "sort_key": "sum(t1.b)" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } } @@ -1503,18 +1521,24 @@ EXPLAIN "filesort": { "sort_key": "t1.b", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.b" + "sorts": [ + { + "filesort": { + "sort_key": "t1.b" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 10, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 10, + "filtered": 100 + } + } + ] } } } @@ -1648,18 +1672,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.c, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.c, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1674,18 +1704,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1700,18 +1736,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.c, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.c, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1726,18 +1768,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.c, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.c, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 3, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + ] } } } @@ -1782,18 +1830,24 @@ EXPLAIN "filesort": { "sort_key": "row_number() over ( order by t1.s1,t1.s2) desc", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.s1, t1.s2" + "sorts": [ + { + "filesort": { + "sort_key": "t1.s1, t1.s2" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] } } } @@ -1935,18 +1989,24 @@ EXPLAIN "select_id": 1, "duplicate_removal": { "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.part_id, t1.a" + "sorts": [ + { + "filesort": { + "sort_key": "t1.part_id, t1.a" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 9, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 9, + "filtered": 100 + } + } + ] } } } @@ -2108,18 +2168,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.a, t1.pk" + "sorts": [ + { + "filesort": { + "sort_key": "t1.a, t1.pk" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 11, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 11, + "filtered": 100 + } + } + ] } } } @@ -2169,18 +2235,24 @@ EXPLAIN "query_block": { "select_id": 1, "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "t1.a, t1.b" + "sorts": [ + { + "filesort": { + "sort_key": "t1.a, t1.b" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "rows": 6, - "filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 6, + "filtered": 100 + } + } + ] } } } @@ -3761,29 +3833,35 @@ ANALYZE "r_loops": 1, "r_total_time_ms": "REPLACED", "window_functions_computation": { - "sorts": { - "filesort": { - "sort_key": "`row_number() OVER()`", - "r_loops": 1, - "r_total_time_ms": "REPLACED", - "r_used_priority_queue": false, - "r_output_rows": 3, - "r_buffer_size": "REPLACED", - "r_sort_mode": "sort_key,rowid" + "sorts": [ + { + "filesort": { + "sort_key": "`row_number() OVER()`", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "r_used_priority_queue": false, + "r_output_rows": 3, + "r_buffer_size": "REPLACED", + "r_sort_mode": "sort_key,rowid" + } } - }, + ], "temporary_table": { - "table": { - "table_name": "t1", - "access_type": "ALL", - "r_loops": 1, - "rows": 3, - "r_rows": 3, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - } + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 3, + "r_rows": 3, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + } + ] } } } diff --git a/mysql-test/suite/engines/funcs/r/ix_using_order.result b/mysql-test/suite/engines/funcs/r/ix_using_order.result index 8d270da1b96..02b34dd4f6c 100644 --- a/mysql-test/suite/engines/funcs/r/ix_using_order.result +++ b/mysql-test/suite/engines/funcs/r/ix_using_order.result @@ -17,7 +17,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, - KEY `i1` (`c1`) USING BTREE + KEY `i1` (`c1` DESC) USING BTREE ) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; SHOW TABLES; @@ -40,7 +40,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL, - UNIQUE KEY `i1` (`c1`) USING BTREE + UNIQUE KEY `i1` (`c1` DESC) USING BTREE ) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP INDEX i1 ON t1; DROP TABLE t1; diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 28736515327..6dcd53e77c7 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -157,31 +157,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t3", - "access_type": "ALL", - "rows": 7, - "filtered": 100 - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "18", - "used_key_parts": ["name"], - "ref": ["federated.t3.name"], - "rows": 2, - "filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "message": "Pushed derived" + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows": 7, + "filtered": 100 + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "18", + "used_key_parts": ["name"], + "ref": ["federated.t3.name"], + "rows": 2, + "filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "table": { + "message": "Pushed derived" + } + } } } } - } + ] } } ANALYZE @@ -221,41 +227,47 @@ ANALYZE "select_id": 1, "r_loops": 1, "r_total_time_ms": "REPLACED", - "table": { - "table_name": "t3", - "access_type": "ALL", - "r_loops": 1, - "rows": 7, - "r_rows": 7, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100 - }, - "table": { - "table_name": "<derived2>", - "access_type": "ref", - "possible_keys": ["key0"], - "key": "key0", - "key_length": "18", - "used_key_parts": ["name"], - "ref": ["federated.t3.name"], - "r_loops": 7, - "rows": 2, - "r_rows": 0, - "r_table_time_ms": "REPLACED", - "r_other_time_ms": "REPLACED", - "filtered": 100, - "r_filtered": 100, - "materialized": { - "query_block": { - "select_id": 2, - "table": { - "message": "Pushed derived" + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "r_loops": 1, + "rows": 7, + "r_rows": 7, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "18", + "used_key_parts": ["name"], + "ref": ["federated.t3.name"], + "r_loops": 7, + "rows": 2, + "r_rows": 0, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "materialized": { + "query_block": { + "select_id": 2, + "table": { + "message": "Pushed derived" + } + } } } } - } + ] } } SELECT t.id, federated.t3.name @@ -346,31 +358,37 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "t5", - "access_type": "ALL", - "rows": 2, - "filtered": 100 - }, - "block-nl-join": { - "table": { - "table_name": "<derived2>", - "access_type": "ALL", - "rows": 5, - "filtered": 100 + "nested_loop": [ + { + "table": { + "table_name": "t5", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + } }, - "buffer_type": "flat", - "buffer_size": "65", - "join_type": "BNL", - "materialized": { - "query_block": { - "select_id": 2, + { + "block-nl-join": { "table": { - "message": "Pushed derived" + "table_name": "<derived2>", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "65", + "join_type": "BNL", + "materialized": { + "query_block": { + "select_id": 2, + "table": { + "message": "Pushed derived" + } + } } } } - } + ] } } drop table t5; diff --git a/mysql-test/suite/federated/indexes.result b/mysql-test/suite/federated/indexes.result new file mode 100644 index 00000000000..d5ebbeeb6dc --- /dev/null +++ b/mysql-test/suite/federated/indexes.result @@ -0,0 +1,33 @@ +# +# MDEV-27398 DESC index causes wrong (empty) result on Federated tables +# +create table t (a int); +insert into t values (1),(5),(2),(3),(4); +create table tf (a int, key(a desc)) connection 'mysql://root@127.0.0.1:$MASTER_MYPORT/test/t' engine=Federated; +select * from tf; +a +1 +2 +3 +4 +5 +select * from tf where a > 2; +a +3 +4 +5 +select * from tf where a < 3; +a +1 +2 +select * from tf where a >= 3; +a +3 +4 +5 +select * from tf where a <= 3; +a +1 +2 +3 +drop table tf, t; diff --git a/mysql-test/suite/federated/indexes.test b/mysql-test/suite/federated/indexes.test new file mode 100644 index 00000000000..2ad2f823acf --- /dev/null +++ b/mysql-test/suite/federated/indexes.test @@ -0,0 +1,22 @@ +--source include/not_embedded.inc +--source suite/federated/have_federatedx.inc + +--echo # +--echo # MDEV-27398 DESC index causes wrong (empty) result on Federated tables +--echo # + +create table t (a int); +insert into t values (1),(5),(2),(3),(4); + +--evalp create table tf (a int, key(a desc)) connection 'mysql://root@127.0.0.1:$MASTER_MYPORT/test/t' engine=Federated +--sorted_result +select * from tf; +--sorted_result +select * from tf where a > 2; +--sorted_result +select * from tf where a < 3; +--sorted_result +select * from tf where a >= 3; +--sorted_result +select * from tf where a <= 3; +drop table tf, t; diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index ef4832cdb8a..b50ae58df28 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result @@ -13,9 +13,9 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references NEVER NULL def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI select,insert,update,references NEVER NULL def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI select,insert,update,references NEVER NULL -def mysql column_stats histogram 11 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references NEVER NULL +def mysql column_stats histogram 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references NEVER NULL def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references NEVER NULL -def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') select,insert,update,references NEVER NULL +def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') select,insert,update,references NEVER NULL def mysql column_stats max_value 5 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references NEVER NULL def mysql column_stats min_value 4 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references NEVER NULL def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references NEVER NULL @@ -345,8 +345,8 @@ NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4) NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4) NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4) NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned -3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') -1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255) +3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') +1.0000 mysql column_stats histogram longblob 4294967295 4294967295 NULL NULL longblob 3.0000 mysql db Host char 255 765 utf8mb3 utf8mb3_bin char(255) 3.0000 mysql db Db char 64 192 utf8mb3 utf8mb3_bin char(64) 3.0000 mysql db User char 128 384 utf8mb3 utf8mb3_bin char(128) diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result index 1a794c2828d..96751dfd176 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result @@ -13,9 +13,9 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) NEVER NULL def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI NEVER NULL def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI NEVER NULL -def mysql column_stats histogram 11 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) NEVER NULL +def mysql column_stats histogram 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob NEVER NULL def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned NEVER NULL -def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') NEVER NULL +def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') NEVER NULL def mysql column_stats max_value 5 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) NEVER NULL def mysql column_stats min_value 4 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) NEVER NULL def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) NEVER NULL @@ -342,8 +342,8 @@ NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4) NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4) NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4) NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned -3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') -1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255) +3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') +1.0000 mysql column_stats histogram longblob 4294967295 4294967295 NULL NULL longblob 3.0000 mysql db Host char 255 765 utf8mb3 utf8mb3_bin char(255) 3.0000 mysql db Db char 64 192 utf8mb3 utf8mb3_bin char(64) 3.0000 mysql db User char 128 384 utf8mb3 utf8mb3_bin char(128) diff --git a/mysql-test/suite/galera/r/galera_as_slave.result b/mysql-test/suite/galera/r/galera_as_slave.result index 391ceecd509..1035fe1e9be 100644 --- a/mysql-test/suite/galera/r/galera_as_slave.result +++ b/mysql-test/suite/galera/r/galera_as_slave.result @@ -18,6 +18,12 @@ SELECT COUNT(*) = 3 FROM t1; COUNT(*) = 3 1 connection node_3; +SET @@session.binlog_alter_two_phase = 1; +ALTER TABLE t1 ADD COLUMN f2 INT; +INSERT INTO t1 VALUES (4,1); +connection node_1; +connection node_2; +connection node_3; DROP TABLE t1; connection node_2; STOP SLAVE; diff --git a/mysql-test/suite/galera/t/galera_as_slave.test b/mysql-test/suite/galera/t/galera_as_slave.test index da92437b118..859fe19c9bb 100644 --- a/mysql-test/suite/galera/t/galera_as_slave.test +++ b/mysql-test/suite/galera/t/galera_as_slave.test @@ -38,8 +38,24 @@ INSERT INTO t1 VALUES (3); SELECT COUNT(*) = 3 FROM t1; --connection node_3 +SET @@session.binlog_alter_two_phase = 1; +ALTER TABLE t1 ADD COLUMN f2 INT; +INSERT INTO t1 VALUES (4,1); + +--connection node_1 +--let $count = 4 +--let $table = t1 +--source include/wait_until_rows_count.inc + +--connection node_2 +--let $count = 4 +--let $table = t1 +--source include/wait_until_rows_count.inc + +--connection node_3 DROP TABLE t1; + --connection node_2 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index d3e8808a4ef..123b9ea5885 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -23,6 +23,8 @@ galera_slave_options_do : MDEV-8798 galera_slave_options_ignore : MDEV-8798 galera_vote_rejoin_mysqldump : MDEV-24481: galera_3nodes.galera_vote_rejoin_mysqldump MTR failed: mysql_shutdown failed galera_ipv6_mysqldump : MDEV-26499: galera_3nodes.galera_ipv6_mysqldump MTR failed: mysql_shutdown failed +galera_ipv6_mariabackup : MDEV-24097 +galera_ipv6_mariabackup_section : MDEV-24097, MDEV-22195 galera_wsrep_schema : MDEV-26503 : galera_3nodes.galera_wsrep_schema MTR failed: mysql_shutdown failed galera_ipv6_mariabackup : MDEV-24097 MTR sporadaically fails: Failed to start mysqld or mysql_shutdown failed galera_ipv6_mariabackup_section : MDEV-24097 MTR sporadaically fails: Failed to start mysqld or mysql_shutdown failed diff --git a/mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc b/mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc index 3f48f86ce7c..3bb44523e64 100644 --- a/mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc +++ b/mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc @@ -1192,18 +1192,6 @@ let $values1 = 'any value',default; let $rows = 1; --source suite/gcol/inc/gcol_supported_sql_funcs.inc ---echo # DES_ENCRYPT(), DES_DECRYPT() ---source include/have_ssl_crypto_functs.inc -let $cols = a varchar(1024), b varchar(1024) generated always as (des_encrypt(des_decrypt(a,'adf'),'adf')) virtual; -let $values1 = 'MySQL',default; ---disable_warnings -eval create table t1 ($cols); -show create table t1; ---enable_warnings -eval insert into t1 values ($values1); -select * from t1; -drop table t1; - --echo # INET_ATON(), INET_NTOA() let $cols = a varchar(1024), b varchar(1024) generated always as (inet_ntoa(inet_aton(a))) virtual; let $values1 = '127.0.0.1',default; diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result index 4fc4801482b..9929f4d1eaa 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result @@ -2889,20 +2889,6 @@ a b any value any value drop table t1; set sql_warnings = 0; -# DES_ENCRYPT(), DES_DECRYPT() -create table t1 (a varchar(1024), b varchar(1024) generated always as (des_encrypt(des_decrypt(a,'adf'),'adf')) virtual); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` varchar(1024) DEFAULT NULL, - `b` varchar(1024) GENERATED ALWAYS AS (des_encrypt(des_decrypt(`a`,'adf'),'adf')) VIRTUAL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into t1 values ('MySQL',default); -select * from t1; -a b -MySQL ÿw2¥ð -èõÁ -drop table t1; # INET_ATON(), INET_NTOA() set sql_warnings = 1; create table t1 (a varchar(1024), b varchar(1024) generated always as (inet_ntoa(inet_aton(a))) virtual); diff --git a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result index 7ddcd4f36ff..802e830a587 100644 --- a/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result @@ -2889,20 +2889,6 @@ a b any value any value drop table t1; set sql_warnings = 0; -# DES_ENCRYPT(), DES_DECRYPT() -create table t1 (a varchar(1024), b varchar(1024) generated always as (des_encrypt(des_decrypt(a,'adf'),'adf')) virtual); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` varchar(1024) DEFAULT NULL, - `b` varchar(1024) GENERATED ALWAYS AS (des_encrypt(des_decrypt(`a`,'adf'),'adf')) VIRTUAL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -insert into t1 values ('MySQL',default); -select * from t1; -a b -MySQL ÿw2¥ð -èõÁ -drop table t1; # INET_ATON(), INET_NTOA() set sql_warnings = 1; create table t1 (a varchar(1024), b varchar(1024) generated always as (inet_ntoa(inet_aton(a))) virtual); diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result index 6bc9ff0d527..e523920bcd0 100644 --- a/mysql-test/suite/heap/heap_hash.result +++ b/mysql-test/suite/heap/heap_hash.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2; create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; insert into t1 values(1,1),(2,2),(3,3),(4,4); delete from t1 where a=1 or a=0; @@ -467,4 +466,23 @@ SELECT * FROM t1 WHERE c1='bar2'; c1 bar2 DROP TABLE t1; -End of 5.5 tests +# +# End of 5.5 tests +# +# +# MDEV-27406 Index on a HEAP table retains DESC attribute despite being hash +# +create table t1 (a int, key(a desc)) engine=memory; +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 Ignored +t1 1 a 1 a NULL 0 NULL NULL YES HASH NO +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table t1; +# +# End of 10.8 tests +# diff --git a/mysql-test/suite/heap/heap_hash.test b/mysql-test/suite/heap/heap_hash.test index 3a8979a2393..3d3855d8062 100644 --- a/mysql-test/suite/heap/heap_hash.test +++ b/mysql-test/suite/heap/heap_hash.test @@ -2,10 +2,6 @@ # Test of heap tables. # ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; insert into t1 values(1,1),(2,2),(3,3),(4,4); delete from t1 where a=1 or a=0; @@ -346,4 +342,18 @@ explain SELECT * FROM t1 WHERE c1='bar2'; SELECT * FROM t1 WHERE c1='bar2'; DROP TABLE t1; ---echo End of 5.5 tests +--echo # +--echo # End of 5.5 tests +--echo # + +--echo # +--echo # MDEV-27406 Index on a HEAP table retains DESC attribute despite being hash +--echo # +create table t1 (a int, key(a desc)) engine=memory; +show index from t1; +show create table t1; +drop table t1; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/suite/innodb/include/no_checkpoint_end.inc b/mysql-test/suite/innodb/include/no_checkpoint_end.inc index 4a00dadfd6e..61721650f32 100644 --- a/mysql-test/suite/innodb/include/no_checkpoint_end.inc +++ b/mysql-test/suite/innodb/include/no_checkpoint_end.inc @@ -10,12 +10,12 @@ my $cp = $ENV{CHECKPOINT_LSN}; $cp =~ s/^InnoDB\t\t//; my $log = "$ENV{MYSQLD_DATADIR}ib_logfile0"; open(LOG, "<$log") || die "Unable to open $log"; -seek(LOG, 512, 0) || die "Unable to seek $log"; -die unless read(LOG, $_, 16) == 16; -my ($no1hi,$no1lo,$cp1hi,$cp1lo) = unpack("N*", $_); -seek(LOG, 3 * 512, 0) || die "Unable to seek $log"; -die unless read(LOG, $_, 16) == 16; -my ($no2hi,$no2lo,$cp2hi,$cp2lo) = unpack("N*", $_); +seek(LOG, 4096, 0) || die "Unable to seek $log"; +die unless read(LOG, $_, 8) == 8; +my ($cp1hi,$cp1lo) = unpack("NN", $_); +seek(LOG, 8192, 0) || die "Unable to seek $log"; +die unless read(LOG, $_, 8) == 8; +my ($cp2hi,$cp2lo) = unpack("NN", $_); close(LOG); my $cp1 = $cp1hi << 32 | $cp1lo; @@ -27,8 +27,7 @@ if ($cp1 > $cp || $cp2 > $cp) { print OUT "--source include/start_mysqld.inc\n" unless $ENV{no_checkpoint_kill}; print OUT "$ENV{CLEANUP_IF_CHECKPOINT}\n"; - print OUT "--skip Extra checkpoint 1 after $cp"; - print OUT " ($no1hi:$no1lo=$cp1,$no2hi:$no2lo=$cp2)\n"; + print OUT "--skip Extra checkpoint 1 after $cp ($cp1,$cp2)\n"; } close(OUT); diff --git a/mysql-test/suite/innodb/r/autoinc_persist,desc.rdiff b/mysql-test/suite/innodb/r/autoinc_persist,desc.rdiff new file mode 100644 index 00000000000..639a60648e4 --- /dev/null +++ b/mysql-test/suite/innodb/r/autoinc_persist,desc.rdiff @@ -0,0 +1,769 @@ +@@ -13,212 +13,212 @@ + # + # Pre-create several tables + SET SQL_MODE='STRICT_ALL_TABLES'; +-CREATE TABLE t1(a TINYINT AUTO_INCREMENT KEY) ENGINE = InnoDB; ++CREATE TABLE t1(a TINYINT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t1 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31); + SELECT * FROM t1; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 + 31 +-CREATE TABLE t2(a TINYINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 ++CREATE TABLE t2(a TINYINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t2 VALUES(-5); + ERROR 22003: Out of range value for column 'a' at row 1 + INSERT INTO t2 VALUES(0), (0), (0), (0), (8), (10), (0), + (20), (30), (31); + SELECT * FROM t2; + a +-1 +-2 +-3 +-4 +-8 +-10 +-11 +-20 +-30 + 31 +-CREATE TABLE t3(a SMALLINT AUTO_INCREMENT KEY) ENGINE = InnoDB; ++30 ++20 ++11 ++10 ++8 ++4 ++3 ++2 ++1 ++CREATE TABLE t3(a SMALLINT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t3 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31), (1024), (4096); + SELECT * FROM t3; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 +-31 +-1024 + 4096 +-CREATE TABLE t4(a SMALLINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; ++1024 ++31 ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 ++CREATE TABLE t4(a SMALLINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t4 VALUES(-5); + ERROR 22003: Out of range value for column 'a' at row 1 + INSERT INTO t4 VALUES(0), (0), (0), (0), (8), (10), (0), + (20), (30), (31), (1024), (4096); + SELECT * FROM t4; + a +-1 +-2 +-3 +-4 +-8 +-10 +-11 +-20 +-30 +-31 +-1024 + 4096 +-CREATE TABLE t5(a MEDIUMINT AUTO_INCREMENT KEY) ENGINE = InnoDB; ++1024 ++31 ++30 ++20 ++11 ++10 ++8 ++4 ++3 ++2 ++1 ++CREATE TABLE t5(a MEDIUMINT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t5 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31), (1000000), (1000005); + SELECT * FROM t5; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 +-31 +-1000000 + 1000005 +-CREATE TABLE t6(a MEDIUMINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; ++1000000 ++31 ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 ++CREATE TABLE t6(a MEDIUMINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t6 VALUES(-5); + ERROR 22003: Out of range value for column 'a' at row 1 + INSERT INTO t6 VALUES(0), (0), (0), (0), (8), (10), (0), + (20), (30), (31), (1000000), (1000005); + SELECT * FROM t6; + a +-1 +-2 +-3 +-4 +-8 +-10 +-11 +-20 +-30 +-31 +-1000000 + 1000005 +-CREATE TABLE t7(a INT AUTO_INCREMENT KEY) ENGINE = InnoDB; ++1000000 ++31 ++30 ++20 ++11 ++10 ++8 ++4 ++3 ++2 ++1 ++CREATE TABLE t7(a INT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t7 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31), (100000000), (100000008); + SELECT * FROM t7; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 +-31 +-100000000 + 100000008 +-CREATE TABLE t8(a INT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; ++100000000 ++31 ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 ++CREATE TABLE t8(a INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t8 VALUES(-5); + ERROR 22003: Out of range value for column 'a' at row 1 + INSERT INTO t8 VALUES(0), (0), (0), (0), (8), (10), (0), + (20), (30), (31), (100000000), (100000008); + SELECT * FROM t8; + a +-1 +-2 +-3 +-4 +-8 +-10 +-11 +-20 +-30 +-31 +-100000000 + 100000008 +-CREATE TABLE t9(a BIGINT AUTO_INCREMENT KEY) ENGINE = InnoDB; ++100000000 ++31 ++30 ++20 ++11 ++10 ++8 ++4 ++3 ++2 ++1 ++CREATE TABLE t9(a BIGINT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t9 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31), (100000000000), (100000000006); + SELECT * FROM t9; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 +-31 +-100000000000 + 100000000006 +-CREATE TABLE t10(a BIGINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; ++100000000000 ++31 ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 ++CREATE TABLE t10(a BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t10 VALUES(-5); + ERROR 22003: Out of range value for column 'a' at row 1 + INSERT INTO t10 VALUES(0), (0), (0), (0), (8), (10), (0), + (20), (30), (31), (100000000000), (100000000006); + SELECT * FROM t10; + a +-1 +-2 +-3 +-4 +-8 +-10 +-11 +-20 +-30 +-31 +-100000000000 + 100000000006 +-CREATE TABLE t11(a FLOAT AUTO_INCREMENT KEY) ENGINE = InnoDB; ++100000000000 ++31 ++30 ++20 ++11 ++10 ++8 ++4 ++3 ++2 ++1 ++CREATE TABLE t11(a FLOAT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t11 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31); + SELECT * FROM t11; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 + 31 +-CREATE TABLE t12(a DOUBLE AUTO_INCREMENT KEY) ENGINE = InnoDB; ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 ++CREATE TABLE t12(a DOUBLE AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB; + INSERT INTO t12 VALUES(0), (0), (0), (0), (-1), (-10), (0), + (20), (30), (31); + SELECT * FROM t12; + a +--10 +--1 +-1 +-2 +-3 +-4 +-5 +-20 +-30 + 31 ++30 ++20 ++5 ++4 ++3 ++2 ++1 ++-1 ++-10 + # Scenario 1: Normal restart, to test if the counters are persisted + # Scenario 2: Delete some values, to test the counters should not be the + # one which is the largest in current table +@@ -242,14 +242,14 @@ + SELECT MAX(a) AS `Expect 100000000000` FROM t9; + Expect 100000000000 + 100000000000 +-CREATE TABLE t13(a INT AUTO_INCREMENT KEY) ENGINE = InnoDB, ++CREATE TABLE t13(a INT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE = InnoDB, + AUTO_INCREMENT = 1234; + # restart + SHOW CREATE TABLE t13; + Table Create Table + t13 CREATE TABLE `t13` ( + `a` int(11) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=1234 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t13 VALUES(0); + SELECT a AS `Expect 1234` FROM t13; +@@ -464,28 +464,28 @@ + INSERT INTO t1 VALUES(0), (0); + SELECT * FROM t1; + a +-1 + 2 ++1 + INSERT INTO t3 VALUES(0), (0); + SELECT * FROM t3; + a +-1 + 2 ++1 + INSERT INTO t5 VALUES(0), (0); + SELECT * FROM t5; + a +-1 + 2 ++1 + INSERT INTO t7 VALUES(0), (0); + SELECT * FROM t7; + a +-1 + 2 ++1 + INSERT INTO t9 VALUES(0), (0); + SELECT * FROM t9; + a +-1 + 2 ++1 + # Ensure that all changes before the server is killed are persisted. + set global innodb_flush_log_at_trx_commit=1; + TRUNCATE TABLE t1; +@@ -498,63 +498,63 @@ + INSERT INTO t19 VALUES(0), (0); + SELECT * FROM t19; + a +-1 + 2 ++1 + # restart + INSERT INTO t1 VALUES(0), (0); + SELECT * FROM t1; + a +-1 + 2 ++1 + INSERT INTO t3 VALUES(0), (0); + SELECT * FROM t3; + a +-1 + 2 ++1 + INSERT INTO t5 VALUES(0), (0); + SELECT * FROM t5; + a +-1 + 2 ++1 + INSERT INTO t7 VALUES(0), (0); + SELECT * FROM t7; + a +-1 + 2 ++1 + INSERT INTO t19 VALUES(0), (0); + SELECT * FROM t19; + a +-1 +-2 +-3 + 4 ++3 ++2 ++1 + DELETE FROM t19 WHERE a = 4; + RENAME TABLE t19 to t9; + INSERT INTO t9 VALUES(0), (0); + SELECT * FROM t9; + a +-1 +-2 +-3 +-5 + 6 ++5 ++3 ++2 ++1 + TRUNCATE TABLE t9; + INSERT INTO t9 VALUES(0), (0); + SELECT * FROM t9; + a +-1 + 2 ++1 + # Scenario 8: Test ALTER TABLE operations + INSERT INTO t3 VALUES(0), (0), (100), (200), (1000); + SELECT * FROM t3; + a +-1 +-2 +-3 +-4 +-100 +-200 + 1000 ++200 ++100 ++4 ++3 ++2 ++1 + DELETE FROM t3 WHERE a > 300; + SELECT MAX(a) AS `Expect 200` FROM t3; + Expect 200 +@@ -566,7 +566,7 @@ + Table Create Table + t3 CREATE TABLE `t3` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t3 VALUES(0); + SELECT MAX(a) AS `Expect 201` FROM t3; +@@ -579,7 +579,7 @@ + Table Create Table + t3 CREATE TABLE `t3` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=500 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t3 VALUES(0); + SELECT MAX(a) AS `Expect 500` FROM t3; +@@ -591,13 +591,13 @@ + Table Create Table + t3 CREATE TABLE `t3` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t3 VALUES(0), (0); + SELECT * FROM t3; + a +-100 + 101 ++100 + INSERT INTO t3 VALUES(150), (180); + UPDATE t3 SET a = 200 WHERE a = 150; + INSERT INTO t3 VALUES(220); +@@ -607,7 +607,7 @@ + Table Create Table + t3 CREATE TABLE `t3` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=221 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t3 VALUES(0); + SELECT MAX(a) AS `Expect 221` FROM t3; +@@ -619,7 +619,7 @@ + Table Create Table + t3 CREATE TABLE `t3` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=120 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # MDEV-6076: Test adding an AUTO_INCREMENT COLUMN + CREATE TABLE mdev6076a (b INT) ENGINE=InnoDB; +@@ -669,18 +669,18 @@ + INSERT INTO t_inplace SELECT * FROM t3; + SELECT * FROM t_inplace; + a +-100 +-101 +-120 +-121 +-122 +-200 + 210 ++200 ++122 ++121 ++120 ++101 ++100 + SHOW CREATE TABLE t_inplace; + Table Create Table + t_inplace CREATE TABLE `t_inplace` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=211 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # This will keep the autoinc counter + ALTER TABLE t_inplace AUTO_INCREMENT = 250, ALGORITHM = INPLACE; +@@ -689,7 +689,7 @@ + Table Create Table + t_inplace CREATE TABLE `t_inplace` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # This should keep the autoinc counter as well + ALTER TABLE t_inplace ADD COLUMN b INT, ALGORITHM = INPLACE; +@@ -699,16 +699,16 @@ + t_inplace CREATE TABLE `t_inplace` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, + `b` int(11) DEFAULT NULL, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + DELETE FROM t_inplace WHERE a > 150; + SELECT * FROM t_inplace; + a b +-100 NULL +-101 NULL +-120 NULL +-121 NULL + 122 NULL ++121 NULL ++120 NULL ++101 NULL ++100 NULL + # This should reset the autoinc counter to the one specified + # Since it's smaller than current one but bigger than existing + # biggest counter in the table +@@ -719,7 +719,7 @@ + t_inplace CREATE TABLE `t_inplace` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, + `b` int(11) DEFAULT NULL, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=180 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # This should reset the autoinc counter to the next value of + # current max counter in the table, since the specified value +@@ -730,7 +730,7 @@ + Table Create Table + t_inplace CREATE TABLE `t_inplace` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t_inplace VALUES(0), (0); + SELECT MAX(a) AS `Expect 124` FROM t_inplace; +@@ -757,18 +757,18 @@ + INSERT INTO t_copy SELECT * FROM t3; + SELECT * FROM t_copy; + a +-100 +-101 +-120 +-121 +-122 +-200 + 210 ++200 ++122 ++121 ++120 ++101 ++100 + SHOW CREATE TABLE t_copy; + Table Create Table + t_copy CREATE TABLE `t_copy` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=211 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # This will keep the autoinc counter + ALTER TABLE t_copy AUTO_INCREMENT = 250, ALGORITHM = COPY; +@@ -777,7 +777,7 @@ + Table Create Table + t_copy CREATE TABLE `t_copy` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # This should keep the autoinc counter as well + ALTER TABLE t_copy ADD COLUMN b INT, ALGORITHM = COPY; +@@ -787,16 +787,16 @@ + t_copy CREATE TABLE `t_copy` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, + `b` int(11) DEFAULT NULL, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + DELETE FROM t_copy WHERE a > 150; + SELECT * FROM t_copy; + a b +-100 NULL +-101 NULL +-120 NULL +-121 NULL + 122 NULL ++121 NULL ++120 NULL ++101 NULL ++100 NULL + # This should reset the autoinc counter to the one specified + # Since it's smaller than current one but bigger than existing + # biggest counter in the table +@@ -807,7 +807,7 @@ + t_copy CREATE TABLE `t_copy` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, + `b` int(11) DEFAULT NULL, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=180 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + # This should reset the autoinc counter to the next value of + # current max counter in the table, since the specified value +@@ -818,7 +818,7 @@ + Table Create Table + t_copy CREATE TABLE `t_copy` ( + `a` smallint(6) NOT NULL AUTO_INCREMENT, +- PRIMARY KEY (`a`) ++ PRIMARY KEY (`a` DESC) + ) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + INSERT INTO t_copy VALUES(0), (0); + SELECT MAX(a) AS `Expect 124` FROM t_copy; +@@ -842,7 +842,7 @@ + 126 + DROP TABLE t_copy, it_copy; + # Scenario 9: Test the sql_mode = NO_AUTO_VALUE_ON_ZERO +-CREATE TABLE t30 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, key(b)) ENGINE = InnoDB; ++CREATE TABLE t30 (a INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(a DESC), b INT, key(b)) ENGINE = InnoDB; + set SQL_MODE = NO_AUTO_VALUE_ON_ZERO; + INSERT INTO t30 VALUES(NULL, 1), (200, 2), (0, 3); + INSERT INTO t30(b) VALUES(4), (5), (6), (7); +@@ -869,20 +869,20 @@ + set global innodb_flush_log_at_trx_commit=1; + CREATE TABLE t31 (a INT) ENGINE = InnoDB; + INSERT INTO t31 VALUES(1), (2); +-ALTER TABLE t31 ADD b INT AUTO_INCREMENT PRIMARY KEY; ++ALTER TABLE t31 ADD b INT AUTO_INCREMENT, ADD PRIMARY KEY(b DESC); + INSERT INTO t31 VALUES(3, 0), (4, NULL), (5, NULL); + INSERT INTO t31 VALUES(6, 0); + ERROR 23000: Duplicate entry '0' for key 'PRIMARY' + SELECT * FROM t31; + a b +-3 0 +-1 1 +-2 2 +-4 3 + 5 4 ++4 3 ++2 2 ++1 1 ++3 0 + SET SQL_MODE = 0; + # Scenario 10: Rollback would not rollback the counter +-CREATE TABLE t32 (a BIGINT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; ++CREATE TABLE t32 (a BIGINT AUTO_INCREMENT, PRIMARY KEY(a DESC)) ENGINE=InnoDB; + INSERT INTO t32 VALUES(0), (0); + # Ensure that all changes before the server is killed are persisted. + set global innodb_flush_log_at_trx_commit=1; +@@ -897,7 +897,7 @@ + # increasing the counter + CREATE TABLE t33 ( + a BIGINT NOT NULL PRIMARY KEY, +-b BIGINT NOT NULL AUTO_INCREMENT, KEY(b)) ENGINE = InnoDB; ++b BIGINT NOT NULL AUTO_INCREMENT, INDEX(b DESC)) ENGINE = InnoDB; + INSERT INTO t33 VALUES(1, NULL); + INSERT INTO t33 VALUES(2, NULL); + INSERT INTO t33 VALUES(2, NULL); +@@ -920,13 +920,13 @@ + INSERT INTO t31(a) VALUES(6), (0); + SELECT * FROM t31; + a b +-3 0 +-1 1 +-2 2 +-4 3 +-5 4 +-6 5 + 0 6 ++6 5 ++5 4 ++4 3 ++2 2 ++1 1 ++3 0 + DROP TABLE t31; + set SQL_MODE = NO_AUTO_VALUE_ON_ZERO; + DELETE FROM t30 WHERE a = 0; +@@ -965,7 +965,7 @@ + DROP TABLE t33; + CREATE TABLE t33 ( + a BIGINT NOT NULL PRIMARY KEY, +-b BIGINT NOT NULL AUTO_INCREMENT, KEY(b)) ENGINE = InnoDB; ++b BIGINT NOT NULL AUTO_INCREMENT, INDEX(b DESC)) ENGINE = InnoDB; + ALTER TABLE t33 DISCARD TABLESPACE; + restore: t33 .ibd and .cfg files + ALTER TABLE t33 IMPORT TABLESPACE; +@@ -975,7 +975,7 @@ + 4 + SELECT * FROM t33; + a b +-10 1 +-2 2 + 3 4 ++2 2 ++10 1 + DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t30, t32, t33; diff --git a/mysql-test/suite/innodb/r/autoinc_persist.result b/mysql-test/suite/innodb/r/autoinc_persist.result index 93594db3f05..9e5cd4ad23e 100644 --- a/mysql-test/suite/innodb/r/autoinc_persist.result +++ b/mysql-test/suite/innodb/r/autoinc_persist.result @@ -242,7 +242,7 @@ DELETE FROM t9 WHERE a > 100000000000; SELECT MAX(a) AS `Expect 100000000000` FROM t9; Expect 100000000000 100000000000 -CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB, +CREATE TABLE t13(a INT AUTO_INCREMENT KEY) ENGINE = InnoDB, AUTO_INCREMENT = 1234; # restart SHOW CREATE TABLE t13; @@ -882,8 +882,7 @@ a b 5 4 SET SQL_MODE = 0; # Scenario 10: Rollback would not rollback the counter -CREATE TABLE t32 ( -a BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +CREATE TABLE t32 (a BIGINT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t32 VALUES(0), (0); # Ensure that all changes before the server is killed are persisted. set global innodb_flush_log_at_trx_commit=1; @@ -898,8 +897,7 @@ ROLLBACK; # increasing the counter CREATE TABLE t33 ( a BIGINT NOT NULL PRIMARY KEY, -b BIGINT NOT NULL AUTO_INCREMENT, -KEY(b)) ENGINE = InnoDB; +b BIGINT NOT NULL AUTO_INCREMENT, KEY(b)) ENGINE = InnoDB; INSERT INTO t33 VALUES(1, NULL); INSERT INTO t33 VALUES(2, NULL); INSERT INTO t33 VALUES(2, NULL); @@ -967,8 +965,7 @@ UNLOCK TABLES; DROP TABLE t33; CREATE TABLE t33 ( a BIGINT NOT NULL PRIMARY KEY, -b BIGINT NOT NULL AUTO_INCREMENT, -KEY(b)) ENGINE = InnoDB; +b BIGINT NOT NULL AUTO_INCREMENT, KEY(b)) ENGINE = InnoDB; ALTER TABLE t33 DISCARD TABLESPACE; restore: t33 .ibd and .cfg files ALTER TABLE t33 IMPORT TABLESPACE; diff --git a/mysql-test/suite/innodb/r/innodb-index,debug.rdiff b/mysql-test/suite/innodb/r/innodb-index,debug.rdiff deleted file mode 100644 index 2740e440cd5..00000000000 --- a/mysql-test/suite/innodb/r/innodb-index,debug.rdiff +++ /dev/null @@ -1,10 +0,0 @@ ---- innodb-index.result -+++ innodb-index.reject -@@ -1851,6 +1851,7 @@ - # - # MDEV-15325 Incomplete validation of missing tablespace during recovery - # -+SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus'; - CREATE TABLE t1(f1 INT PRIMARY KEY)ENGINE=InnoDB; - CREATE TABLE t2(f1 INT PRIMARY KEY)ENGINE=InnoDB; - # Kill the server diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 2292188c8ac..a76837b91a2 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -1947,3 +1947,51 @@ Warnings: Warning 1082 InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB Warning 1082 InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB DROP TABLE t; +# +# MDEV-27374 InnoDB table becomes corrupt after renaming DESC-indexed column +# +CREATE TABLE t1 (a VARCHAR(8), PRIMARY KEY(a DESC)) ENGINE=InnoDB; +ALTER TABLE t1 RENAME COLUMN a TO b, ALGORITHM=INPLACE; +SELECT TABLE_ID INTO @table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME="test/t1"; +SELECT INDEX_ID INTO @index_id FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE TABLE_ID = @table_id; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS WHERE INDEX_ID=@index_id; +NAME +b +DROP TABLE t1; +# +# MDEV-27432 ASC/DESC primary and unique keys cause index +# inconsistency between InnoDB and server +# +CREATE TABLE t1 (id INT NOT NULL, UNIQUE(id DESC)) ENGINE=InnoDB; +ALTER TABLE t1 ADD PRIMARY KEY (id), ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +# +# MDEV-27445 Index inconsistency and assertion failure after +# renaming virtual column with DESC key +# +CREATE TABLE t1(a INT, b INT AS (a), KEY(a, b DESC)) ENGINE=InnoDB; +ALTER TABLE t1 RENAME COLUMN IF EXISTS b TO v; +ALTER TABLE t1 FORCE; +DROP TABLE t1; +# +# MDEV-27592 DESC primary index fails to set wide format +# while renaming the column +# +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(8), b INT, KEY(a DESC,b)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'foo',10); +ALTER TABLE t1 RENAME COLUMN b TO c, ALGORITHM=INPLACE; +SELECT TABLE_ID INTO @table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME="test/t1"; +SELECT INDEX_ID INTO @index_id FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE TABLE_ID = @table_id ORDER BY INDEX_ID DESC LIMIT 1; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS WHERE INDEX_ID=@index_id; +NAME +a +c +DROP TABLE t1; +# End of 10.8 tests diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result index 848079d27b4..5d75692a89f 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result @@ -1,5 +1,5 @@ call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation."); -call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified."); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: .*"); call mtr.add_suppression("InnoDB: Ignoring tablespace .* because it could not be opened."); call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result index 667d31a0b69..cafa3f45eab 100644 --- a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result +++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result @@ -3,22 +3,20 @@ select @@innodb_buffer_pool_size; @@innodb_buffer_pool_size 8388608 set global innodb_buffer_pool_size = 10485760; -Warnings: -Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '10485760' select @@innodb_buffer_pool_size; @@innodb_buffer_pool_size -16777216 +10485760 create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; create or replace view view0 as select 1 union all select 1; set @`v_id` := 0; set @`v_val` := 0; replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17; -set global innodb_buffer_pool_size = 7340032; +set global innodb_buffer_pool_size = 64 * 1024 * 1024 + 512 * 1024; Warnings: -Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032' +Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '67633152' select @@innodb_buffer_pool_size; @@innodb_buffer_pool_size -8388608 +68157440 select count(val) from t1; count(val) 262144 diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result index 19b426009f2..a504bb4aa39 100644 --- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result +++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result @@ -154,9 +154,6 @@ os_data_fsyncs os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status os_pending_reads os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of reads pending os_pending_writes os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of writes pending os_log_bytes_written os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Bytes of log written (innodb_os_log_written) -os_log_fsyncs os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of fsync log writes (innodb_os_log_fsyncs) -os_log_pending_fsyncs os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pending fsync write (innodb_os_log_pending_fsyncs) -os_log_pending_writes os 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pending log file writes (innodb_os_log_pending_writes) trx_rw_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of read-write transactions committed trx_ro_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of read-only transactions committed trx_nl_ro_commits transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of non-locking auto-commit read-only transactions committed @@ -174,20 +171,16 @@ purge_undo_log_pages purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL purge_dml_delay_usec purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Microseconds DML to be delayed due to purge lagging purge_stop_count purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of times purge was stopped purge_resume_count purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of times purge was resumed -log_checkpoints recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of checkpoints +log_checkpoints recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of checkpoints log_lsn_last_flush recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value LSN of Last flush log_lsn_last_checkpoint recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value LSN at last checkpoint log_lsn_current recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current LSN value log_lsn_checkpoint_age recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current LSN value minus LSN at last checkpoint log_lsn_buf_pool_oldest recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value The oldest modified block LSN in the buffer pool log_max_modified_age_async recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Maximum LSN difference; when exceeded, start asynchronous preflush -log_pending_log_flushes recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Pending log flushes -log_pending_checkpoint_writes recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Pending checkpoints -log_num_log_io recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of log I/Os log_waits recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of log waits due to small log buffer (innodb_log_waits) log_write_requests recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of log write requests (innodb_log_write_requests) log_writes recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of log writes (innodb_log_writes) -log_padded recovery 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Bytes of log padded for log write ahead compress_pages_compressed compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages compressed compress_pages_decompressed compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of pages decompressed compression_pad_increments compression 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times padding is incremented to avoid compression failures diff --git a/mysql-test/suite/innodb/r/innodb_status_variables.result b/mysql-test/suite/innodb/r/innodb_status_variables.result index a729dd0a8d4..086e4e1d1e7 100644 --- a/mysql-test/suite/innodb/r/innodb_status_variables.result +++ b/mysql-test/suite/innodb/r/innodb_status_variables.result @@ -64,9 +64,6 @@ INNODB_MASTER_THREAD_ACTIVE_LOOPS INNODB_MASTER_THREAD_IDLE_LOOPS INNODB_MAX_TRX_ID INNODB_MEM_DICTIONARY -INNODB_OS_LOG_FSYNCS -INNODB_OS_LOG_PENDING_FSYNCS -INNODB_OS_LOG_PENDING_WRITES INNODB_OS_LOG_WRITTEN INNODB_PAGE_SIZE INNODB_PAGES_CREATED diff --git a/mysql-test/suite/innodb/r/instant_alter_import.result b/mysql-test/suite/innodb/r/instant_alter_import.result index 2b2cd8bf796..c65ffb3ad4c 100644 --- a/mysql-test/suite/innodb/r/instant_alter_import.result +++ b/mysql-test/suite/innodb/r/instant_alter_import.result @@ -1,6 +1,6 @@ call mtr.add_suppression("Operating system error number .* in a file operation."); call mtr.add_suppression("The error means the system cannot find the path specified."); -call mtr.add_suppression("File ./test/t1.ibd: 'delete' returned OS error"); +call mtr.add_suppression("File ./test/t1.ibd was not found"); set default_storage_engine=innodb; # # MDEV-18295 IMPORT TABLESPACE fails with instant-altered tables diff --git a/mysql-test/suite/innodb/r/log_corruption.result b/mysql-test/suite/innodb/r/log_corruption.result index bf92f77d30c..df58a90dcec 100644 --- a/mysql-test/suite/innodb/r/log_corruption.result +++ b/mysql-test/suite/innodb/r/log_corruption.result @@ -12,16 +12,15 @@ WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint/ in mysqld.1.err -FOUND 2 /Plugin 'InnoDB' registration as a STORAGE ENGINE failed/ in mysqld.1.err # redo log from before MariaDB 10.2.2, with corrupted log block # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err +FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint/ in mysqld.1.err # empty redo log from before MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); @@ -29,53 +28,55 @@ COUNT(*) 1 FOUND 1 /InnoDB: Upgrading redo log:/ in mysqld.1.err # Corrupted multi-file redo log from before MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 0 -FOUND 2 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err -# Empty multi-file redo log from before MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +FOUND 1 /InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and it appears corrupted/ in mysqld.1.err +# Empty multi-file redo log (wrong offset) from before MariaDB 10.2.2 +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) -1 -FOUND 2 /InnoDB: Upgrading redo log:/ in mysqld.1.err +0 +FOUND 3 /Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint\./ in mysqld.1.err # Multi-file redo log with size mismatch from after MariaDB 10.2.2 # Corrupted multi-file redo log from after MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 0 -FOUND 1 /InnoDB: Log file .*ib_logfile1 is of different size 1048576 bytes than other log files 2097152 bytes!/ in mysqld.1.err -FOUND 1 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with BogoDB 1\.2\.3\.4, and it appears corrupted\./ in mysqld.1.err -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +FOUND 3 /Upgrade after a crash is not supported. This redo log was created before MariaDB 10\.2\.2, and we did not find a valid checkpoint\./ in mysqld.1.err +FOUND 1 /InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\.2\.3\.4\./ in mysqld.1.err +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 0 -FOUND 2 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with BogoDB 1\.2\.3\.4, and it appears corrupted\./ in mysqld.1.err +FOUND 1 /InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files 1048576 bytes!/ in mysqld.1.err +FOUND 2 /InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\.2\.3\.4\./ in mysqld.1.err # Empty multi-file redo log from after MariaDB 10.2.2 -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) -1 -FOUND 3 /InnoDB: Upgrading redo log:/ in mysqld.1.err +0 +FOUND 3 /InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\.2\.3\.4\./ in mysqld.1.err # redo log from "after" MariaDB 10.2.2, but with invalid header checksum # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Invalid redo log header checksum/ in mysqld.1.err +FOUND 1 /InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files 4194304 bytes!/ in mysqld.1.err +FOUND 1 /InnoDB: Invalid log header checksum/ in mysqld.1.err # distant future redo log format, with valid header checksum # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -89,14 +90,14 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: No valid checkpoint found .corrupted redo log/ in mysqld.1.err +FOUND 1 /InnoDB: No valid checkpoint was found; the log was created with malicious intentions, or perhaps\./ in mysqld.1.err # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err +FOUND 2 /InnoDB: Invalid log header checksum/ in mysqld.1.err FOUND 1 /InnoDB: Upgrade after a crash is not supported\. The redo log was created with malicious intentions, or perhaps, and it appears corrupted\./ in mysqld.1.err # same, but with current-version header # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 @@ -104,7 +105,7 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 2 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122/ in mysqld.1.err +FOUND 3 /InnoDB: Invalid log header checksum/ in mysqld.1.err # --innodb-force-recovery=6 (skip the entire redo log) # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=6 SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -112,7 +113,7 @@ WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS InnoDB YES Supports transactions, row-level locking, foreign keys and encryption for tables YES YES YES -FOUND 1 /\[Note\] InnoDB: .* started; log sequence number 0/ in mysqld.1.err +FOUND 1 /\[Note\] InnoDB: log sequence number 0.*; transaction id 0/ in mysqld.1.err # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -141,8 +142,9 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 2454333373 found: 150151/ in mysqld.1.err -FOUND 3 /\[ERROR\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1, and it appears corrupted\./ in mysqld.1.err +NOT FOUND /InnoDB: Invalid log header checksum +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=\[ERROR\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1, and it appears corrupted\./ in mysqld.1.err # valid header, invalid checkpoint 1, valid checkpoint 2, invalid log record # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption SELECT * FROM INFORMATION_SCHEMA.ENGINES @@ -165,21 +167,29 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS FOUND 3 /\[ERROR\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1\./ in mysqld.1.err # Empty 10.3 redo log -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 1 -FOUND 1 /InnoDB: .* started; log sequence number 1213964; transaction id 0/ in mysqld.1.err +FOUND 1 /InnoDB: log sequence number 1213964\b.*; transaction id 0/ in mysqld.1.err # Empty 10.2 redo log -# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=2m +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m +SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +COUNT(*) +1 +FOUND 3 /InnoDB: Upgrading redo log:/ in mysqld.1.err +# Empty 10.5 redo log +# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 --innodb-log-file-size=4m SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); COUNT(*) 1 -FOUND 5 /InnoDB: Upgrading redo log:/ in mysqld.1.err +FOUND 4 /InnoDB: Upgrading redo log:/ in mysqld.1.err # Minimal MariaDB 10.1.21 encrypted redo log # restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_corruption --innodb-force-recovery=5 SELECT * FROM INFORMATION_SCHEMA.ENGINES diff --git a/mysql-test/suite/innodb/r/log_file.result b/mysql-test/suite/innodb/r/log_file.result index 642ba41d97f..734e9b07687 100644 --- a/mysql-test/suite/innodb/r/log_file.result +++ b/mysql-test/suite/innodb/r/log_file.result @@ -15,7 +15,7 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND 1 /File .path.to.non-existent.*ib_logfile101: 'create' returned OS error \d+/ in mysqld.1.err +FOUND 1 /Cannot create /path/to/non-existent/ib_logfile101/ in mysqld.1.err # Successfully let InnoDB create tablespaces # restart: --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_file --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_file --innodb-undo-directory=MYSQLTEST_VARDIR/tmp/log_file --innodb-undo-logs=20 --innodb-undo-tablespaces=3 --innodb-data-file-path=ibdata1:16M;ibdata2:10M:autoextend SELECT COUNT(*) `1` FROM INFORMATION_SCHEMA.ENGINES @@ -255,7 +255,6 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -InnoDB YES Supports transactions, row-level locking, foreign keys and encryption for tables YES YES YES bak_ib_logfile0 bak_ibdata1 bak_ibdata2 @@ -263,7 +262,6 @@ bak_undo001 bak_undo002 bak_undo003 ib_buffer_pool -ib_logfile0 ibdata1 ibdata2 undo001 @@ -289,7 +287,6 @@ WHERE engine='innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); 1 1 -NOT FOUND /Resizing redo log from 1\*\d+ to 3\*\d+ bytes; LSN=\d+/ in mysqld.1.err # restart # Cleanup bak_ib_logfile0 diff --git a/mysql-test/suite/innodb/r/log_file_name_debug.result b/mysql-test/suite/innodb/r/log_file_name_debug.result deleted file mode 100644 index cb2ee68fc98..00000000000 --- a/mysql-test/suite/innodb/r/log_file_name_debug.result +++ /dev/null @@ -1,18 +0,0 @@ -# -# Bug#19685095 DO NOT CARE ABOUT UNRESOLVED MLOG_FILE_NAME -# IF THERE ARE NO OPERATIONS TO APPLY -# -SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus'; -CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; -# Kill the server -# restart: --debug=d,innodb_log_abort_1 --innodb-log-file-size=4194304 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_3,ib_log --innodb-log-file-size=4194304 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /ib_log: FILE_CHECKPOINT.* written/ in mysqld.1.err -# restart -# restart -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/log_file_size.result b/mysql-test/suite/innodb/r/log_file_size.result index a0ab35d5c43..7b4935e1ab1 100644 --- a/mysql-test/suite/innodb/r/log_file_size.result +++ b/mysql-test/suite/innodb/r/log_file_size.result @@ -1,5 +1,5 @@ CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; -# restart: --innodb-log-file-size=2m +# restart: --innodb-log-file-size=4m CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK @@ -35,61 +35,32 @@ FOUND 1 /syntax error in innodb_log_group_home_dir/ in mysqld.1.err SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' FOUND 1 /InnoDB: Starting crash recovery from checkpoint LSN=.*/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_3 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' # restart: --innodb-read-only SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' FOUND 1 /InnoDB: innodb_read_only prevents crash recovery/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_4 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 5 /redo log from [0-9]+ to [0-9]+ bytes/ in mysqld.1.err # restart: --debug=d,innodb_log_abort_5 SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 6 /redo log from [0-9]+ to [0-9]+ bytes/ in mysqld.1.err +FOUND 1 /redo log from 5\.000MiB to [0-9.]*[KMGT]iB/ in mysqld.1.err # restart: --innodb-read-only SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' FOUND 2 /InnoDB: innodb_read_only prevents crash recovery/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_6 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 7 /redo log from [0-9]+ to [0-9]+ bytes/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_7 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -# restart: --innodb-read-only -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /InnoDB: Cannot create log file in read-only mode/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_8 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /InnoDB: Setting log file .*ib_logfile[0-9]+ size to/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_9 -SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /InnoDB: Setting log file .*ib_logfile[0-9]+ size to/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_9 +# restart SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /InnoDB: Log file .*ib_logfile0 size 7 is not a multiple of 512 bytes/ in mysqld.1.err -# restart: --debug=d,innodb_log_abort_9 -SELECT * FROM t1; -a -42 -123 -# restart: --debug=d,innodb_log_abort_10 +FOUND 1 /InnoDB: File .*ib_logfile0 is too small/ in mysqld.1.err +# restart SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' -FOUND 1 /InnoDB: Setting log file .*ib_logfile[0-9]+ size to/ in mysqld.1.err -FOUND 1 /InnoDB: Renaming log file .*ib_logfile101 to .*ib_logfile0/ in mysqld.1.err +FOUND 1 /InnoDB: Expecting only ib_logfile0/ in mysqld.1.err +# restart +FOUND 1 /InnoDB: File .*ib_logfile0 was not found/ in mysqld.1.err # restart SELECT * FROM t1; a 42 123 DROP TABLE t1; +FOUND 2 /InnoDB: Resizing redo log from 5\.000MiB to [0-9.]*[KMGT]iB; LSN=\d+\b/ in mysqld.1.err diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index caa4b33df6c..922c66a068f 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -120,9 +120,6 @@ os_data_fsyncs disabled os_pending_reads disabled os_pending_writes disabled os_log_bytes_written disabled -os_log_fsyncs disabled -os_log_pending_fsyncs disabled -os_log_pending_writes disabled trx_rw_commits disabled trx_ro_commits disabled trx_nl_ro_commits disabled @@ -147,13 +144,9 @@ log_lsn_current disabled log_lsn_checkpoint_age disabled log_lsn_buf_pool_oldest disabled log_max_modified_age_async disabled -log_pending_log_flushes disabled -log_pending_checkpoint_writes disabled -log_num_log_io disabled log_waits disabled log_write_requests disabled log_writes disabled -log_padded disabled compress_pages_compressed disabled compress_pages_decompressed disabled compression_pad_increments disabled @@ -282,9 +275,6 @@ os_data_fsyncs enabled os_pending_reads enabled os_pending_writes enabled os_log_bytes_written disabled -os_log_fsyncs disabled -os_log_pending_fsyncs enabled -os_log_pending_writes enabled set global innodb_monitor_enable=""; ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' set global innodb_monitor_enable="_"; diff --git a/mysql-test/suite/innodb/r/rename_table.result b/mysql-test/suite/innodb/r/rename_table.result index 8c3722c7940..0ed56005e21 100644 --- a/mysql-test/suite/innodb/r/rename_table.result +++ b/mysql-test/suite/innodb/r/rename_table.result @@ -21,7 +21,7 @@ path DROP DATABASE abc_def; # restart DROP DATABASE abc_def2; -call mtr.add_suppression("InnoDB: (Operating system error|The error means|Cannot rename file)"); +call mtr.add_suppression("InnoDB: (Operating system error|Error number \\d+ means|Cannot rename file)"); CREATE TABLE t1 (a INT) ENGINE=InnoDB; RENAME TABLE t1 TO non_existing_db.t1; ERROR HY000: Error on rename of './test/t1' to './non_existing_db/t1' (errno: 168 "Unknown (generic) error from engine") diff --git a/mysql-test/suite/innodb/r/truncate_missing.result b/mysql-test/suite/innodb/r/truncate_missing.result index b5348f65c5c..9e28d0fe556 100644 --- a/mysql-test/suite/innodb/r/truncate_missing.result +++ b/mysql-test/suite/innodb/r/truncate_missing.result @@ -1,5 +1,5 @@ call mtr.add_suppression("InnoDB: Operating system error number "); -call mtr.add_suppression("InnoDB: (The error means|If you are|Cannot open datafile) "); +call mtr.add_suppression("InnoDB: (Error number \\d+ means|If you are|Cannot open datafile) "); call mtr.add_suppression("InnoDB: Ignoring tablespace for test/t "); call mtr.add_suppression("InnoDB: Table test/t .* does not exist"); CREATE TABLE t (a SERIAL) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/t/alter_missing_tablespace.test b/mysql-test/suite/innodb/t/alter_missing_tablespace.test index bf7111509bd..5c7f63eb813 100644 --- a/mysql-test/suite/innodb/t/alter_missing_tablespace.test +++ b/mysql-test/suite/innodb/t/alter_missing_tablespace.test @@ -9,7 +9,7 @@ --disable_query_log call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: "); call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation"); -call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); call mtr.add_suppression("InnoDB: Ignoring tablespace for test/\(t\|x@002e@002ed\) because it could not be opened"); call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing"); call mtr.add_suppression("Could not find a valid tablespace file for"); diff --git a/mysql-test/suite/innodb/t/autoinc_persist.combinations b/mysql-test/suite/innodb/t/autoinc_persist.combinations new file mode 100644 index 00000000000..4ae2948e523 --- /dev/null +++ b/mysql-test/suite/innodb/t/autoinc_persist.combinations @@ -0,0 +1,2 @@ +[asc] +[desc] diff --git a/mysql-test/suite/innodb/t/autoinc_persist.test b/mysql-test/suite/innodb/t/autoinc_persist.test index 6e094b40e02..c6135b5580c 100644 --- a/mysql-test/suite/innodb/t/autoinc_persist.test +++ b/mysql-test/suite/innodb/t/autoinc_persist.test @@ -2,6 +2,19 @@ # Restarting is not supported when testing the embedded server. --source include/not_embedded.inc +if ($MTR_COMBINATION_DESC) { + let $AUTO_INCREMENT_KEY_a= AUTO_INCREMENT, PRIMARY KEY(a DESC); + let $AUTO_INCREMENT_KEY_b= AUTO_INCREMENT, INDEX(b DESC); + let $AUTO_INCREMENT_PRIMARY_KEY_a= AUTO_INCREMENT, PRIMARY KEY(a DESC); + let $AUTO_INCREMENT_PRIMARY_KEY_b= AUTO_INCREMENT, ADD PRIMARY KEY(b DESC); +} +if (!$MTR_COMBINATION_DESC) { + let $AUTO_INCREMENT_KEY_a= AUTO_INCREMENT KEY; + let $AUTO_INCREMENT_KEY_b= AUTO_INCREMENT, KEY(b); + let $AUTO_INCREMENT_PRIMARY_KEY_a= AUTO_INCREMENT PRIMARY KEY; + let $AUTO_INCREMENT_PRIMARY_KEY_b= AUTO_INCREMENT PRIMARY KEY; +} + --echo # --echo # MDEV-6076 Persistent AUTO_INCREMENT for InnoDB --echo # @@ -20,72 +33,72 @@ SET SQL_MODE='STRICT_ALL_TABLES'; -CREATE TABLE t1(a TINYINT AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t1(a TINYINT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t1 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31); SELECT * FROM t1; -CREATE TABLE t2(a TINYINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t2(a TINYINT UNSIGNED $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; --error ER_WARN_DATA_OUT_OF_RANGE INSERT INTO t2 VALUES(-5); INSERT INTO t2 VALUES(0), (0), (0), (0), (8), (10), (0), (20), (30), (31); SELECT * FROM t2; -CREATE TABLE t3(a SMALLINT AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t3(a SMALLINT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t3 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31), (1024), (4096); SELECT * FROM t3; -CREATE TABLE t4(a SMALLINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t4(a SMALLINT UNSIGNED $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; --error ER_WARN_DATA_OUT_OF_RANGE INSERT INTO t4 VALUES(-5); INSERT INTO t4 VALUES(0), (0), (0), (0), (8), (10), (0), (20), (30), (31), (1024), (4096); SELECT * FROM t4; -CREATE TABLE t5(a MEDIUMINT AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t5(a MEDIUMINT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t5 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31), (1000000), (1000005); SELECT * FROM t5; -CREATE TABLE t6(a MEDIUMINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t6(a MEDIUMINT UNSIGNED $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; --error ER_WARN_DATA_OUT_OF_RANGE INSERT INTO t6 VALUES(-5); INSERT INTO t6 VALUES(0), (0), (0), (0), (8), (10), (0), (20), (30), (31), (1000000), (1000005); SELECT * FROM t6; -CREATE TABLE t7(a INT AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t7(a INT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t7 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31), (100000000), (100000008); SELECT * FROM t7; -CREATE TABLE t8(a INT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t8(a INT UNSIGNED $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; --error ER_WARN_DATA_OUT_OF_RANGE INSERT INTO t8 VALUES(-5); INSERT INTO t8 VALUES(0), (0), (0), (0), (8), (10), (0), (20), (30), (31), (100000000), (100000008); SELECT * FROM t8; -CREATE TABLE t9(a BIGINT AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t9(a BIGINT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t9 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31), (100000000000), (100000000006); SELECT * FROM t9; -CREATE TABLE t10(a BIGINT UNSIGNED AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t10(a BIGINT UNSIGNED $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; --error ER_WARN_DATA_OUT_OF_RANGE INSERT INTO t10 VALUES(-5); INSERT INTO t10 VALUES(0), (0), (0), (0), (8), (10), (0), (20), (30), (31), (100000000000), (100000000006); SELECT * FROM t10; -CREATE TABLE t11(a FLOAT AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t11(a FLOAT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t11 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31); SELECT * FROM t11; -CREATE TABLE t12(a DOUBLE AUTO_INCREMENT KEY) ENGINE = InnoDB; +eval CREATE TABLE t12(a DOUBLE $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB; INSERT INTO t12 VALUES(0), (0), (0), (0), (-1), (-10), (0), (20), (30), (31); SELECT * FROM t12; @@ -105,7 +118,7 @@ SELECT MAX(a) AS `Expect 100000000` FROM t7; DELETE FROM t9 WHERE a > 100000000000; SELECT MAX(a) AS `Expect 100000000000` FROM t9; -CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB, +eval CREATE TABLE t13(a INT $AUTO_INCREMENT_KEY_a) ENGINE = InnoDB, AUTO_INCREMENT = 1234; --source include/restart_mysqld.inc @@ -439,7 +452,7 @@ INSERT INTO t3 VALUES(0), (0), (200), (210); --echo # Scenario 9: Test the sql_mode = NO_AUTO_VALUE_ON_ZERO -CREATE TABLE t30 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, key(b)) ENGINE = InnoDB; +eval CREATE TABLE t30 (a INT NOT NULL $AUTO_INCREMENT_PRIMARY_KEY_a, b INT, key(b)) ENGINE = InnoDB; set SQL_MODE = NO_AUTO_VALUE_ON_ZERO; @@ -454,7 +467,7 @@ set global innodb_flush_log_at_trx_commit=1; CREATE TABLE t31 (a INT) ENGINE = InnoDB; INSERT INTO t31 VALUES(1), (2); -ALTER TABLE t31 ADD b INT AUTO_INCREMENT PRIMARY KEY; +eval ALTER TABLE t31 ADD b INT $AUTO_INCREMENT_PRIMARY_KEY_b; INSERT INTO t31 VALUES(3, 0), (4, NULL), (5, NULL); --error ER_DUP_ENTRY INSERT INTO t31 VALUES(6, 0); @@ -463,8 +476,7 @@ SELECT * FROM t31; SET SQL_MODE = 0; --echo # Scenario 10: Rollback would not rollback the counter -CREATE TABLE t32 ( -a BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +eval CREATE TABLE t32 (a BIGINT $AUTO_INCREMENT_PRIMARY_KEY_a) ENGINE=InnoDB; INSERT INTO t32 VALUES(0), (0); @@ -480,10 +492,9 @@ ROLLBACK; --echo # Scenario 11: Test duplicate primary key/secondary key will not stop --echo # increasing the counter -CREATE TABLE t33 ( +eval CREATE TABLE t33 ( a BIGINT NOT NULL PRIMARY KEY, -b BIGINT NOT NULL AUTO_INCREMENT, -KEY(b)) ENGINE = InnoDB; +b BIGINT NOT NULL $AUTO_INCREMENT_KEY_b) ENGINE = InnoDB; INSERT INTO t33 VALUES(1, NULL); INSERT INTO t33 VALUES(2, NULL); @@ -539,10 +550,9 @@ ib_backup_tablespaces("test", "t33"); EOF UNLOCK TABLES; DROP TABLE t33; -CREATE TABLE t33 ( +eval CREATE TABLE t33 ( a BIGINT NOT NULL PRIMARY KEY, -b BIGINT NOT NULL AUTO_INCREMENT, -KEY(b)) ENGINE = InnoDB; +b BIGINT NOT NULL $AUTO_INCREMENT_KEY_b) ENGINE = InnoDB; ALTER TABLE t33 DISCARD TABLESPACE; perl; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; diff --git a/mysql-test/suite/innodb/t/innodb-index-online.opt b/mysql-test/suite/innodb/t/innodb-index-online.opt index ff20edbe2f7..1837463f07a 100644 --- a/mysql-test/suite/innodb/t/innodb-index-online.opt +++ b/mysql-test/suite/innodb/t/innodb-index-online.opt @@ -1,6 +1,5 @@ --loose-innodb-sort-buffer-size=64k --loose-innodb-online-alter-log-max-size=128k --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.test b/mysql-test/suite/innodb/t/innodb-index.test index c7aa6250da5..c80e3e6c066 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -1,7 +1,6 @@ -- source include/have_innodb.inc # Embedded server tests do not support restarting. -- source include/not_embedded.inc --- source include/maybe_debug.inc let $MYSQLD_DATADIR= `select @@datadir`; @@ -1126,9 +1125,6 @@ drop table t1; --echo # --source include/no_checkpoint_start.inc -if ($have_debug) { -SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus'; -} CREATE TABLE t1(f1 INT PRIMARY KEY)ENGINE=InnoDB; CREATE TABLE t2(f1 INT PRIMARY KEY)ENGINE=InnoDB; @@ -1156,13 +1152,6 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); --move_file $MYSQLD_DATADIR/test/t0.ibd $MYSQLD_DATADIR/test/t1.ibd --source include/start_mysqld.inc -if ($have_debug) { -# Initiate shutdown in order to issue a redo log checkpoint and to discard -# the redo log record that was emitted due to '+d,fil_names_write_bogus'. ---let $restart_noprint=2 ---source include/restart_mysqld.inc ---let $restart_noprint=0 -} SELECT * FROM t1; SELECT * FROM t2; @@ -1193,6 +1182,48 @@ SHOW CREATE TABLE t; --disable_prepare_warnings DROP TABLE t; +--echo # +--echo # MDEV-27374 InnoDB table becomes corrupt after renaming DESC-indexed column +--echo # +CREATE TABLE t1 (a VARCHAR(8), PRIMARY KEY(a DESC)) ENGINE=InnoDB; +ALTER TABLE t1 RENAME COLUMN a TO b, ALGORITHM=INPLACE; +SELECT TABLE_ID INTO @table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME="test/t1"; +SELECT INDEX_ID INTO @index_id FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE TABLE_ID = @table_id; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS WHERE INDEX_ID=@index_id; +DROP TABLE t1; + +--echo # +--echo # MDEV-27432 ASC/DESC primary and unique keys cause index +--echo # inconsistency between InnoDB and server +--echo # +CREATE TABLE t1 (id INT NOT NULL, UNIQUE(id DESC)) ENGINE=InnoDB; +ALTER TABLE t1 ADD PRIMARY KEY (id), ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-27445 Index inconsistency and assertion failure after +--echo # renaming virtual column with DESC key +--echo # +CREATE TABLE t1(a INT, b INT AS (a), KEY(a, b DESC)) ENGINE=InnoDB; +ALTER TABLE t1 RENAME COLUMN IF EXISTS b TO v; +ALTER TABLE t1 FORCE; +DROP TABLE t1; + +--echo # +--echo # MDEV-27592 DESC primary index fails to set wide format +--echo # while renaming the column +--echo # +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(8), b INT, KEY(a DESC,b)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'foo',10); +ALTER TABLE t1 RENAME COLUMN b TO c, ALGORITHM=INPLACE; +SELECT TABLE_ID INTO @table_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME="test/t1"; +SELECT INDEX_ID INTO @index_id FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE TABLE_ID = @table_id ORDER BY INDEX_ID DESC LIMIT 1; +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS WHERE INDEX_ID=@index_id; +DROP TABLE t1; + +--echo # End of 10.8 tests + --disable_query_log call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*t[12].ibd."); diff --git a/mysql-test/suite/innodb/t/innodb-table-online-master.opt b/mysql-test/suite/innodb/t/innodb-table-online-master.opt index 92eea2b0d2e..1eafb5ac188 100644 --- a/mysql-test/suite/innodb/t/innodb-table-online-master.opt +++ b/mysql-test/suite/innodb/t/innodb-table-online-master.opt @@ -1 +1 @@ ---innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=512k --innodb-buffer-pool-size=5M --innodb-log-buffer-size=256k +--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=512k --innodb-buffer-pool-size=5M diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test index 76c7346b521..efa2b1ea403 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -19,7 +19,7 @@ let $restart_noprint=2; call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation."); -call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified."); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: .*"); call mtr.add_suppression("InnoDB: Ignoring tablespace .* because it could not be opened."); call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); diff --git a/mysql-test/suite/innodb/t/innodb_28867993.test b/mysql-test/suite/innodb/t/innodb_28867993.test index 61e9578df7b..4777a9ac77f 100644 --- a/mysql-test/suite/innodb/t/innodb_28867993.test +++ b/mysql-test/suite/innodb/t/innodb_28867993.test @@ -6,6 +6,10 @@ source include/have_innodb.inc; create table t1 (a int) engine=innodb; insert t1 values (1),(2); create database ib_logfile2; +--disable_query_log +call mtr.add_suppression("InnoDB: Operating system error number "); +call mtr.add_suppression("InnoDB: Error number .* means "); +--enable_query_log source include/restart_mysqld.inc; select * from t1; drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test index 932829470e3..051f38a572e 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test @@ -7,7 +7,7 @@ let $wait_timeout = 180; let $wait_condition = - SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool' FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; @@ -45,7 +45,7 @@ SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; --enable_query_log # Shrink buffer pool -set global innodb_buffer_pool_size = 7340032; +set global innodb_buffer_pool_size = 64 * 1024 * 1024 + 512 * 1024; --source include/wait_condition.inc select @@innodb_buffer_pool_size; diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test index 1cdf4a318d0..c49ae451638 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test @@ -15,7 +15,7 @@ SET GLOBAL innodb_buffer_pool_size=8388608; let $wait_timeout = 60; let $wait_condition = - SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool' FROM information_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_RESIZE_STATUS'; --source include/wait_condition.inc diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test index d11443ca1b2..78db6bf0d5a 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test @@ -8,7 +8,7 @@ let $wait_timeout = 180; let $wait_condition = - SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool' FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; diff --git a/mysql-test/suite/innodb/t/instant_alter_import.test b/mysql-test/suite/innodb/t/instant_alter_import.test index 87a36186150..3a811def170 100644 --- a/mysql-test/suite/innodb/t/instant_alter_import.test +++ b/mysql-test/suite/innodb/t/instant_alter_import.test @@ -4,7 +4,7 @@ call mtr.add_suppression("Operating system error number .* in a file operation."); call mtr.add_suppression("The error means the system cannot find the path specified."); -call mtr.add_suppression("File ./test/t1.ibd: 'delete' returned OS error"); +call mtr.add_suppression("File ./test/t1.ibd was not found"); --disable_query_log call mtr.add_suppression("Table `test`.`t2` contains unrecognizable instant ALTER metadata"); diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test index 4e9ea9fa698..7d351bf565c 100644 --- a/mysql-test/suite/innodb/t/log_corruption.test +++ b/mysql-test/suite/innodb/t/log_corruption.test @@ -7,8 +7,8 @@ call mtr.add_suppression("InnoDB: Plugin initialization aborted"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); call mtr.add_suppression("InnoDB: Unsupported redo log format"); -call mtr.add_suppression("InnoDB: No valid checkpoint found"); -call mtr.add_suppression("InnoDB: Invalid (log block|redo log header) checksum"); +call mtr.add_suppression("InnoDB: No valid checkpoint was found"); +call mtr.add_suppression("InnoDB: Invalid log header checksum"); call mtr.add_suppression("InnoDB: Missing MLOG_CHECKPOINT"); call mtr.add_suppression("InnoDB: MLOG_FILE_NAME incorrect"); call mtr.add_suppression("InnoDB: ############### CORRUPT LOG RECORD FOUND"); @@ -16,8 +16,7 @@ call mtr.add_suppression("InnoDB: Log scan aborted at LSN"); call mtr.add_suppression("InnoDB: Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT for tablespace 42\\r?$"); call mtr.add_suppression("InnoDB: Obtaining redo log encryption key version 1 failed"); call mtr.add_suppression("InnoDB: Decrypting checkpoint failed"); -call mtr.add_suppression("InnoDB: Are you sure you are using the right ib_logfile0 to start up the database\\? The checkpoint is 1213964,"); -call mtr.add_suppression("InnoDB: Log file .*ib_logfile1 is of different size 1048576 bytes than other log files 2097152 bytes!"); +call mtr.add_suppression("InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files (1048576|4194304) bytes!"); --enable_query_log let bugdir= $MYSQLTEST_VARDIR/tmp/log_corruption; @@ -134,8 +133,6 @@ eval $check_no_innodb; let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\\.2\\.2, and we did not find a valid checkpoint; --source include/search_pattern_in_file.inc -let SEARCH_PATTERN=Plugin 'InnoDB' registration as a STORAGE ENGINE failed; ---source include/search_pattern_in_file.inc --echo # redo log from before MariaDB 10.2.2, with corrupted log block --remove_file $bugdir/ib_logfile0 @@ -154,7 +151,6 @@ EOF --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\\.2\\.2, and it appears corrupted; --source include/search_pattern_in_file.inc --echo # empty redo log from before MariaDB 10.2.2 @@ -165,7 +161,7 @@ die unless seek(OUT, 0x800, 0); print OUT pack("NnnNx[496]N", 0x80000944, 12, 12, 0, 0xb2a); close OUT or die; EOF ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' @@ -195,7 +191,7 @@ print OUT chr(0) x 2048; close OUT or die; EOF ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' @@ -204,7 +200,7 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported. This redo log was created before MariaDB 10\\.2\\.2, and it appears corrupted; --source include/search_pattern_in_file.inc ---echo # Empty multi-file redo log from before MariaDB 10.2.2 +--echo # Empty multi-file redo log (wrong offset) from before MariaDB 10.2.2 perl; die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile1"; binmode OUT; @@ -214,13 +210,13 @@ print OUT chr(0) x 1536; close OUT or die; EOF ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN= InnoDB: Upgrading redo log: +--let SEARCH_PATTERN= Upgrade after a crash is not supported. This redo log was created before MariaDB 10\\.2\\.2, and we did not find a valid checkpoint\\. --source include/search_pattern_in_file.inc --echo # Multi-file redo log with size mismatch from after MariaDB 10.2.2 @@ -245,15 +241,14 @@ close OUT or die; EOF --echo # Corrupted multi-file redo log from after MariaDB 10.2.2 ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN=InnoDB: Log file .*ib_logfile1 is of different size 1048576 bytes than other log files 2097152 bytes! --source include/search_pattern_in_file.inc ---let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported\\. The redo log was created with BogoDB 1\\.2\\.3\\.4, and it appears corrupted\\. +--let SEARCH_PATTERN=InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\\.2\\.3\\.4\\. --source include/search_pattern_in_file.inc perl; @@ -264,13 +259,15 @@ print OUT chr(0); close OUT or die; EOF ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported\\. The redo log was created with BogoDB 1\\.2\\.3\\.4, and it appears corrupted\\. +--let SEARCH_PATTERN=InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files 1048576 bytes! +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=InnoDB: No valid checkpoint was found; the log was created with BogoDB 1\\.2\\.3\\.4\\. --source include/search_pattern_in_file.inc --echo # Empty multi-file redo log from after MariaDB 10.2.2 @@ -286,13 +283,12 @@ print OUT $_, pack("N", mycrc32($_, 0, $polynomial)); close OUT or die; EOF ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN= InnoDB: Upgrading redo log: --source include/search_pattern_in_file.inc --let $restart_parameters= $dirs @@ -309,7 +305,9 @@ EOF --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Invalid redo log header checksum; +--let SEARCH_PATTERN=InnoDB: Log file .*ib_logfile1 is of different size 2097152 bytes than other log files 4194304 bytes! +--source include/search_pattern_in_file.inc +let SEARCH_PATTERN=InnoDB: Invalid log header checksum; --source include/search_pattern_in_file.inc --echo # distant future redo log format, with valid header checksum @@ -345,7 +343,7 @@ EOF --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: No valid checkpoint found .corrupted redo log; +--let SEARCH_PATTERN=InnoDB: No valid checkpoint was found; the log was created with malicious intentions, or perhaps\\. --source include/search_pattern_in_file.inc --echo # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum @@ -356,6 +354,9 @@ die unless seek(OUT, 0x210, 0); print OUT pack("NNx[264]", 0, 0x80c); print OUT pack("NNx[212]N", 0x590dbaac, 0xfe922582, 0xc72d49c4); close OUT or die; +die unless open OUT, ">", "$ENV{bugdir}/ib_logfile1"; +print OUT pack("x[4194304]"); +close OUT or die; EOF # Anything below innodb_force_recovery=6 must find a valid redo log. # Missing tablespace files are tolerated already with innodb_force_recovery=1. @@ -363,7 +364,7 @@ EOF --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122; +let SEARCH_PATTERN=InnoDB: Invalid log header checksum; --source include/search_pattern_in_file.inc let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported\. The redo log was created with malicious intentions, or perhaps, and it appears corrupted\.; --source include/search_pattern_in_file.inc @@ -380,14 +381,14 @@ EOF eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 3362026715 found: 144444122; +let SEARCH_PATTERN=InnoDB: Invalid log header checksum; --source include/search_pattern_in_file.inc --echo # --innodb-force-recovery=6 (skip the entire redo log) --let $restart_parameters= $dirs --innodb-force-recovery=6 --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN=\\[Note\\] InnoDB: .* started; log sequence number 0 +--let SEARCH_PATTERN=\\[Note\\] InnoDB: log sequence number 0.*; transaction id 0 --source include/search_pattern_in_file.inc --echo # valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number @@ -464,7 +465,7 @@ EOF --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=InnoDB: Invalid log block checksum. block: 2372 checkpoint no: 1 expected: 2454333373 found: 150151; +let SEARCH_PATTERN=InnoDB: Invalid log header checksum --source include/search_pattern_in_file.inc let SEARCH_PATTERN=\\[ERROR\\] InnoDB: Upgrade after a crash is not supported\. The redo log was created with MariaDB 10\.3\.1, and it appears corrupted\.; --source include/search_pattern_in_file.inc @@ -538,13 +539,13 @@ print OUT pack("NnnNx[496]N", 0x80000944, 12, 12, 1, 0x46c8a2a2); close OUT or die; EOF ---let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=2m +--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --source include/start_mysqld.inc SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN= InnoDB: .* started; log sequence number 1213964; transaction id 0 +--let SEARCH_PATTERN= InnoDB: log sequence number 1213964\\b.*; transaction id 0 --source include/search_pattern_in_file.inc --echo # Empty 10.2 redo log @@ -577,6 +578,33 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); --let SEARCH_PATTERN= InnoDB: Upgrading redo log: --source include/search_pattern_in_file.inc +--echo # Empty 10.5 redo log +perl; +die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; +binmode OUT; +# header block +print OUT pack("Nx[5]nx[5]", 0x50485953, 0x1286); +print OUT "ibbackup was here!!!1!"; +print OUT pack("x[470]N", 0x677700cf); +# invalid (all-zero) checkpoint page 1 and an empty log page +print OUT chr(0) x 1024; +# valid checkpoint block 2 +print OUT pack("x[12]NNNx[264]", 0x12860c, 0, 0x80c); +# pointer to the FILE_CHECKPOINT record, and checkpoint page checksum +print OUT pack("H*x[204]NNN", "590DBAACFE922582", 0x128612, 0, 0x101741b); +# log page +print OUT pack("NnnNx[496]N", 0x80000944, 12, 12, 1, 0x46c8a2a2); +close OUT or die; +EOF + +--source include/start_mysqld.inc +SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES +WHERE engine = 'innodb' +AND support IN ('YES', 'DEFAULT', 'ENABLED'); +--source include/shutdown_mysqld.inc +--let SEARCH_PATTERN= InnoDB: Upgrading redo log: +--source include/search_pattern_in_file.inc + --echo # Minimal MariaDB 10.1.21 encrypted redo log perl; die unless open OUT, "+<", "$ENV{bugdir}/ib_logfile0"; diff --git a/mysql-test/suite/innodb/t/log_file.test b/mysql-test/suite/innodb/t/log_file.test index e167bc6fb57..0f26622e2b6 100644 --- a/mysql-test/suite/innodb/t/log_file.test +++ b/mysql-test/suite/innodb/t/log_file.test @@ -11,7 +11,7 @@ call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); call mtr.add_suppression("InnoDB: Operating system error number \d+ in a file operation"); call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); -call mtr.add_suppression("InnoDB: File .path.to.non-existent.ib_logfile101: 'create' returned OS error \d+"); +call mtr.add_suppression("InnoDB: File /path/to/non-existent/ib_logfile101 was not found"); call mtr.add_suppression("InnoDB: Cannot create .path.to.non-existent.ib_logfile101"); call mtr.add_suppression("InnoDB: The data file '.*ibdata1' was not found but one of the other data files '.*ibdata2' exists"); call mtr.add_suppression("InnoDB: Tablespace size stored in header is \d+ pages, but the sum of data file sizes is \d+ pages"); @@ -61,7 +61,7 @@ let SEARCH_PATTERN=\[ERROR\] InnoDB: Could not create undo tablespace '.*undo002 --source include/start_mysqld.inc eval $check_no_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=File .path.to.non-existent.*ib_logfile101: 'create' returned OS error \d+; +let SEARCH_PATTERN=Cannot create /path/to/non-existent/ib_logfile101; --source include/search_pattern_in_file.inc --list_files $bugdir @@ -208,8 +208,6 @@ eval $check_no_innodb; --source include/start_mysqld.inc eval $check_yes_innodb; --source include/shutdown_mysqld.inc ---let SEARCH_PATTERN=Resizing redo log from 1\*\d+ to 3\*\d+ bytes; LSN=\d+ ---source include/search_pattern_in_file.inc --let $restart_parameters= --source include/start_mysqld.inc diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test index 895e945f4e3..b0935c90ca3 100644 --- a/mysql-test/suite/innodb/t/log_file_name.test +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -146,7 +146,7 @@ DROP TABLE t0; --disable_query_log # The following are for the orphan file t0.ibd or for the directory t2.ibd: call mtr.add_suppression("InnoDB: Operating system error number [0-9]* in a file operation"); -call mtr.add_suppression("InnoDB: Error number [0-9]* means '(File exists|Is a directory)'"); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); call mtr.add_suppression("InnoDB: Cannot create file '.*t0.ibd'"); call mtr.add_suppression("InnoDB: The file '.*t0\.ibd' already exists"); call mtr.add_suppression("InnoDB: Cannot open datafile for read-write: '.*t2\.ibd'"); diff --git a/mysql-test/suite/innodb/t/log_file_name_debug.test b/mysql-test/suite/innodb/t/log_file_name_debug.test deleted file mode 100644 index 239606b121b..00000000000 --- a/mysql-test/suite/innodb/t/log_file_name_debug.test +++ /dev/null @@ -1,51 +0,0 @@ ---source include/have_innodb.inc -# Embedded server does not support restarting ---source include/not_embedded.inc ---source include/have_debug.inc ---source include/no_valgrind_without_big.inc - ---echo # ---echo # Bug#19685095 DO NOT CARE ABOUT UNRESOLVED MLOG_FILE_NAME ---echo # IF THERE ARE NO OPERATIONS TO APPLY ---echo # - -SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus'; ---disable_query_log -call mtr.add_suppression("InnoDB: Plugin initialization aborted"); -call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); -call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); -FLUSH TABLES; ---enable_query_log - ---let $change=`SELECT if(@@innodb_log_file_size = 4194304, 8388608, 4194304)` ---let $resize= --innodb-log-file-size=$change - ---source include/no_checkpoint_start.inc - -CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; - ---let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; ---source include/no_checkpoint_end.inc - ---let $restart_parameters= --debug=d,innodb_log_abort_1 $resize ---source include/start_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - ---let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err ---let SEARCH_PATTERN = InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either ---source include/search_pattern_in_file.inc - ---let $restart_parameters= --debug=d,innodb_log_abort_3,ib_log $resize ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; ---let SEARCH_PATTERN= ib_log: FILE_CHECKPOINT.* written ---source include/search_pattern_in_file.inc - ---let $restart_parameters= ---source include/restart_mysqld.inc -# Initiate shutdown in order to issue a redo log checkpoint and to discard -# the redo log record that was emitted due to '+d,fil_names_write_bogus'. ---source include/restart_mysqld.inc -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/log_file_size.test b/mysql-test/suite/innodb/t/log_file_size.test index fc6cb1ef83e..261b024fa41 100644 --- a/mysql-test/suite/innodb/t/log_file_size.test +++ b/mysql-test/suite/innodb/t/log_file_size.test @@ -7,36 +7,55 @@ # This test is slow on buildbot. --source include/big_test.inc -if (`SELECT @@innodb_log_file_size = 1048576`) { - --skip Test requires innodb_log_file_size>1M. -} - --disable_query_log -call mtr.add_suppression("InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata file do not match the log sequence number [0-9]+ in the ib_logfile"); call mtr.add_suppression("syntax error in innodb_log_group_home_dir"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); call mtr.add_suppression("InnoDB: Plugin initialization aborted"); call mtr.add_suppression("InnoDB: innodb_read_only prevents crash recovery"); -call mtr.add_suppression("InnoDB: Are you sure you are using the right ib_logfile"); -call mtr.add_suppression("InnoDB: Cannot (create|resize) log file in read-only mode"); -call mtr.add_suppression("InnoDB: Can't initiate database recovery, running in read-only-mode"); -call mtr.add_suppression("InnoDB: Log file .*ib_logfile0.* size"); -call mtr.add_suppression("InnoDB: Unable to open .*ib_logfile0. to check native AIO read support"); +call mtr.add_suppression("InnoDB: Log file .*ib_logfile1.* size"); +call mtr.add_suppression("InnoDB: File .*ib_logfile0 (is too small|was not found)"); +call mtr.add_suppression("InnoDB: Expecting only ib_logfile0"); FLUSH TABLES; --enable_query_log let MYSQLD_DATADIR= `select @@datadir`; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; --source include/shutdown_mysqld.inc ---move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile.old -write_file $MYSQLD_DATADIR/ib_logfile0; +perl; +do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; +my $file = "$ENV{MYSQLD_DATADIR}ib_logfile0"; +open(FILE, "<$file") || die "Unable to open $file\n"; +seek(FILE, 4096, 0) || die "Unable to seek $file\n"; +die unless read(FILE, $_, 8) == 8; +my ($lsn_hi,$lsn_lo) = unpack("NN", $_); +seek(FILE, 8192, 0) || die "Unable to seek $file\n"; +die unless read(FILE, $_, 8) == 8; +my ($cp2hi,$cp2lo) = unpack("NN", $_); +if ($cp2hi < $lsn_hi) {} +elsif ($cp2hi > $lsn_hi || $cp2lo > $lsn_lo) +{ $lsn_hi=$cp2hi;$lsn_lo=$cp2lo; } +close(FILE); +open(FILE, ">", $file) or die "Unable to open $file\n"; +binmode FILE; +my $polynomial = 0x82f63b78; # CRC-32C +my ($header, $checkpoint, $log); +$header = "Phys" . pack("x[4]NN", $lsn_hi, $lsn_lo) . + "some Perl code" . pack("x[478]"); +$header .= pack("Nx[3584]", mycrc32($header, 0, $polynomial)); +$checkpoint = pack("NNNNx[44]", $lsn_hi, $lsn_lo, $lsn_hi, $lsn_lo); +$checkpoint .= pack("Nx[8128]", mycrc32($checkpoint, 0, $polynomial)); +$log = pack("CxxNN", 0xfa, $lsn_hi, $lsn_lo); +$log .= pack("CN", 1, mycrc32($log, 0, $polynomial)); +print FILE $header, $checkpoint, $log; +close(FILE) or die "Unable to close $file\n"; EOF + let $check_no_innodb=SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); ---let $restart_parameters= --innodb-log-file-size=2m +--let $restart_parameters= --innodb-log-file-size=4m --source include/start_mysqld.inc let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; @@ -95,11 +114,6 @@ SELECT * FROM t1; let SEARCH_PATTERN= InnoDB: Starting crash recovery from checkpoint LSN=.*; --source include/search_pattern_in_file.inc ---let $restart_parameters= --debug=d,innodb_log_abort_3 ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - --let $restart_parameters= --innodb-read-only --source include/restart_mysqld.inc @@ -108,18 +122,11 @@ SELECT * FROM t1; let SEARCH_PATTERN= InnoDB: innodb_read_only prevents crash recovery; --source include/search_pattern_in_file.inc ---let $restart_parameters= --debug=d,innodb_log_abort_4 ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; -let SEARCH_PATTERN= redo log from [0-9]+ to [0-9]+ bytes; ---source include/search_pattern_in_file.inc - --let $restart_parameters= --debug=d,innodb_log_abort_5 --source include/restart_mysqld.inc --error ER_UNKNOWN_STORAGE_ENGINE SELECT * FROM t1; -let SEARCH_PATTERN= redo log from [0-9]+ to [0-9]+ bytes; +let SEARCH_PATTERN= redo log from 5\\.000MiB to [0-9.]*[KMGT]iB; --source include/search_pattern_in_file.inc --let $restart_parameters= --innodb-read-only @@ -129,87 +136,40 @@ SELECT * FROM t1; let SEARCH_PATTERN= InnoDB: innodb_read_only prevents crash recovery; --source include/search_pattern_in_file.inc ---let $restart_parameters= --debug=d,innodb_log_abort_6 ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -let SEARCH_PATTERN= redo log from [0-9]+ to [0-9]+ bytes; ---source include/search_pattern_in_file.inc - ---let $restart_parameters= --debug=d,innodb_log_abort_7 ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -# this aborts right after deleting all log files - ---let $restart_parameters= --innodb-read-only ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -let SEARCH_PATTERN= InnoDB: Cannot create log file in read-only mode; ---source include/search_pattern_in_file.inc - ---let $restart_parameters= --debug=d,innodb_log_abort_8 ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; ---source include/search_pattern_in_file.inc - ---let $restart_parameters= --debug=d,innodb_log_abort_9 ---source include/restart_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; ---source include/search_pattern_in_file.inc ---source include/shutdown_mysqld.inc - -# We should have perfectly synced files here. # Trigger an error in recovery. -perl; -die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/ib_logfile0"); -print FILE "garbage"; -close(FILE); +--move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile101 +--write_file $MYSQLD_DATADIR/ib_logfile0 +garbage EOF ---source include/start_mysqld.inc +--let $restart_parameters= +--source include/restart_mysqld.inc --error ER_UNKNOWN_STORAGE_ENGINE SELECT * FROM t1; -let SEARCH_PATTERN= InnoDB: Log file .*ib_logfile0 size 7 is not a multiple of 512 bytes; +let SEARCH_PATTERN= InnoDB: File .*ib_logfile0 is too small; --source include/search_pattern_in_file.inc ---remove_file $MYSQLD_DATADIR/ib_logfile0 +--move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile1 --move_file $MYSQLD_DATADIR/ib_logfile101 $MYSQLD_DATADIR/ib_logfile0 -perl; -die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/ib_logfile1"); -print FILE "junkfill" x 131072; -close(FILE); -EOF - --source include/restart_mysqld.inc +--error ER_UNKNOWN_STORAGE_ENGINE SELECT * FROM t1; +let SEARCH_PATTERN= InnoDB: Expecting only ib_logfile0; +--source include/search_pattern_in_file.inc --remove_file $MYSQLD_DATADIR/ib_logfile1 --move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile101 ---let $restart_parameters= --debug=d,innodb_log_abort_10 --source include/restart_mysqld.inc --error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; ---source include/search_pattern_in_file.inc -let SEARCH_PATTERN= InnoDB: Renaming log file .*ib_logfile101 to .*ib_logfile0; +let SEARCH_PATTERN= InnoDB: File .*ib_logfile0 was not found; --source include/search_pattern_in_file.inc +--move_file $MYSQLD_DATADIR/ib_logfile101 $MYSQLD_DATADIR/ib_logfile0 ---let $restart_parameters= --source include/restart_mysqld.inc - SELECT * FROM t1; DROP TABLE t1; + +--let SEARCH_PATTERN= InnoDB: Resizing redo log from 5\\.000MiB to [0-9.]*[KMGT]iB; LSN=\\d+\\b +--source include/search_pattern_in_file.inc diff --git a/mysql-test/suite/innodb/t/missing_tablespaces.test b/mysql-test/suite/innodb/t/missing_tablespaces.test index 8dc325b3356..9f970ca2dd2 100644 --- a/mysql-test/suite/innodb/t/missing_tablespaces.test +++ b/mysql-test/suite/innodb/t/missing_tablespaces.test @@ -25,7 +25,7 @@ let $restart_noprint=2; --disable_query_log call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number 2 in a file operation."); -call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot find the path specified."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: Error number \\d+ means"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot open datafile for read-only"); call mtr.add_suppression("\\[Warning\\] InnoDB: Ignoring tablespace .* because it could not be opened"); --enable_query_log diff --git a/mysql-test/suite/innodb/t/rename_table.test b/mysql-test/suite/innodb/t/rename_table.test index 35421f0ce7a..654f8809b22 100644 --- a/mysql-test/suite/innodb/t/rename_table.test +++ b/mysql-test/suite/innodb/t/rename_table.test @@ -32,7 +32,7 @@ DROP DATABASE abc_def; DROP DATABASE abc_def2; -call mtr.add_suppression("InnoDB: (Operating system error|The error means|Cannot rename file)"); +call mtr.add_suppression("InnoDB: (Operating system error|Error number \\d+ means|Cannot rename file)"); CREATE TABLE t1 (a INT) ENGINE=InnoDB; --replace_result "\\" "/" diff --git a/mysql-test/suite/innodb/t/restart.test b/mysql-test/suite/innodb/t/restart.test index 1ca4f51c747..bb3d08a8779 100644 --- a/mysql-test/suite/innodb/t/restart.test +++ b/mysql-test/suite/innodb/t/restart.test @@ -93,7 +93,7 @@ DROP TABLE tr,tc,td; let $wait_timeout = 180; let $wait_condition = - SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool' FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; diff --git a/mysql-test/suite/innodb/t/truncate_missing.test b/mysql-test/suite/innodb/t/truncate_missing.test index fb6bd678237..d36a2de5cd9 100644 --- a/mysql-test/suite/innodb/t/truncate_missing.test +++ b/mysql-test/suite/innodb/t/truncate_missing.test @@ -2,7 +2,7 @@ --source include/not_embedded.inc call mtr.add_suppression("InnoDB: Operating system error number "); -call mtr.add_suppression("InnoDB: (The error means|If you are|Cannot open datafile) "); +call mtr.add_suppression("InnoDB: (Error number \\d+ means|If you are|Cannot open datafile) "); call mtr.add_suppression("InnoDB: Ignoring tablespace for test/t "); call mtr.add_suppression("InnoDB: Table test/t .* does not exist"); diff --git a/mysql-test/suite/innodb_fts/r/create.result b/mysql-test/suite/innodb_fts/r/create.result index 3ca24f5253d..4334344a981 100644 --- a/mysql-test/suite/innodb_fts/r/create.result +++ b/mysql-test/suite/innodb_fts/r/create.result @@ -187,4 +187,27 @@ FTS_DOC_ID bigint unsigned not null, unique key FTS_DOC_ID_INDEX(FTS_DOC_ID, f1), fulltext (f2)) engine=innodb; -ERROR 42000: Incorrect index name 'FTS_DOC_ID_INDEX' +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +# +# MDEV-26938 Support descending indexes internally in InnoDB +# +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC), FULLTEXT(b)) +ENGINE=InnoDB; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC)) ENGINE=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` text DEFAULT NULL, + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `FTS_DOC_ID_INDEX` (`FTS_DOC_ID` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=INPLACE; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=COPY; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/create.test b/mysql-test/suite/innodb_fts/t/create.test index 38c93de4982..edecef64589 100644 --- a/mysql-test/suite/innodb_fts/t/create.test +++ b/mysql-test/suite/innodb_fts/t/create.test @@ -110,10 +110,28 @@ SET GLOBAL innodb_optimize_fulltext_only= @optimize_fulltext.save; --echo # --echo # MDEV-24403 Segfault on CREATE TABLE with explicit FTS_DOC_ID_INDEX by multiple fields --echo # ---error ER_WRONG_NAME_FOR_INDEX +--error ER_INNODB_FT_WRONG_DOCID_INDEX create table t1 ( f1 int, f2 text, FTS_DOC_ID bigint unsigned not null, unique key FTS_DOC_ID_INDEX(FTS_DOC_ID, f1), fulltext (f2)) engine=innodb; + +--echo # +--echo # MDEV-26938 Support descending indexes internally in InnoDB +--echo # + +--error ER_INNODB_FT_WRONG_DOCID_INDEX +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC), FULLTEXT(b)) +ENGINE=InnoDB; + +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC)) ENGINE=InnoDB; +SHOW CREATE TABLE t1; +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=INPLACE; +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=COPY; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_gis/r/geometry.result b/mysql-test/suite/innodb_gis/r/geometry.result index e5acdf5eb6f..c38e9e28d85 100644 --- a/mysql-test/suite/innodb_gis/r/geometry.result +++ b/mysql-test/suite/innodb_gis/r/geometry.result @@ -342,7 +342,7 @@ tab CREATE TABLE `tab` ( `c7` geometrycollection DEFAULT NULL, `c8` geometry DEFAULT NULL, UNIQUE KEY `idx2` (`c8`(5)), - KEY `idx1` (`c2`(5)) USING BTREE, + KEY `idx1` (`c2`(5) DESC) USING BTREE, KEY `idx3` (`c3`(5)) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci #check the data after modify @@ -778,7 +778,7 @@ tab3 CREATE TABLE `tab3` ( `c7` geometrycollection DEFAULT NULL, `c8` geometry DEFAULT NULL, UNIQUE KEY `idx2` (`c8`(5)), - KEY `idx1` (`c2`(5)) USING BTREE, + KEY `idx1` (`c2`(5) DESC) USING BTREE, KEY `idx3` (`c3`(5)) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=16 #check index with WKB function diff --git a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result index db4bf8cd278..6c754d143c3 100644 --- a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result +++ b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result @@ -5,7 +5,7 @@ call mtr.add_suppression("InnoDB: Page for tablespace "); call mtr.add_suppression("InnoDB: Invalid FSP_SPACE_FLAGS=0x"); call mtr.add_suppression("InnoDB: Unknown index id .* on page"); call mtr.add_suppression("InnoDB: Operating system error number"); -call mtr.add_suppression("InnoDB: The error means"); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); call mtr.add_suppression("InnoDB: Cannot open datafile .*t1\\.ibd"); call mtr.add_suppression("InnoDB: Ignoring tablespace for test/t1 "); call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` because the \\.ibd file is missing"); diff --git a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test index c30a4f8f000..36dcd1e454b 100644 --- a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test +++ b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test @@ -21,7 +21,7 @@ call mtr.add_suppression("InnoDB: Page for tablespace "); call mtr.add_suppression("InnoDB: Invalid FSP_SPACE_FLAGS=0x"); call mtr.add_suppression("InnoDB: Unknown index id .* on page"); call mtr.add_suppression("InnoDB: Operating system error number"); -call mtr.add_suppression("InnoDB: The error means"); +call mtr.add_suppression("InnoDB: Error number \\d+ means"); call mtr.add_suppression("InnoDB: Cannot open datafile .*t1\\.ibd"); call mtr.add_suppression("InnoDB: Ignoring tablespace for test/t1 "); call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` because the \\.ibd file is missing"); diff --git a/mysql-test/suite/json/r/json_no_table.result b/mysql-test/suite/json/r/json_no_table.result index 6784fe6da32..10dd5d4b4ca 100644 --- a/mysql-test/suite/json/r/json_no_table.result +++ b/mysql-test/suite/json/r/json_no_table.result @@ -3338,7 +3338,7 @@ OBJECT CREATE VIEW v1 AS SELECT JSON_TYPE(JSON_OBJECT()); SELECT * FROM v1; JSON_TYPE(JSON_OBJECT()) -OBJE +OBJECT drop view v1; # # Bug#21198333 SIG 6 IN ITEM_CACHE_JSON::CACHE_VALUE AT SQL/ITEM.CC:9470 diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index cc87a34ffb3..fdecd9eb978 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -211,13 +211,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "tt", - "access_type": "ALL", - "rows": 40, - "filtered": 100, - "table_function": "json_table" - } + "nested_loop": [ + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows": 40, + "filtered": 100, + "table_function": "json_table" + } + } + ] } } explain select * from diff --git a/mysql-test/suite/json/r/json_table_mysql.result b/mysql-test/suite/json/r/json_table_mysql.result index 699d5a8b4f3..2357d9d3cf0 100644 --- a/mysql-test/suite/json/r/json_table_mysql.result +++ b/mysql-test/suite/json/r/json_table_mysql.result @@ -189,13 +189,17 @@ EXPLAIN { "query_block": { "select_id": 1, - "table": { - "table_name": "tt", - "access_type": "ALL", - "rows": 40, - "filtered": 100, - "table_function": "json_table" - } + "nested_loop": [ + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows": 40, + "filtered": 100, + "table_function": "json_table" + } + } + ] } } select * from diff --git a/mysql-test/suite/maria/maria2.result b/mysql-test/suite/maria/maria2.result index b4b27512054..c25659ae1f8 100644 --- a/mysql-test/suite/maria/maria2.result +++ b/mysql-test/suite/maria/maria2.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2; CREATE TABLE t1 ( line BLOB, kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po', @@ -68,3 +67,99 @@ pk apk data 3 4 NULL 5 6 NULL drop table t1; +# +# End of 5.5 tests +# +# +# MDEV-27303 Table corruption after insert into a non-InnoDB table with DESC index +# +create table t1 ( +a bigint default 0, +b bigint default 0, +c binary(128) not null, +d datetime default '0000-00-00 00:00:00', +key (c desc,b,d,a) +) engine=aria; +insert into t1 (c) values +('xx'),('bb'),('tt'),('pp'),('mm'),('yy'),('rr'),('bb'),('yy'),('gg'), +('dd'),('fx'),('wi'),('ix'),('ox'),('mu'),('ux'),('pm'),('mx'),('xu'), +('ul'),('lp'),('px'),('lp'),('xx'),('pq'),('qs'),('se'),('ee'),('xx'), +('rv'),('ff'),('vj'),('jy'),('yn'),('nc'),('nx'),('hj'),('ji'),('ik'), +('kk'),('ww'),('xx'),('yd'),('dw'),('wk'),('kr'),('dd'),('rj'),('jf'), +('bx'),('fc'),('cp'),('pm'),('mw'),('wy'),('yl'),('li'),('ic'),('he'), +('ci'),('il'),('lz'),('zd'),('gz'),('xd'),('ze'),('dm'),('ms'),('xd'), +('sw'),('we'),('nb'),('tx'),('vr'),('xw'),('aa'),('ah'),('hd'),('jl'), +('lf'),('fw'),('wx'),('xh'),('hr'),('zx'),('vw'),('rm'),('mx'),('xt'), +('tp'),('ps'),('sh'),('ga'),('df'),('as'),('gz'),('xd'),('yy'),('xr'); +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +# +# MDEV-27309 Server crash or ASAN memcpy-param-overlap upon INSERT into Aria/MyISAM table with DESC key +# +CREATE TABLE t1 (id INT, c BINARY(80), PRIMARY KEY(id)); +ALTER TABLE t1 ADD KEY(c DESC, id); +INSERT INTO t1 VALUES (1,NULL),(2,''),(3,''); +DROP TABLE t1; +# +# MDEV-27330 Wrong sorting order with DESC index and empty strings in MyISAM/Aria table +# +create table t (id int, c char(128) not null, key (c desc)) engine=aria; +insert into t values (1,''),(2,'foo'),(3,''),(4,'bar'); +select c from t order by c; +c + + +bar +foo +drop table t; +# +# MDEV-27340 NULL gets lost (becomes empty string), SELECT hangs with DESC index on MyISAM/Aria table +# +create table t (c char(8), key(c desc)) engine=aria character set utf8mb4; +insert into t values (''),('foo'),(null),(''),('bar'); +check table t; +Table Op Msg_type Msg_text +test.t check status OK +check table t extended; +Table Op Msg_type Msg_text +test.t check status OK +select distinct c from t; +c +NULL + +bar +foo +select c from t; +c +foo +bar + + +NULL +drop table t; +# +# MDEV-27434 DESC attribute does not work with auto-increment on secondary column of multi-part index +# +create table t (a int auto_increment, b int, unique(b,a desc)) engine=aria; +insert ignore into t (b) values (10),(10),(10); +select * from t; +a b +3 10 +2 10 +1 10 +drop table t; +# +# MDEV-27585 Auto-increment on secondary column increments unexpectedly with DESC key +# +create table t (c char(16), i int auto_increment, index (c,i desc)) engine=aria collate latin1_swedish_ci; +insert into t (c) values ('ä'),('a'); +select hex(c),c,i from t order by c, i; +hex(c) c i +61 a 1 +C3A4 ä 1 +drop table t; +# +# End of 10.8 tests +# diff --git a/mysql-test/suite/maria/maria2.test b/mysql-test/suite/maria/maria2.test index df691569e05..0f4a50ad99d 100644 --- a/mysql-test/suite/maria/maria2.test +++ b/mysql-test/suite/maria/maria2.test @@ -1,10 +1,5 @@ --source include/have_maria.inc -# Initialise ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - # Test for BUG#36319 # "Aria: table is not empty but DELETE and SELECT find no rows" @@ -109,3 +104,78 @@ select * from t1 order by pk; load data infile '../../std_data/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); select * from t1 order by pk; drop table t1; + +--echo # +--echo # End of 5.5 tests +--echo # + +--echo # +--echo # MDEV-27303 Table corruption after insert into a non-InnoDB table with DESC index +--echo # +create table t1 ( + a bigint default 0, + b bigint default 0, + c binary(128) not null, + d datetime default '0000-00-00 00:00:00', + key (c desc,b,d,a) +) engine=aria; +insert into t1 (c) values + ('xx'),('bb'),('tt'),('pp'),('mm'),('yy'),('rr'),('bb'),('yy'),('gg'), + ('dd'),('fx'),('wi'),('ix'),('ox'),('mu'),('ux'),('pm'),('mx'),('xu'), + ('ul'),('lp'),('px'),('lp'),('xx'),('pq'),('qs'),('se'),('ee'),('xx'), + ('rv'),('ff'),('vj'),('jy'),('yn'),('nc'),('nx'),('hj'),('ji'),('ik'), + ('kk'),('ww'),('xx'),('yd'),('dw'),('wk'),('kr'),('dd'),('rj'),('jf'), + ('bx'),('fc'),('cp'),('pm'),('mw'),('wy'),('yl'),('li'),('ic'),('he'), + ('ci'),('il'),('lz'),('zd'),('gz'),('xd'),('ze'),('dm'),('ms'),('xd'), + ('sw'),('we'),('nb'),('tx'),('vr'),('xw'),('aa'),('ah'),('hd'),('jl'), + ('lf'),('fw'),('wx'),('xh'),('hr'),('zx'),('vw'),('rm'),('mx'),('xt'), + ('tp'),('ps'),('sh'),('ga'),('df'),('as'),('gz'),('xd'),('yy'),('xr'); +check table t1 extended; +drop table t1; + +--echo # +--echo # MDEV-27309 Server crash or ASAN memcpy-param-overlap upon INSERT into Aria/MyISAM table with DESC key +--echo # +CREATE TABLE t1 (id INT, c BINARY(80), PRIMARY KEY(id)); +ALTER TABLE t1 ADD KEY(c DESC, id); +INSERT INTO t1 VALUES (1,NULL),(2,''),(3,''); +DROP TABLE t1; + +--echo # +--echo # MDEV-27330 Wrong sorting order with DESC index and empty strings in MyISAM/Aria table +--echo # +create table t (id int, c char(128) not null, key (c desc)) engine=aria; +insert into t values (1,''),(2,'foo'),(3,''),(4,'bar'); +select c from t order by c; +drop table t; + +--echo # +--echo # MDEV-27340 NULL gets lost (becomes empty string), SELECT hangs with DESC index on MyISAM/Aria table +--echo # +create table t (c char(8), key(c desc)) engine=aria character set utf8mb4; +insert into t values (''),('foo'),(null),(''),('bar'); +check table t; +check table t extended; +select distinct c from t; +select c from t; +drop table t; + +--echo # +--echo # MDEV-27434 DESC attribute does not work with auto-increment on secondary column of multi-part index +--echo # +create table t (a int auto_increment, b int, unique(b,a desc)) engine=aria; +insert ignore into t (b) values (10),(10),(10); +select * from t; +drop table t; + +--echo # +--echo # MDEV-27585 Auto-increment on secondary column increments unexpectedly with DESC key +--echo # +create table t (c char(16), i int auto_increment, index (c,i desc)) engine=aria collate latin1_swedish_ci; +insert into t (c) values ('ä'),('a'); +select hex(c),c,i from t order by c, i; +drop table t; + +--echo # +--echo # End of 10.8 tests +--echo # diff --git a/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff b/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff new file mode 100644 index 00000000000..29afd468751 --- /dev/null +++ b/mysql-test/suite/mariabackup/huge_lsn,strict_crc32.rdiff @@ -0,0 +1,11 @@ +@@ -1,8 +1,8 @@ + # + # MDEV-13416 mariabackup fails with EFAULT "Bad Address" + # +-# restart: --innodb-log-file-size=4M --innodb-encrypt-log=0 +-FOUND 1 /InnoDB: log sequence number 17596481011216/ in mysqld.1.err ++# restart ++FOUND 1 /redo log: [0-9.]*[KMGT]iB; LSN=17596481010687\b/ in mysqld.1.err + CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES; + INSERT INTO t VALUES(1); + # xtrabackup backup diff --git a/mysql-test/suite/mariabackup/huge_lsn.result b/mysql-test/suite/mariabackup/huge_lsn.result index 73b51ea438f..503d13fcac4 100644 --- a/mysql-test/suite/mariabackup/huge_lsn.result +++ b/mysql-test/suite/mariabackup/huge_lsn.result @@ -1,8 +1,8 @@ # # MDEV-13416 mariabackup fails with EFAULT "Bad Address" # -# restart -FOUND 1 /InnoDB: New log file created, LSN=175964\d{8}/ in mysqld.1.err +# restart: --innodb-log-file-size=4M --innodb-encrypt-log=0 +FOUND 1 /InnoDB: log sequence number 17596481011216/ in mysqld.1.err CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES; INSERT INTO t VALUES(1); # xtrabackup backup diff --git a/mysql-test/suite/mariabackup/huge_lsn.test b/mysql-test/suite/mariabackup/huge_lsn.test index 66fe00dd761..8850e9d8954 100644 --- a/mysql-test/suite/mariabackup/huge_lsn.test +++ b/mysql-test/suite/mariabackup/huge_lsn.test @@ -14,8 +14,8 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir= --enable_result_log --source include/shutdown_mysqld.inc +if ($MTR_COMBINATION_STRICT_CRC32) { perl; -do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; my $file= "$ENV{MYSQLD_DATADIR}/ibdata1"; open(FILE, "+<", $file) or die "Unable to open $file\n"; binmode FILE; @@ -23,23 +23,54 @@ my $ps= $ENV{INNODB_PAGE_SIZE}; my $page; die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; substr($page,26,8) = pack("NN", 4096, ~1024); -my $polynomial = 0x82f63b78; # CRC-32C -my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS -if ($full_crc32) -{ - my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial); - substr($page, $ps-4, 4) = pack("N", $ck); -} sysseek(FILE, 0, 0) || die "Unable to rewind $file\n"; syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; close(FILE) || die "Unable to close $file\n"; + +$file= "$ENV{MYSQLD_DATADIR}/ib_logfile0"; +open(FILE, ">", $file) || die "Unable to truncate $file\n"; +close(FILE) || "Unable to close $file\n"; EOF +--let SEARCH_PATTERN= redo log: [0-9.]*[KMGT]iB; LSN=17596481010687\\b +} ---remove_files_wildcard $MYSQLD_DATADIR ib_logfile* +if (!$MTR_COMBINATION_STRICT_CRC32) { +perl; +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; +my $file= "$ENV{MYSQLD_DATADIR}/ib_logfile0"; +open(FILE, ">", $file) or die "Unable to open $file\n"; +binmode FILE; +my $extra_repeat = 139820; +# The desired log sequence number is 17596481011216 (0x1000fffffe10). +my $file_size=4<<20; +my $lsn_hi=4096,$lsn_lo=0xfffffe00 - $extra_repeat * 15; +my $polynomial = 0x82f63b78; # CRC-32C +my ($header, $checkpoint, $log); +$header = "Phys" . pack("x[4]NN", $lsn_hi, $lsn_lo - $file_size + 0x300f) . + "some Perl code" . pack("x[478]"); +$header .= pack("Nx[3584]", mycrc32($header, 0, $polynomial)); +$checkpoint = pack("NNNNx[44]", $lsn_hi, $lsn_lo, $lsn_hi, $lsn_lo); +$checkpoint .= pack("Nx[8128]", mycrc32($checkpoint, 0, $polynomial)); +$log = pack("CxxNN", 0xfa, $lsn_hi, $lsn_lo); +$log .= pack("CN", 0, mycrc32($log, 0, $polynomial)); + +# Write more than 2MiB of FILE_MODIFY mini-transactions to exercise the parser. +my $extra = pack("CCxa*", 0xb9, 127, "a/b.ibd"); +$extra .= pack("CN", 0, mycrc32($extra, 0, $polynomial)); + +print FILE $header, $checkpoint, $extra x ($extra_repeat - 1), $log; +seek(FILE, $file_size - 15, 0); +$extra = pack("CCxa*", 0xb9, 127, "c/d.ibd"); +$extra .= pack("CN", 1, mycrc32($extra, 0, $polynomial)); +print FILE $extra; +close(FILE) or die "Unable to close $file\n"; +EOF +--let SEARCH_PATTERN= InnoDB: log sequence number 17596481011216 +--let $restart_parameters=--innodb-log-file-size=4M --innodb-encrypt-log=0 +} --source include/start_mysqld.inc let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; ---let SEARCH_PATTERN= InnoDB: New log file created, LSN=175964\d{8} --source include/search_pattern_in_file.inc CREATE TABLE t(i INT) ENGINE=INNODB ENCRYPTED=YES; @@ -55,6 +86,7 @@ INSERT INTO t VALUES(2); echo # xtrabackup prepare; --disable_result_log exec $XTRABACKUP --prepare --target-dir=$targetdir; +--let $restart_parameters= --source include/restart_and_restore.inc --enable_result_log SELECT * FROM t; diff --git a/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt index 95b88d038ee..a0b4b588279 100644 --- a/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt +++ b/mysql-test/suite/mariabackup/innodb_redo_log_overwrite.opt @@ -1 +1 @@ ---loose-innodb-log-file-size=2097152 +--loose-innodb-log-file-size=4194304 diff --git a/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt b/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt index 19c08c8c945..a0b4b588279 100644 --- a/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt +++ b/mysql-test/suite/mariabackup/innodb_redo_overwrite.opt @@ -1 +1 @@ ---loose-innodb-log-file-size=2m +--loose-innodb-log-file-size=4194304 diff --git a/mysql-test/suite/mariabackup/innodb_redo_overwrite.result b/mysql-test/suite/mariabackup/innodb_redo_overwrite.result index 9076dbaa57a..bab5d4331e0 100644 --- a/mysql-test/suite/mariabackup/innodb_redo_overwrite.result +++ b/mysql-test/suite/mariabackup/innodb_redo_overwrite.result @@ -1,27 +1,5 @@ -CREATE TABLE t(i INT) ENGINE=INNODB; -INSERT INTO t VALUES -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), -(0), (1), (2), (3), (4), (5), (6), (7), (8), (9); -# Generate enough data to overwrite innodb redo log -# on the next "INSERT INTO t SELECT * FROM t" execution. -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; -INSERT INTO t SELECT * FROM t; +CREATE TABLE t ENGINE=INNODB SELECT seq%10 i FROM seq_0_to_204796; # xtrabackup backup -FOUND 1 /failed: redo log block is overwritten/ in backup.log -FOUND 1 /failed: redo log block checksum does not match/ in backup.log +FOUND 1 /Was only able to copy log from \d+ to \d+, not \d+; try increasing innodb_log_file_size\b/ in backup.log +NOT FOUND /failed: redo log block checksum does not match/ in backup.log DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/innodb_redo_overwrite.test b/mysql-test/suite/mariabackup/innodb_redo_overwrite.test index e27229c5f33..34198222cea 100644 --- a/mysql-test/suite/mariabackup/innodb_redo_overwrite.test +++ b/mysql-test/suite/mariabackup/innodb_redo_overwrite.test @@ -1,26 +1,9 @@ --source include/have_innodb.inc --source include/have_debug_sync.inc +--source include/have_debug.inc +--source include/have_sequence.inc -CREATE TABLE t(i INT) ENGINE=INNODB; - -INSERT INTO t VALUES - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), - (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); ---echo # Generate enough data to overwrite innodb redo log ---echo # on the next "INSERT INTO t SELECT * FROM t" execution. ---let $i = 0 -while ($i < 9) { -INSERT INTO t SELECT * FROM t; ---inc $i -} +CREATE TABLE t ENGINE=INNODB SELECT seq%10 i FROM seq_0_to_204796; --echo # xtrabackup backup --let $targetdir=$MYSQLTEST_VARDIR/tmp/backup @@ -33,13 +16,13 @@ INSERT INTO t SELECT * FROM t; --exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events > $backuplog --enable_result_log ---let SEARCH_PATTERN=failed: redo log block is overwritten +--let SEARCH_PATTERN=Was only able to copy log from \\d+ to \\d+, not \\d+; try increasing innodb_log_file_size\\b --let SEARCH_FILE=$backuplog --source include/search_pattern_in_file.inc --remove_file $backuplog --rmdir $targetdir ---let before_innodb_log_copy_thread_started=INSERT INTO test.t VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) +--let before_innodb_log_copy_thread_started=INSERT INTO test.t SELECT seq FROM seq_0_to_9 --disable_result_log --error 1 diff --git a/mysql-test/suite/mariabackup/missing_ibd.test b/mysql-test/suite/mariabackup/missing_ibd.test index dc1406039e7..f406a555b4a 100644 --- a/mysql-test/suite/mariabackup/missing_ibd.test +++ b/mysql-test/suite/mariabackup/missing_ibd.test @@ -9,7 +9,7 @@ let MYSQLD_DATADIR=`select @@datadir`; --disable_query_log call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: '.*test.t1\.ibd'"); -call mtr.add_suppression('InnoDB: Operating system error number'); +call mtr.add_suppression('InnoDB: (Operating system error number|Error number \\d+ means)'); call mtr.add_suppression('InnoDB: The error means the system cannot find the path specified\.'); call mtr.add_suppression('InnoDB: Table test/t1 in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist'); call mtr.add_suppression('InnoDB: Ignoring tablespace for test/t1 because it could not be opened\.'); diff --git a/mysql-test/suite/mariabackup/xb_file_key_management.result b/mysql-test/suite/mariabackup/xb_file_key_management.result index 6cedfd2213b..cf8edb310b8 100644 --- a/mysql-test/suite/mariabackup/xb_file_key_management.result +++ b/mysql-test/suite/mariabackup/xb_file_key_management.result @@ -1,5 +1,7 @@ -CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; +CREATE TABLE t(c TEXT) ENGINE INNODB encrypted=yes; +INSERT INTO t VALUES(REPEAT('fubar',100)); INSERT INTO t VALUES('foobar1'); +DELETE FROM t LIMIT 1; # xtrabackup backup NOT FOUND /foobar1/ in ib_logfile0 # expect NOT FOUND diff --git a/mysql-test/suite/mariabackup/xb_file_key_management.test b/mysql-test/suite/mariabackup/xb_file_key_management.test index 2a176952053..4d27b2dfa95 100644 --- a/mysql-test/suite/mariabackup/xb_file_key_management.test +++ b/mysql-test/suite/mariabackup/xb_file_key_management.test @@ -1,8 +1,10 @@ #--source include/innodb_page_size.inc --source include/have_file_key_management.inc -CREATE TABLE t(c VARCHAR(10)) ENGINE INNODB encrypted=yes; +CREATE TABLE t(c TEXT) ENGINE INNODB encrypted=yes; +INSERT INTO t VALUES(REPEAT('fubar',100)); INSERT INTO t VALUES('foobar1'); +DELETE FROM t LIMIT 1; echo # xtrabackup backup; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; --disable_result_log @@ -24,7 +26,7 @@ exec $XTRABACKUP --prepare --target-dir=$targetdir; --enable_result_log --list_files $targetdir ib_logfile* ---cat_file $targetdir/ib_logfile0 +--remove_file $targetdir/ib_logfile0 SELECT * FROM t; DROP TABLE t; diff --git a/mysql-test/suite/parts/r/engine_defined_part_attributes.result b/mysql-test/suite/parts/r/engine_defined_part_attributes.result new file mode 100644 index 00000000000..fe7a89fdf52 --- /dev/null +++ b/mysql-test/suite/parts/r/engine_defined_part_attributes.result @@ -0,0 +1,288 @@ +# +# MDEV-5271 Support engine-defined attributes per partition +# +# partitioned tables +CREATE TABLE `t1` ( +`id` INT +) ENGINE=InnoDB ENCRYPTED="YES" PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO" ENCRYPTION_KEY_ID=1, +PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="DEFAULT" ENCRYPTION_KEY_ID=1 +); +SHOW CREATE TABLE `t1`; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='YES' + PARTITION BY RANGE (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) ENGINE = InnoDB ENCRYPTED = 'NO' ENCRYPTION_KEY_ID = 1, + PARTITION `pt2` VALUES LESS THAN MAXVALUE ENGINE = InnoDB ENCRYPTED = 'DEFAULT' ENCRYPTION_KEY_ID = 1) +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 WHERE id = 1; +UPDATE t1 SET id = 4 WHERE id = 3; +SELECT * FROM t1 WHERE id IN (2, 3); +id +2 +DROP TABLE `t1`; +CREATE TABLE `t2` ( +`id` INT +) ENGINE=InnoDB ENCRYPTED="YES" ENCRYPTION_KEY_ID=2 PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100), +PARTITION pt2 VALUES LESS THAN MAXVALUE +); +ERROR HY000: Can't create table `test`.`t2` (errno: 140 "Wrong create options") +CREATE TABLE `t3` ( +`id` INT +) ENGINE=InnoDB ENCRYPTED="NO" PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES" ENCRYPTION_KEY_ID=2, +PARTITION pt2 VALUES LESS THAN MAXVALUE +); +ERROR HY000: Can't create table `test`.`t3` (errno: 140 "Wrong create options") +CREATE TABLE `t4` ( +`id` INT +) ENGINE=InnoDB ENCRYPTED="NO"; +SHOW CREATE TABLE `t4`; +Table Create Table +t4 CREATE TABLE `t4` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='NO' +ALTER TABLE `t4` PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO", +PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="DEFAULT" +); +SHOW CREATE TABLE `t4`; +Table Create Table +t4 CREATE TABLE `t4` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='NO' + PARTITION BY RANGE (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) ENGINE = InnoDB ENCRYPTED = 'NO', + PARTITION `pt2` VALUES LESS THAN MAXVALUE ENGINE = InnoDB ENCRYPTED = 'DEFAULT') +ALTER TABLE `t4` PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100), +PARTITION pt2 VALUES LESS THAN MAXVALUE +); +SHOW CREATE TABLE `t4`; +Table Create Table +t4 CREATE TABLE `t4` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='NO' + PARTITION BY RANGE (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) ENGINE = InnoDB, + PARTITION `pt2` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +ALTER TABLE `t4` PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES" ENCRYPTION_KEY_ID=2, +PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="DEFAULT" +); +ERROR HY000: Can't create table `test`.`t4` (errno: 140 "Wrong create options") +DROP TABLE `t4`; +# subpartitioned tables +CREATE TABLE `t5` ( +`id` INT +) ENGINE=InnoDB ENCRYPTED="NO" PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) +SUBPARTITIONS 2 ( +PARTITION pt1 VALUES LESS THAN (100), +PARTITION pt2 VALUES LESS THAN MAXVALUE +); +SHOW CREATE TABLE `t5`; +Table Create Table +t5 CREATE TABLE `t5` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='NO' + PARTITION BY RANGE (`id`) +SUBPARTITION BY HASH (`id`) +SUBPARTITIONS 2 +(PARTITION `pt1` VALUES LESS THAN (100) ENGINE = InnoDB, + PARTITION `pt2` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +DROP TABLE `t5`; +CREATE TABLE `t6` ( +`id` INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) +SUBPARTITIONS 2 ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES", +PARTITION pt2 VALUES LESS THAN MAXVALUE +); +ERROR HY000: Can't create table `test`.`t6` (errno: 140 "Wrong create options") +CREATE TABLE `t7` ( +id INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( +PARTITION pt1 VALUES LESS THAN (100)( +SUBPARTITION spt1 ENCRYPTED="NO", +SUBPARTITION spt2 +), +PARTITION pt2 VALUES LESS THAN MAXVALUE ( +SUBPARTITION spt3, +SUBPARTITION spt4 +) +); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ENCRYPTED="NO", +SUBPARTITION spt2 +), +PARTITION pt2 VALUES LESS THAN MAXVALUE ...' at line 6 +CREATE TABLE `t8` ( +id INT +) ENGINE=InnoDB ENCRYPTED="NO" PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( +PARTITION pt1 VALUES LESS THAN (100) ( +SUBPARTITION spt1, +SUBPARTITION spt2 +), +PARTITION pt2 VALUES LESS THAN MAXVALUE ( +SUBPARTITION spt3, +SUBPARTITION spt4 +) +); +SHOW CREATE TABLE `t8`; +Table Create Table +t8 CREATE TABLE `t8` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='NO' + PARTITION BY RANGE (`id`) +SUBPARTITION BY HASH (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) + (SUBPARTITION `spt1` ENGINE = InnoDB, + SUBPARTITION `spt2` ENGINE = InnoDB), + PARTITION `pt2` VALUES LESS THAN MAXVALUE + (SUBPARTITION `spt3` ENGINE = InnoDB, + SUBPARTITION `spt4` ENGINE = InnoDB)) +DROP TABLE `t8`; +CREATE TABLE `t9` ( +id INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO" ( +SUBPARTITION spt1, +SUBPARTITION spt2 +), +PARTITION pt2 VALUES LESS THAN MAXVALUE ( +SUBPARTITION spt3, +SUBPARTITION spt4 +) +); +SHOW CREATE TABLE `t9`; +Table Create Table +t9 CREATE TABLE `t9` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci + PARTITION BY RANGE (`id`) +SUBPARTITION BY HASH (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) + (SUBPARTITION `spt1` ENGINE = InnoDB, + SUBPARTITION `spt2` ENGINE = InnoDB), + PARTITION `pt2` VALUES LESS THAN MAXVALUE + (SUBPARTITION `spt3` ENGINE = InnoDB, + SUBPARTITION `spt4` ENGINE = InnoDB)) +DROP TABLE `t9`; +CREATE TABLE `t10` ( +id INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES" ( +SUBPARTITION spt1, +SUBPARTITION spt2 +), +PARTITION pt2 VALUES LESS THAN MAXVALUE ( +SUBPARTITION spt3, +SUBPARTITION spt4 +) +); +ERROR HY000: Can't create table `test`.`t10` (errno: 140 "Wrong create options") +CREATE TABLE `t11` ( +id INT +) ENGINE=InnoDB ENCRYPTED="YES" PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( +PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO" ( +SUBPARTITION spt1, +SUBPARTITION spt2 +), +PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="NO" ( +SUBPARTITION spt3, +SUBPARTITION spt4 +) +); +SHOW CREATE TABLE `t11`; +Table Create Table +t11 CREATE TABLE `t11` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`='YES' + PARTITION BY RANGE (`id`) +SUBPARTITION BY HASH (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) + (SUBPARTITION `spt1` ENGINE = InnoDB, + SUBPARTITION `spt2` ENGINE = InnoDB), + PARTITION `pt2` VALUES LESS THAN MAXVALUE + (SUBPARTITION `spt3` ENGINE = InnoDB, + SUBPARTITION `spt4` ENGINE = InnoDB)) +DROP TABLE `t11`; +# +# MDEV-27605 ALTER .. ADD PARTITION uses wrong partition-level option values +# +# restart: --innodb-sys-tablespaces +CREATE TABLE `t12` ( +id INT +) ENGINE=InnoDB PARTITION BY HASH(id) +( +pt1 PAGE_COMPRESSED=0 +); +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%'; +name flag +test/t12#P#pt1 21 +ALTER TABLE `t12` ADD PARTITION ( +PARTITION pt2 PAGE_COMPRESSED=1 +); +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%'; +name flag +test/t12#P#pt1 21 +test/t12#P#pt2 1610612789 +ALTER TABLE `t12` ADD PARTITION ( +PARTITION pt3 PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3 +); +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%'; +name flag +test/t12#P#pt1 21 +test/t12#P#pt2 1610612789 +test/t12#P#pt3 805306421 +DROP TABLE `t12`; +CREATE TABLE `t13` ( +`id` INT +) ENGINE=InnoDB PAGE_COMPRESSED=1 PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100) PAGE_COMPRESSED=0, +PARTITION pt2 VALUES LESS THAN (200) PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3, +PARTITION pt3 VALUES LESS THAN MAXVALUE +); +SHOW CREATE TABLE `t13`; +Table Create Table +t13 CREATE TABLE `t13` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `PAGE_COMPRESSED`=1 + PARTITION BY RANGE (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) ENGINE = InnoDB PAGE_COMPRESSED = 0, + PARTITION `pt2` VALUES LESS THAN (200) ENGINE = InnoDB PAGE_COMPRESSED = 1 PAGE_COMPRESSION_LEVEL = 3, + PARTITION `pt3` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t13%'; +name flag +test/t13#P#pt1 21 +test/t13#P#pt2 805306421 +test/t13#P#pt3 1610612789 +ALTER TABLE `t13` PARTITION BY RANGE(id) ( +PARTITION pt1 VALUES LESS THAN (100) PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3, +PARTITION pt2 VALUES LESS THAN (200), +PARTITION pt3 VALUES LESS THAN MAXVALUE PAGE_COMPRESSED=0 +); +SHOW CREATE TABLE `t13`; +Table Create Table +t13 CREATE TABLE `t13` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `PAGE_COMPRESSED`=1 + PARTITION BY RANGE (`id`) +(PARTITION `pt1` VALUES LESS THAN (100) ENGINE = InnoDB PAGE_COMPRESSED = 1 PAGE_COMPRESSION_LEVEL = 3, + PARTITION `pt2` VALUES LESS THAN (200) ENGINE = InnoDB, + PARTITION `pt3` VALUES LESS THAN MAXVALUE ENGINE = InnoDB PAGE_COMPRESSED = 0) +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t13%'; +name flag +test/t13#P#pt1 805306421 +test/t13#P#pt2 1610612789 +test/t13#P#pt3 21 +DROP TABLE `t13`; diff --git a/mysql-test/suite/parts/t/engine_defined_part_attributes.test b/mysql-test/suite/parts/t/engine_defined_part_attributes.test new file mode 100644 index 00000000000..22aec9286e9 --- /dev/null +++ b/mysql-test/suite/parts/t/engine_defined_part_attributes.test @@ -0,0 +1,216 @@ +--echo # +--echo # MDEV-5271 Support engine-defined attributes per partition +--echo # + +--source include/have_partition.inc +--source include/have_innodb.inc + +--echo # partitioned tables + +CREATE TABLE `t1` ( + `id` INT +) ENGINE=InnoDB ENCRYPTED="YES" PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO" ENCRYPTION_KEY_ID=1, + PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="DEFAULT" ENCRYPTION_KEY_ID=1 +); +SHOW CREATE TABLE `t1`; + +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 WHERE id = 1; +UPDATE t1 SET id = 4 WHERE id = 3; +SELECT * FROM t1 WHERE id IN (2, 3); + +DROP TABLE `t1`; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE `t2` ( + `id` INT +) ENGINE=InnoDB ENCRYPTED="YES" ENCRYPTION_KEY_ID=2 PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100), + PARTITION pt2 VALUES LESS THAN MAXVALUE +); + +--error ER_CANT_CREATE_TABLE +CREATE TABLE `t3` ( + `id` INT +) ENGINE=InnoDB ENCRYPTED="NO" PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES" ENCRYPTION_KEY_ID=2, + PARTITION pt2 VALUES LESS THAN MAXVALUE +); + +CREATE TABLE `t4` ( + `id` INT +) ENGINE=InnoDB ENCRYPTED="NO"; +SHOW CREATE TABLE `t4`; + +ALTER TABLE `t4` PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO", + PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="DEFAULT" +); +SHOW CREATE TABLE `t4`; + +ALTER TABLE `t4` PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100), + PARTITION pt2 VALUES LESS THAN MAXVALUE +); +SHOW CREATE TABLE `t4`; + +--error ER_CANT_CREATE_TABLE +ALTER TABLE `t4` PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES" ENCRYPTION_KEY_ID=2, + PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="DEFAULT" +); + +DROP TABLE `t4`; + +--echo # subpartitioned tables + +CREATE TABLE `t5` ( + `id` INT +) ENGINE=InnoDB ENCRYPTED="NO" PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) +SUBPARTITIONS 2 ( + PARTITION pt1 VALUES LESS THAN (100), + PARTITION pt2 VALUES LESS THAN MAXVALUE +); +SHOW CREATE TABLE `t5`; + +DROP TABLE `t5`; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE `t6` ( + `id` INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) +SUBPARTITIONS 2 ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES", + PARTITION pt2 VALUES LESS THAN MAXVALUE +); + +--error ER_PARSE_ERROR +CREATE TABLE `t7` ( + id INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( + PARTITION pt1 VALUES LESS THAN (100)( + SUBPARTITION spt1 ENCRYPTED="NO", + SUBPARTITION spt2 + ), + PARTITION pt2 VALUES LESS THAN MAXVALUE ( + SUBPARTITION spt3, + SUBPARTITION spt4 + ) +); + +CREATE TABLE `t8` ( + id INT +) ENGINE=InnoDB ENCRYPTED="NO" PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( + PARTITION pt1 VALUES LESS THAN (100) ( + SUBPARTITION spt1, + SUBPARTITION spt2 + ), + PARTITION pt2 VALUES LESS THAN MAXVALUE ( + SUBPARTITION spt3, + SUBPARTITION spt4 + ) +); +SHOW CREATE TABLE `t8`; + +DROP TABLE `t8`; + +CREATE TABLE `t9` ( + id INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO" ( + SUBPARTITION spt1, + SUBPARTITION spt2 + ), + PARTITION pt2 VALUES LESS THAN MAXVALUE ( + SUBPARTITION spt3, + SUBPARTITION spt4 + ) +); +SHOW CREATE TABLE `t9`; + +DROP TABLE `t9`; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE `t10` ( + id INT +) ENGINE=InnoDB PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="YES" ( + SUBPARTITION spt1, + SUBPARTITION spt2 + ), + PARTITION pt2 VALUES LESS THAN MAXVALUE ( + SUBPARTITION spt3, + SUBPARTITION spt4 + ) +); + +CREATE TABLE `t11` ( + id INT +) ENGINE=InnoDB ENCRYPTED="YES" PARTITION BY RANGE(id) +SUBPARTITION BY HASH(id) ( + PARTITION pt1 VALUES LESS THAN (100) ENCRYPTED="NO" ( + SUBPARTITION spt1, + SUBPARTITION spt2 + ), + PARTITION pt2 VALUES LESS THAN MAXVALUE ENCRYPTED="NO" ( + SUBPARTITION spt3, + SUBPARTITION spt4 + ) +); +SHOW CREATE TABLE `t11`; + +DROP TABLE `t11`; + +--echo # +--echo # MDEV-27605 ALTER .. ADD PARTITION uses wrong partition-level option values +--echo # + +--let $restart_parameters= --innodb-sys-tablespaces +--source include/restart_mysqld.inc + +CREATE TABLE `t12` ( + id INT +) ENGINE=InnoDB PARTITION BY HASH(id) +( + pt1 PAGE_COMPRESSED=0 +); +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%'; + +ALTER TABLE `t12` ADD PARTITION ( + PARTITION pt2 PAGE_COMPRESSED=1 +); +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%'; + +ALTER TABLE `t12` ADD PARTITION ( + PARTITION pt3 PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3 +); +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t12%'; + +DROP TABLE `t12`; + +CREATE TABLE `t13` ( + `id` INT +) ENGINE=InnoDB PAGE_COMPRESSED=1 PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100) PAGE_COMPRESSED=0, + PARTITION pt2 VALUES LESS THAN (200) PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3, + PARTITION pt3 VALUES LESS THAN MAXVALUE +); +SHOW CREATE TABLE `t13`; +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t13%'; + +ALTER TABLE `t13` PARTITION BY RANGE(id) ( + PARTITION pt1 VALUES LESS THAN (100) PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=3, + PARTITION pt2 VALUES LESS THAN (200), + PARTITION pt3 VALUES LESS THAN MAXVALUE PAGE_COMPRESSED=0 +); +SHOW CREATE TABLE `t13`; +SELECT name, flag FROM information_schema.innodb_sys_tablespaces WHERE name like 'test/t13%'; + +DROP TABLE `t13`; diff --git a/mysql-test/suite/perfschema/include/default_mysqld_autosize.cnf b/mysql-test/suite/perfschema/include/default_mysqld_autosize.cnf index eee52ede869..6bcf7a09401 100644 --- a/mysql-test/suite/perfschema/include/default_mysqld_autosize.cnf +++ b/mysql-test/suite/perfschema/include/default_mysqld_autosize.cnf @@ -19,9 +19,8 @@ loose-innodb_buffer_pool_size= 8M loose-innodb_lru_scan_depth= 100 loose-innodb_write_io_threads= 2 loose-innodb_read_io_threads= 2 -loose-innodb_log_buffer_size= 1M -loose-innodb_log_file_size= 5M -loose-innodb_log_files_in_group= 2 +loose-innodb_log_buffer_size= 2M +loose-innodb_log_file_size= 10M slave-net-timeout=120 diff --git a/mysql-test/suite/perfschema/r/sxlock_func.result b/mysql-test/suite/perfschema/r/sxlock_func.result index ff556c1e011..d6bbce28ee1 100644 --- a/mysql-test/suite/perfschema/r/sxlock_func.result +++ b/mysql-test/suite/perfschema/r/sxlock_func.result @@ -10,6 +10,7 @@ name wait/synch/rwlock/innodb/dict_operation_lock wait/synch/rwlock/innodb/fil_space_latch wait/synch/rwlock/innodb/lock_latch +wait/synch/rwlock/innodb/log_latch wait/synch/rwlock/innodb/trx_i_s_cache_lock wait/synch/rwlock/innodb/trx_purge_latch wait/synch/rwlock/innodb/trx_rseg_latch @@ -43,6 +44,7 @@ ORDER BY event_name; event_name wait/synch/rwlock/innodb/fil_space_latch wait/synch/rwlock/innodb/lock_latch +wait/synch/rwlock/innodb/log_latch SELECT event_name FROM performance_schema.events_waits_history_long WHERE event_name = 'wait/synch/sxlock/innodb/index_tree_rw_lock' AND operation IN ('try_shared_lock','shared_lock') LIMIT 1; diff --git a/mysql-test/suite/rpl/include/start_alter_basic.inc b/mysql-test/suite/rpl/include/start_alter_basic.inc new file mode 100644 index 00000000000..f6e4b6b3253 --- /dev/null +++ b/mysql-test/suite/rpl/include/start_alter_basic.inc @@ -0,0 +1,60 @@ +# +# Run start alter basic tests (CA/RA with given engine) +# Params:- +# $engine +# $sync_slave +# master_node and slave_node connection should be defined + +--echo # $engine +--connection master_node +--eval create table t1(a int, b int) engine=$engine; +insert into t1 values(1,1); +insert into t1 values(2,2); +--echo # Normal Alter +alter table t1 add column c int; +show create table t1; +--echo # Failed Alter +insert into t1 values(1,1, NULL); +--error ER_DUP_ENTRY +alter table t1 change a a int unique; +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; + +# The following restriction should be removed post MDEV-26005 fix. +# TODO MDEV-26130 , should be removed after fixing +#if ($engine != 'aria') +#{ +#--eval create temporary table tmp_tbl(a int, b int) engine=$engine; +#insert into tmp_tbl values(1,1); +#insert into tmp_tbl values(2,2); +#--echo # Normal Alter +#alter table tmp_tbl add column c int; +#--echo # Failed Alter +#insert into tmp_tbl values(1,1, NULL); +#--error ER_DUP_ENTRY +#alter table tmp_tbl change a a int unique ; +#show create table tmp_tbl; +#} +if ($sync_slave) +{ + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + show create table t1; +} + +--connection master_node +drop table t1; +#if ($engine != 'aria') +#{ +#drop temporary table tmp_tbl; +#} +if ($sync_slave) +{ + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc +} diff --git a/mysql-test/suite/rpl/include/start_alter_concurrent.inc b/mysql-test/suite/rpl/include/start_alter_concurrent.inc new file mode 100644 index 00000000000..e5472152807 --- /dev/null +++ b/mysql-test/suite/rpl/include/start_alter_concurrent.inc @@ -0,0 +1,230 @@ +# +# ==== Purpose ==== +# +# Run concurrent split alter on given storage engine +# With concurrent 10 connections +# +# ==== Usage ==== +# +# --let $alter_engine= Engine Name (myisam , innodb ...) +# --let $alter_algorithm= ... +# --let $alter_online = [][ONLINE] +# --let $domain_1= +# --let $domain_2= +# --let $M_port= //Master port +# --let $S_port= //Slave port +# --let $sync_slave= // 0/1 whether to sync slave with master or not +# + + +--connection master_node +set global debug_dbug="+d,start_alter_delay_master"; + +--let $i= 1 +while($i < 11) +{ + if($i == 1 && $domain_1) + { + --eval set gtid_domain_id= $domain_1; + } + if($i == 6 && $domain_2) + { + --eval set gtid_domain_id= $domain_2; + } + --eval create table t$i( a int primary key, b int) engine=$alter_engine + --eval insert into t$i values(1,1),(2,2) + --inc $i +} + + +if ($sync_slave) +{ + --echo # Sync slave + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + --connection master_node +} + +--let $i= 1 +while($i < 21) +{ + if($i == 1 || $i == 11) + { + if($domain_1) + { + --eval set global gtid_domain_id= $domain_1; + } + } + if($i == 6 || $i == 16) + { + if($domain_2) + { + --eval set global gtid_domain_id= $domain_2; + } + } + connect(con$i,127.0.0.1,root,,$db_name, $M_port); + --inc $i +} + +--let $i= 1 +while($i < 11) +{ + --connection con$i + --send_eval alter $alter_online table t$i add column c int, force, algorithm=$alter_algorithm + --inc $i +} + +--connection master_node +set DEBUG_SYNC= "now signal alter_cont"; + +--let $i= 1 +while($i < 11) +{ + --connection con$i + --reap + --inc $i +} +--connection master_node +set DEBUG_SYNC= 'RESET'; + +if ($sync_slave) +{ + --echo # Sync slave + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + --connection master_node +} + + +--echo # Concurrent DML +--let $i= 1 +while($i < 11) +{ + --connection con$i + --send_eval alter table t$i add column d int, force, algorithm=$alter_algorithm + --inc $i +} + +if ($alter_algorithm == "inplace") +{ + --sleep 1 + --let $i= 11 + --let $j= 1 + while($i < 21) + { + --connection con$i + --send_eval insert into t$j values(5,5,5); + --inc $i + --inc $j + } + + --let $i= 11 + while($i < 21) + { + --connection con$i + --reap + --inc $i + } + + if ($sync_slave) + { + --echo # Sync slave + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + --connection master_node + } +} +--connection master_node +set DEBUG_SYNC= "now signal alter_cont"; +--let $i= 1 +while($i < 11) +{ + --connection con$i + --reap + --inc $i +} +--connection master_node +set DEBUG_SYNC= 'RESET'; + +if ($sync_slave) +{ + --echo # Sync slave + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + --connection master_node +} + + +--echo # Rollback tests +--let $i= 1 +while($i < 11) +{ + --connection con$i + --eval insert into t$i values(3,2,1,1) + --send_eval alter table t$i change b b int unique, force, algorithm=$alter_algorithm + --inc $i +} +--connection master_node +set DEBUG_SYNC= "now signal alter_cont"; + + +--let $i= 1 +while ($i < 11) +{ + --connection con$i + --error ER_DUP_ENTRY + --reap + --inc $i +} +--connection master_node +set DEBUG_SYNC= 'RESET'; + + +if ($sync_slave) +{ + --echo # Sync slave + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + --connection master_node +} + +if ($sync_slave) +{ + --enable_query_log + --echo # diff_table of master and slave , we will do only in the case when + --echo # sync_slave is on + --let $i= 1 + while($i < 11) + { + --let $diff_tables= master_node:t$i, slave_node:t$i + source include/diff_tables.inc; + --inc $i + } + --disable_query_log +} + +--connection master_node +drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; + +if ($sync_slave) +{ + --echo # Sync slave + --source include/save_master_gtid.inc + --connection slave_node + --source include/sync_with_master_gtid.inc + --connection master_node +} + +--let $i= 1 +while ($i < 21) +{ + --disconnect con$i + --inc $i +} +--connection master_node +SET GLOBAL debug_dbug= ""; diff --git a/mysql-test/suite/rpl/include/start_alter_include.inc b/mysql-test/suite/rpl/include/start_alter_include.inc new file mode 100644 index 00000000000..c66075c0164 --- /dev/null +++ b/mysql-test/suite/rpl/include/start_alter_include.inc @@ -0,0 +1,64 @@ +# +# ==== Purpose ==== +# +# Run concurrent split alter on different storage engine and with sync to given +# master +# +# ==== Usage ==== +# --let $domain_1= +# --let $domain_2= +# --let $M_port= //Master port +# --let $S_port= //Slave port +# --let $sync_slave= +# --let $db_name= +# + +connect(master_node,127.0.0.1,root,,$db_name, $M_port); +if (!$sync_slave) +{ + --eval set gtid_domain_id= $domain_1; +} +connect(slave_node,127.0.0.1,root,,test, $S_port); +if (!$sync_slave) +{ + --eval set gtid_domain_id= $domain_2; +} + +--let $engine=myisam +--source include/start_alter_basic.inc + +--let $engine=innodb +--source include/start_alter_basic.inc + +--let $engine=aria +--source include/start_alter_basic.inc + +--disable_query_log +--disable_warnings +--connection master_node +--echo # concurrent alter Myisam +--let $alter_engine=myisam +--let $alter_algorithm=copy +--source include/start_alter_concurrent.inc + +--connection master_node +--echo # concurrent alter Aria +--let $alter_engine=aria +--let $alter_algorithm=copy +--source include/start_alter_concurrent.inc + +--connection master_node +--echo # concurrent alter Innodb copy +--let $alter_engine=innodb +--let $alter_algorithm=copy +--source include/start_alter_concurrent.inc + +--connection master_node +--echo # concurrent alter Innodb Inplace +--let $alter_engine=innodb +--let $alter_algorithm=inplace +--source include/start_alter_concurrent.inc +--disconnect master_node +--disconnect slave_node +--enable_warnings +--enable_query_log diff --git a/mysql-test/suite/rpl/include/start_alter_options.inc b/mysql-test/suite/rpl/include/start_alter_options.inc new file mode 100644 index 00000000000..72c7104b114 --- /dev/null +++ b/mysql-test/suite/rpl/include/start_alter_options.inc @@ -0,0 +1,399 @@ +# This test will test all the option related to the Alter Table command +# NOTE not all alter statements will follow alter_algorithm since for some statements +# copy is only option +# parameters +# $alter_algorithm {DEFAULT|INPLACE|COPY|NOCOPY|INSTANT} +# $show_binlog +# +--let $force_needed= force , +# Error that is caused by a particular ALTER's option combination +--let $alter_error = 0 + +--connection slave +stop slave; +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +change master to master_use_gtid= current_pos; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +--connection master +set binlog_alter_two_phase=true; +create table t1(a int , b int) engine=innodb; +create table a1(a int , b int) engine=myisam; +create temporary table tmp_tbl(a int, b int) engine=innodb; + +# These are grammer rules for ALTER TABLE we will got through all alter table +# rules in this test. +# | ADD [COLUMN] [IF NOT EXISTS] col_name column_definition +# [FIRST | AFTER col_name ] +# | ADD [COLUMN] [IF NOT EXISTS] (col_name column_definition,...) +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column if not exists c int , $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column d int first, $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 add column e int after c, $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 add column f int after c, $force_needed add column g int first ,add column h char, algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, $force_needed algorithm=$alter_algorithm +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add column if not exists c int , $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl add column d int first, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl add column e int after c, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl add column f int after c, $force_needed add column g int first ,add column h char, algorithm=$alter_algorithm +--eval alter table tmp_tbl drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, $force_needed algorithm=$alter_algorithm +} +--echo # show binlog and clear status +--sync_slave_with_master +if ($show_binlog) +{ + --source include/show_binlog_events.inc +} +reset master; +--connection master + + +# +# | ADD {INDEX|KEY} [IF NOT EXISTS] [index_name] +# [index_type] (index_col_name,...) [index_option] ... +# | ADD [CONSTRAINT [symbol]] +# UNIQUE [INDEX|KEY] [index_name] +# [index_type] (index_col_name,...) [index_option] ... +# +# | ADD FULLTEXT [INDEX|KEY] [index_name] +# (index_col_name,...) [index_option] ... +# | DROP [COLUMN] [IF EXISTS] col_name [RESTRICT|CASCADE] +# | DROP PRIMARY KEY +# | DROP {INDEX|KEY} [IF EXISTS] index_name +# | DROP FOREIGN KEY [IF EXISTS] fk_symbol +# | DROP CONSTRAINT [IF EXISTS] constraint_name +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column f int after b, $force_needed add column g int first ,add column h varchar(100), algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST +} +--error 0,$alter_error +--eval alter table t1 add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop index index_1, $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST +} +--error 0,$alter_error +--eval alter table t1 add unique key unique_1(g), $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop index unique_1, $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST +} +--error 0,$alter_error +--eval alter table t1 add fulltext key f_1(h), $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column f, drop column g , $force_needed algorithm=$alter_algorithm +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add column f int after b, $force_needed add column g int first ,add column h varchar(100), algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST +} +--error 0,$alter_error +--eval alter table tmp_tbl add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl drop index index_1, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl add unique key unique_1(g), $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl drop index unique_1, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl drop column f, drop column g , $force_needed algorithm=$alter_algorithm +} +# | ADD [CONSTRAINT [symbol]] PRIMARY KEY +# [index_type] (index_col_name,...) [index_option] ... +# primary key changes cant use inplace algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST +} +--error 0,$alter_error +--eval alter table t1 add primary key(h), $force_needed algorithm=copy +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop primary key, $force_needed algorithm=copy +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column h, $force_needed algorithm=copy +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add primary key(h), $force_needed algorithm=copy +--eval alter table tmp_tbl drop primary key, $force_needed algorithm=copy +--eval alter table tmp_tbl drop column h, $force_needed algorithm=copy +} +--echo # show binlog and clear status +--sync_slave_with_master +if ($show_binlog) +{ + --source include/show_binlog_events.inc +} +reset master; +--connection master + +## NOTE force_needed and algorithm will not be used for system versioning +# | ADD PERIOD FOR SYSTEM_TIME (start_column_name, end_column_name) +# | ADD SYSTEM VERSIONING +# | DROP SYSTEM VERSIONING +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm +--eval alter table t1 add period for system_time(f,h) +--eval alter table t1 add system versioning +--eval alter table t1 drop system versioning +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column f, drop column g , drop column h, $force_needed algorithm=$alter_algorithm +--echo # show binlog and clear status +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add column f varchar(100) after b, add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl drop column f, drop column g , drop column h, $force_needed algorithm=$alter_algorithm +} +--sync_slave_with_master +if ($show_binlog) +{ + --source include/show_binlog_events.inc +} +reset master; +--connection master + + +# | ALTER [COLUMN] col_name SET DEFAULT literal | (expression) +# | ALTER [COLUMN] col_name DROP DEFAULT +# | CHANGE [COLUMN] [IF EXISTS] old_col_name new_col_name column_definition +# [FIRST|AFTER col_name] +# | MODIFY [COLUMN] [IF EXISTS] col_name column_definition +# [FIRST | AFTER col_name] +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm ; +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 alter column f set default "****", $force_needed algorithm=$alter_algorithm ; +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 alter column f drop default, $force_needed algorithm=$alter_algorithm ; +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 change column g new_g char, $force_needed algorithm=copy; +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 modify column h varchar(100), $force_needed algorithm=copy; +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column new_g ,drop column f, drop column h, $force_needed algorithm=$alter_algorithm ; +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm ; +--eval alter table tmp_tbl alter column f set default "****", $force_needed algorithm=$alter_algorithm ; +--eval alter table tmp_tbl alter column f drop default, $force_needed algorithm=$alter_algorithm ; +--eval alter table tmp_tbl change column g new_g char, $force_needed algorithm=copy; +--eval alter table tmp_tbl modify column h varchar(100), $force_needed algorithm=copy; +--eval alter table tmp_tbl drop column new_g ,drop column f, drop column h, $force_needed algorithm=$alter_algorithm ; +} +--echo # show binlog and clear status +--sync_slave_with_master +if ($show_binlog) +{ + --source include/show_binlog_events.inc +} +reset master; +--connection master + +# | DISABLE KEYS +# | ENABLE KEYS +# | RENAME [TO] new_tbl_name +# | ORDER BY col_name [, col_name] ... +# | RENAME COLUMN old_col_name TO new_col_name +# | RENAME {INDEX|KEY} old_index_name TO new_index_name +# | CONVERT TO CHARACTER SET charset_name [COLLATE collation_name] +# | [DEFAULT] CHARACTER SET [=] charset_name +# | [DEFAULT] COLLATE [=] collation_name +# | DISCARD TABLESPACE +# | IMPORT TABLESPACE +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST +} +--error 0,$alter_error +--eval alter table t1 add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm +--eval alter table t1 disable keys, $force_needed algorithm=copy +--eval alter table t1 enable keys, $force_needed algorithm=copy +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 rename t2, $force_needed algorithm=$alter_algorithm +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_NO_SUCH_TABLE +} +--error 0,$alter_error +--eval alter table t2 rename t1, $force_needed algorithm=$alter_algorithm +--eval alter table a1 order by a +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_BAD_FIELD_ERROR +} +--error 0,$alter_error +--eval alter table t1 rename column f to new_f, $force_needed algorithm=copy +--eval alter table t1 convert to character set 'utf8', $force_needed algorithm=copy +--eval alter table t1 default character set 'utf8', $force_needed algorithm=copy +--eval alter table t1 default collate 'utf8_icelandic_ci', $force_needed algorithm=copy +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column new_f ,drop column g, drop column h, $force_needed algorithm=$alter_algorithm +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl disable keys, $force_needed algorithm=copy +--eval alter table tmp_tbl enable keys, $force_needed algorithm=copy +--eval alter table a1 order by a +--eval alter table tmp_tbl rename column f to new_f, $force_needed algorithm=copy +--eval alter table tmp_tbl convert to character set 'utf8', $force_needed algorithm=copy +--eval alter table tmp_tbl default character set 'utf8', $force_needed algorithm=copy +--eval alter table tmp_tbl default collate 'utf8_icelandic_ci', $force_needed algorithm=copy +--eval alter table tmp_tbl drop column new_f ,drop column g, drop column h, $force_needed algorithm=$alter_algorithm +} +##--eval alter table t1 discard tablespace; +######--eval alter table t1 import tablespace; + +--echo # show binlog and clear status +--sync_slave_with_master +if ($show_binlog) +{ + --source include/show_binlog_events.inc +} +reset master; +--connection master + +# Only add partition and remove partition is tested +# | ADD PARTITION (partition_definition) +# | REMOVE PARTITIONING +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED +} +--error 0,$alter_error +--eval alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm +--eval alter table t1 partition by hash(b) partitions 8 +--eval alter table t1 remove partitioning +if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`) +{ + --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY +} +--error 0,$alter_error +--eval alter table t1 drop column f ,drop column g, drop column h, $force_needed algorithm=$alter_algorithm +if ($alter_algorithm == 'copy') +{ +--eval alter table tmp_tbl add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm +--eval alter table tmp_tbl drop column f ,drop column g, drop column h, $force_needed algorithm=$alter_algorithm +} +--echo # show binlog and clear status +--sync_slave_with_master +if ($show_binlog) +{ + --source include/show_binlog_events.inc +} +reset master; +--connection master + +# clean master/slave +--connection master +drop table t1, a1; +drop temporary table tmp_tbl; +--sync_slave_with_master +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +--source include/start_slave.inc diff --git a/mysql-test/suite/rpl/r/rpl_alter_rollback.result b/mysql-test/suite/rpl/r/rpl_alter_rollback.result new file mode 100644 index 00000000000..3bd91a516c4 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_alter_rollback.result @@ -0,0 +1,54 @@ +# +# Test verifies that "ROLLBACK ALTER" is written to binary log upon +#ALTER command execution failure. +# +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +create table t1 (f1 int primary key) engine=InnoDB; +create table t2 (f1 int primary key, +constraint c1 foreign key (f1) references t1(f1), +constraint c1 foreign key (f1) references t1(f1)) engine=InnoDB; +ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +create table t2 (f1 int primary key, +constraint c1 foreign key (f1) references t1(f1)) engine=innodb; +alter table t2 add constraint c1 foreign key (f1) references t1(f1); +ERROR HY000: Can't create table `test`.`t2` (errno: 121 "Duplicate key on write or update") +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t1 (f1 int primary key) engine=InnoDB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t2 (f1 int primary key, +constraint c1 foreign key (f1) references t1(f1)) engine=innodb +master-bin.000001 # Gtid # # GTID #-#-# START ALTER +master-bin.000001 # Query # # use `test`; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +master-bin.000001 # Gtid # # GTID #-#-# ROLLBACK ALTER id=# +master-bin.000001 # Query # # use `test`; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +set foreign_key_checks = 0; +alter table t2 add constraint c1 foreign key (f1) references t1(f1); +ERROR HY000: Duplicate FOREIGN KEY constraint name 'test/c1' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t1 (f1 int primary key) engine=InnoDB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t2 (f1 int primary key, +constraint c1 foreign key (f1) references t1(f1)) engine=innodb +master-bin.000001 # Gtid # # GTID #-#-# START ALTER +master-bin.000001 # Query # # use `test`; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +master-bin.000001 # Gtid # # GTID #-#-# ROLLBACK ALTER id=# +master-bin.000001 # Query # # use `test`; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +master-bin.000001 # Gtid # # GTID #-#-# START ALTER +master-bin.000001 # Query # # use `test`; set foreign_key_checks=1; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +master-bin.000001 # Gtid # # GTID #-#-# ROLLBACK ALTER id=# +master-bin.000001 # Query # # use `test`; set foreign_key_checks=1; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +connection slave; +connection master; +drop table t2, t1; +connection slave; +connection master; +set global binlog_alter_two_phase=0;; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result b/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result index 54156685806..4c35d42d90a 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result @@ -3,6 +3,7 @@ include/master-slave.inc *** Test that we check against incorrect table definition for mysql.gtid_slave_pos *** connection master; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +call mtr.add_suppression("Incorrect definition of table mysql.gtid_slave_pos:.*"); connection slave; connection slave; include/stop_slave.inc @@ -83,16 +84,16 @@ ERROR 25000: You are not allowed to execute this command in a transaction ROLLBACK; SET GLOBAL gtid_strict_mode= 1; SET GLOBAL gtid_slave_pos = "0-1-1"; -ERROR HY000: Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos +ERROR HY000: Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos SET GLOBAL gtid_slave_pos = ""; -ERROR HY000: Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos +ERROR HY000: Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos SET GLOBAL gtid_strict_mode= 0; SET GLOBAL gtid_slave_pos = "0-1-1"; Warnings: -Warning 1947 Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos +Warning 1947 Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos SET GLOBAL gtid_slave_pos = ""; Warnings: -Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos +Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos RESET MASTER; SET GLOBAL gtid_slave_pos = "0-1-1"; START SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_1.result b/mysql-test/suite/rpl/r/rpl_start_alter_1.result new file mode 100644 index 00000000000..9edb23216fe --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_1.result @@ -0,0 +1,313 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection slave; +set global gtid_strict_mode=1; +# Legacy Master Slave +connect master_node,127.0.0.1,root,,$db_name, $M_port; +connect slave_node,127.0.0.1,root,,test, $S_port; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# concurrent alter Myisam +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Aria +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb copy +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb Inplace +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +connection master; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +set global gtid_strict_mode = 0;; +connection master; +set global binlog_alter_two_phase=0;; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_2.result b/mysql-test/suite/rpl/r/rpl_start_alter_2.result new file mode 100644 index 00000000000..a862fc5556a --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_2.result @@ -0,0 +1,326 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection slave; +set global gtid_strict_mode=1; +connection slave; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +include/start_slave.inc +# Parallel Slave +connection master; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +connect slave_node,127.0.0.1,root,,test, $S_port; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# concurrent alter Myisam +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Aria +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb copy +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb Inplace +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +connection master; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# cleanup +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global gtid_domain_id= 0; +include/start_slave.inc +connection master; +set global binlog_alter_two_phase=0;; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_3.result b/mysql-test/suite/rpl/r/rpl_start_alter_3.result new file mode 100644 index 00000000000..97754401471 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_3.result @@ -0,0 +1,326 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection slave; +set global gtid_strict_mode=1; +connection slave; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +include/start_slave.inc +# Parallel Slave +connection master; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +connect slave_node,127.0.0.1,root,,test, $S_port; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# concurrent alter Myisam +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Aria +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb copy +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb Inplace +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +connection master; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# cleanup +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global gtid_domain_id= 0; +include/start_slave.inc +connection master; +set global binlog_alter_two_phase=0;; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_4.result b/mysql-test/suite/rpl/r/rpl_start_alter_4.result new file mode 100644 index 00000000000..9d7d6376bba --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_4.result @@ -0,0 +1,327 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection slave; +set global gtid_strict_mode=1; +connection slave; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +include/start_slave.inc +# Parallel Slave +connection master; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +connect slave_node,127.0.0.1,root,,test, $S_port; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# concurrent alter Myisam +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Aria +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb copy +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb Inplace +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +connection master; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# cleanup +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global gtid_domain_id= 0; +include/start_slave.inc +connection master; +set global binlog_alter_two_phase=0;; +set global gtid_domain_id= 0; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_5.result b/mysql-test/suite/rpl/r/rpl_start_alter_5.result new file mode 100644 index 00000000000..4e592c1931f --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_5.result @@ -0,0 +1,327 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection slave; +set global gtid_strict_mode=1; +connection slave; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +include/start_slave.inc +# Parallel Slave +connection master; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +connect slave_node,127.0.0.1,root,,test, $S_port; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# concurrent alter Myisam +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Aria +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb copy +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb Inplace +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +connection master; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# cleanup +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global gtid_domain_id= 0; +include/start_slave.inc +connection master; +set global binlog_alter_two_phase=0;; +set global gtid_domain_id= 0; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_6.result b/mysql-test/suite/rpl/r/rpl_start_alter_6.result new file mode 100644 index 00000000000..6c26d511ee2 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_6.result @@ -0,0 +1,329 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection slave; +set global gtid_strict_mode=1; +connection slave; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +set global slave_domain_parallel_threads=3; +change master to master_use_gtid=slave_pos; +include/start_slave.inc +# Parallel Slave +connection master; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +connect slave_node,127.0.0.1,root,,test, $S_port; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +# concurrent alter Myisam +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Aria +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb copy +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# concurrent alter Innodb Inplace +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Concurrent DML +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +# diff_table of master and slave , we will do only in the case when +# sync_slave is on +include/diff_tables.inc [master_node:t1, slave_node:t1] +include/diff_tables.inc [master_node:t2, slave_node:t2] +include/diff_tables.inc [master_node:t3, slave_node:t3] +include/diff_tables.inc [master_node:t4, slave_node:t4] +include/diff_tables.inc [master_node:t5, slave_node:t5] +include/diff_tables.inc [master_node:t6, slave_node:t6] +include/diff_tables.inc [master_node:t7, slave_node:t7] +include/diff_tables.inc [master_node:t8, slave_node:t8] +include/diff_tables.inc [master_node:t9, slave_node:t9] +include/diff_tables.inc [master_node:t10, slave_node:t10] +# Sync slave +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +connection master; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# cleanup +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global slave_domain_parallel_threads = 0;; +set global gtid_domain_id= 0; +include/start_slave.inc +connection master; +set global binlog_alter_two_phase=0;; +set global gtid_domain_id= 0; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_7.result b/mysql-test/suite/rpl/r/rpl_start_alter_7.result new file mode 100644 index 00000000000..cfe31497179 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_7.result @@ -0,0 +1,368 @@ +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +connection server_1; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection server_2; +stop slave; +Warnings: +Note 1255 Slave already has been stopped +set global binlog_alter_two_phase=true; +connection server_3; +SET GLOBAL slave_parallel_threads=8; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +connection server_1; +set gtid_domain_id= 11; +create database s1; +use s1; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 11;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 11;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection server_1; +drop database s1; +select @@gtid_binlog_pos; +@@gtid_binlog_pos +11-1-412 +connection server_2; +set gtid_domain_id= 12; +create database s2; +use s2; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 12;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 12;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection server_2; +drop database s2; +select @@gtid_binlog_pos; +@@gtid_binlog_pos +12-2-412 +connection server_3; +start all slaves; +Warnings: +Note 1937 SLAVE 'm2' started +Note 1937 SLAVE 'm1' started +set default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm1'; +include/sync_with_master_gtid.inc +set default_master_connection = 'm2'; +include/sync_with_master_gtid.inc +# cleanup +connection server_3; +set default_master_connection = 'm1'; +include/stop_slave.inc +set default_master_connection = 'm2'; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global gtid_domain_id= 0; +reset master; +RESET SLAVE ALL; +SET GLOBAL gtid_slave_pos= ''; +connection server_1; +set global binlog_alter_two_phase=0;; +set global gtid_domain_id= 0; +reset master; +connection server_2; +set global gtid_domain_id= 0; +set global binlog_alter_two_phase=0; +reset master; +disconnect server_1; +disconnect server_2; +disconnect server_3; diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_8.result b/mysql-test/suite/rpl/r/rpl_start_alter_8.result new file mode 100644 index 00000000000..8002f295f5c --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_8.result @@ -0,0 +1,362 @@ +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +connection server_1; +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +connection server_2; +stop slave; +Warnings: +Note 1255 Slave already has been stopped +set global binlog_alter_two_phase=true; +connection server_3; +SET GLOBAL slave_parallel_threads=20; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +connection server_1; +set gtid_domain_id= 11; +create database s1; +use s1; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 11;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 11;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection server_1; +drop database s1; +connection server_2; +set gtid_domain_id= 12; +create database s2; +use s2; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 12;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 12;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection server_2; +drop database s2; +connection server_3; +start all slaves; +Warnings: +Note 1937 SLAVE 'm2' started +Note 1937 SLAVE 'm1' started +set default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm1'; +include/sync_with_master_gtid.inc +set default_master_connection = 'm2'; +include/sync_with_master_gtid.inc +# cleanup +connection server_3; +set default_master_connection = 'm1'; +include/stop_slave.inc +set default_master_connection = 'm2'; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set global gtid_domain_id= 0; +reset master; +RESET SLAVE ALL; +SET GLOBAL gtid_slave_pos= ''; +connection server_1; +set global binlog_alter_two_phase=0;; +set global gtid_domain_id= 0; +reset master; +connection server_2; +set global gtid_domain_id= 0; +set global binlog_alter_two_phase=0;; +reset master; +disconnect server_1; +disconnect server_2; +disconnect server_3; diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_bugs.result b/mysql-test/suite/rpl/r/rpl_start_alter_bugs.result new file mode 100644 index 00000000000..3fb3df27afd --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_bugs.result @@ -0,0 +1,33 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase=true; +connection slave; +stop slave; +SET global slave_parallel_threads=2; +set global slave_parallel_mode=optimistic; +start slave; +connection master; +CREATE TABLE t1 (i int primary key) ENGINE = InnoDB; +connection master1; +ALTER TABLE t1 DROP PRIMARY KEY; +ALTER TABLE t1 ADD UNIQUE KEY ui (i); +ALTER TABLE t1 ADD PRIMARY KEY (i); +connection slave; +connection master; +drop table t1; +CREATE TABLE t1 (a int)engine=innodb; +ALTER TABLE t1 add column b int, LOCK=EXCLUSIVE; +drop table t1; +CREATE TABLE t1 (pk int)engine=innodb; +ALTER TABLE t1 DROP FOREIGN KEY y, LOCK=EXCLUSIVE; +ERROR 42000: Can't DROP FOREIGN KEY `y`; check that it exists +drop table t1; +connection slave; +connection master; +set global binlog_alter_two_phase=false; +connection slave; +include/stop_slave.inc +SET global slave_parallel_threads=0; +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_chain_basic.result b/mysql-test/suite/rpl/r/rpl_start_alter_chain_basic.result new file mode 100644 index 00000000000..b6c28458561 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_chain_basic.result @@ -0,0 +1,83 @@ +include/rpl_init.inc [topology=1->2->3->4] +connection server_3; +set global gtid_strict_mode=1; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +include/start_slave.inc +connection server_1; +set global binlog_alter_two_phase=ON; +set binlog_alter_two_phase=ON; +connect master_node,127.0.0.1,root,,$db_name, $SERVER_MYPORT_1; +connect slave_node,127.0.0.1,root,,test, $SERVER_MYPORT_2; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +include/save_master_gtid.inc +connection slave_node; +include/sync_with_master_gtid.inc +disconnect master_node; +disconnect slave_node; +connection server_1; +set global binlog_alter_two_phase=0; +include/rpl_sync.inc +connection server_2; +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +domain_id seq_no +0 12 +connection server_3; +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +domain_id seq_no +0 12 +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +include/start_slave.inc +select @@slave_parallel_threads; +@@slave_parallel_threads +0 +connection server_4; +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +domain_id seq_no +0 12 +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_ftwrl.result b/mysql-test/suite/rpl/r/rpl_start_alter_ftwrl.result new file mode 100644 index 00000000000..4f22c2a1f5f --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_ftwrl.result @@ -0,0 +1,60 @@ +include/master-slave.inc +[connection master] +connection slave; +include/stop_slave.inc +SET @@global.slave_parallel_threads=4; +SET @@global.slave_parallel_mode=optimistic; +CHANGE MASTER TO master_use_gtid=slave_pos; +SET @@global.debug_dbug="+d,at_write_start_alter"; +include/start_slave.inc +connection master; +SET @@session.binlog_alter_two_phase=true; +CREATE TABLE t1 (a INT) ENGINE=innodb; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +connection master; +SET @@session.alter_algorithm='INSTANT'; +SET @@session.gtid_domain_id=11; +ALTER TABLE t1 ADD COLUMN b int; +# START Alter having exclusive lock is waiting for the signal +connection slave; +# FTWRL is sent first to wait for SA +connection slave1; +FLUSH TABLES WITH READ LOCK; +# SA completes +connection slave; +set DEBUG_SYNC= "now signal alter_cont"; +connection slave1; +connection slave; +# Release CA +connection slave1; +UNLOCK TABLES; +connection master; +connection slave; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Gtid # # GTID #-#-# +slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT) ENGINE=innodb +slave-bin.000001 # Gtid # # GTID #-#-# START ALTER +slave-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN b int +slave-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=# +slave-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN b int +connection master; +DROP TABLE t1; +connection slave; +# cleanup +connection slave; +set DEBUG_SYNC = RESET; +include/stop_slave.inc +set global slave_parallel_threads = 0; +set global slave_parallel_mode = optimistic; +set @@global.debug_dbug = ""; +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_instant.result b/mysql-test/suite/rpl/r/rpl_start_alter_instant.result new file mode 100644 index 00000000000..17aaad81aa4 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_instant.result @@ -0,0 +1,66 @@ +include/master-slave.inc +[connection master] +connection master; +set binlog_alter_two_phase=true; +CREATE OR REPLACE TABLE tab ( +a int PRIMARY KEY, +b varchar(50), +c varchar(50) +) CHARACTER SET=latin1 engine=innodb; +SET SESSION alter_algorithm='INSTANT'; +ALTER TABLE tab MODIFY COLUMN b varchar(100); +SET SESSION alter_algorithm='NOCOPY'; +ALTER TABLE tab MODIFY COLUMN c varchar(100); +SHOW CREATE TABLE tab; +Table Create Table +tab CREATE TABLE `tab` ( + `a` int(11) NOT NULL, + `b` varchar(100) DEFAULT NULL, + `c` varchar(100) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE tab ( +a int PRIMARY KEY, +b varchar(50), +c varchar(50) +) CHARACTER SET=latin1 engine=innodb +master-bin.000001 # Gtid # # GTID #-#-# START ALTER +master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100) +master-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=# +master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100) +master-bin.000001 # Gtid # # GTID #-#-# START ALTER +master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100) +master-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=# +master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100) +connection slave; +SHOW CREATE TABLE tab; +Table Create Table +tab CREATE TABLE `tab` ( + `a` int(11) NOT NULL, + `b` varchar(100) DEFAULT NULL, + `c` varchar(100) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Gtid # # GTID #-#-# +slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE tab ( +a int PRIMARY KEY, +b varchar(50), +c varchar(50) +) CHARACTER SET=latin1 engine=innodb +slave-bin.000001 # Gtid # # GTID #-#-# START ALTER +slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100) +slave-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=# +slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100) +slave-bin.000001 # Gtid # # GTID #-#-# START ALTER +slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100) +slave-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=# +slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100) +connection master; +DROP TABLE tab; +connection slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_mysqlbinlog_1.result b/mysql-test/suite/rpl/r/rpl_start_alter_mysqlbinlog_1.result new file mode 100644 index 00000000000..e008bbc81a7 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_mysqlbinlog_1.result @@ -0,0 +1,172 @@ +include/master-slave.inc +[connection master] +connection master; +set global binlog_alter_two_phase=true; +connection slave; +include/stop_slave.inc +change master to master_use_gtid= current_pos; +set global gtid_strict_mode=1; +# Legacy Master Slave +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 0;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 0;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection master; +select @@gtid_binlog_state; +@@gtid_binlog_state +0-1-410 +RESET master; +connection slave; +select @@gtid_binlog_state; +@@gtid_binlog_state +0-1-410 +set global gtid_strict_mode=0; +include/start_slave.inc +connection master; +set global binlog_alter_two_phase=false; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_mysqlbinlog_2.result b/mysql-test/suite/rpl/r/rpl_start_alter_mysqlbinlog_2.result new file mode 100644 index 00000000000..2c1ae667fd6 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_mysqlbinlog_2.result @@ -0,0 +1,419 @@ +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +connection server_1; +SET @save_binlog_alter_two_phase= @@GLOBAL.binlog_alter_two_phase; +SET GLOBAL binlog_alter_two_phase = ON; +SET binlog_alter_two_phase = ON; +# Create table and perform CA and RA +CREATE TABLE t1( a INT, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1,1); +INSERT INTO t1 VALUES(2,2); +# Normal Alter +ALTER TABLE t1 ADD COLUMN c INT; +# Failed Alter +INSERT INTO t1 VALUES(1,1, NULL); +ALTER TABLE t1 CHANGE a a INT UNIQUE; +ERROR 23000: Duplicate entry '1' for key 'a' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +0-1-8 +# apply the binlog +DROP TABLE t1; +# reset the binlog +RESET MASTER; +# execute the binlog +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +0-1-8 +# Same as before +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +# reset the binlog +RESET MASTER; +RESET SLAVE; +connection server_2; +SET @save_binlog_alter_two_phase= @@GLOBAL.binlog_alter_two_phase; +SET GLOBAL binlog_alter_two_phase = ON; +connection server_3; +SET @save_gtid_strict_mode= @@GLOBAL.gtid_strict_mode; +SET @slave_parallel_threads= @@GLOBAL.slave_parallel_threads; +SET @slave_parallel_mode= @@GLOBAL.slave_parallel_mode; +SET GLOBAL slave_parallel_threads=20; +SET GLOBAL slave_parallel_mode=optimistic; +SET GLOBAL gtid_strict_mode=1; +connection server_1; +SET gtid_domain_id= 11; +CREATE DATABASE s1; +USE s1; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 11;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 11;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection server_1; +DROP DATABASE s1; +connection server_2; +SET gtid_domain_id= 12; +CREATE DATABASE s2; +USE s2; +connect master_node,127.0.0.1,root,,$db_name, $M_port; +set gtid_domain_id= 12;; +connect slave_node,127.0.0.1,root,,test, $S_port; +set gtid_domain_id= 12;; +# myisam +connection master_node; +create table t1(a int, b int) engine=myisam;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# innodb +connection master_node; +create table t1(a int, b int) engine=innodb;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master_node; +drop table t1; +# aria +connection master_node; +create table t1(a int, b int) engine=aria;; +insert into t1 values(1,1); +insert into t1 values(2,2); +# Normal Alter +alter table t1 add column c int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +# Failed Alter +insert into t1 values(1,1, NULL); +alter table t1 change a a int unique; +ERROR 23000: Duplicate entry '1' for key 'a' +set @@session.binlog_alter_two_phase = 0; +alter table t1 change a a int; +set @@session.binlog_alter_two_phase = 1; +alter table t1 change a a int; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +connection master_node; +drop table t1; +# concurrent alter Myisam +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Aria +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb copy +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +# concurrent alter Innodb Inplace +# Concurrent DML +# Rollback tests +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +ERROR 23000: Duplicate entry '2' for key 'b' +connection server_2; +DROP DATABASE s2; +connection server_3; +START ALL SLAVES; +Warnings: +Note 1937 SLAVE 'm2' started +Note 1937 SLAVE 'm1' started +SET default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +SET default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +SET default_master_connection = 'm1'; +include/sync_with_master_gtid.inc +SET default_master_connection = 'm2'; +include/sync_with_master_gtid.inc +# Stop slaves and apply binlog +connection server_3; +SET default_master_connection = 'm1'; +include/stop_slave.inc +SET default_master_connection = 'm2'; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads = @slave_parallel_threads; +SET GLOBAL slave_parallel_mode = @slave_parallel_mode; +SET GLOBAL gtid_strict_mode = @save_gtid_strict_mode; +SET GLOBAL gtid_domain_id= 0; +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +11-1-412,12-2-412 +# reset the binlog +RESET MASTER; +# execute the binlog +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +11-1-412,12-2-412 +# One more time to simulate S->S case +RESET MASTER; +# execute the binlog +SELECT @@gtid_binlog_state; +@@gtid_binlog_state +11-1-412,12-2-412 +RESET MASTER; +RESET SLAVE ALL; +SET GLOBAL gtid_slave_pos= ''; +connection server_1; +SET GLOBAL binlog_alter_two_phase=@save_binlog_alter_two_phase; +SET GLOBAL gtid_domain_id= 0; +RESET MASTER; +connection server_2; +SET GLOBAL gtid_domain_id= 0; +SET GLOBAL binlog_alter_two_phase=@save_binlog_alter_two_phase; +RESET MASTER; +disconnect server_1; +disconnect server_2; +disconnect server_3; diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_optimize.result b/mysql-test/suite/rpl/r/rpl_start_alter_optimize.result new file mode 100644 index 00000000000..24f016e93a0 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_optimize.result @@ -0,0 +1,18 @@ +include/master-slave.inc +[connection master] +connection master; +set binlog_alter_two_phase = ON; +connection master; +CREATE TABLE t1 (i int) engine=innodb; +CREATE TABLE t2 (i int) engine=innodb; +ALTER TABLE t1 DROP CONSTRAINT IF EXISTS y; +Warnings: +Note 1091 Can't DROP CONSTRAINT `y`; check that it exists +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +connection slave; +connection master; +drop table t1,t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_options.result b/mysql-test/suite/rpl/r/rpl_start_alter_options.result new file mode 100644 index 00000000000..30854b12be1 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_options.result @@ -0,0 +1,497 @@ +include/master-slave.inc +[connection master] +connection slave; +stop slave; +change master to master_use_gtid= current_pos; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +connection master; +set binlog_alter_two_phase=true; +create table t1(a int , b int) engine=innodb; +create table a1(a int , b int) engine=myisam; +create temporary table tmp_tbl(a int, b int) engine=innodb; +alter table t1 add column if not exists c int , force , algorithm=default; +alter table t1 add column d int first, force , algorithm=default; +alter table t1 add column e int after c, force , algorithm=default; +alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=default; +alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=default; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=default; +alter table t1 add index if not exists index_1(f), force , algorithm=default; +alter table t1 drop index index_1, force , algorithm=default; +alter table t1 add unique key unique_1(g), force , algorithm=default; +alter table t1 drop index unique_1, force , algorithm=default; +alter table t1 add fulltext key f_1(h), force , algorithm=default; +alter table t1 drop column f, drop column g , force , algorithm=default; +alter table t1 add primary key(h), force , algorithm=copy; +alter table t1 drop primary key, force , algorithm=copy; +alter table t1 drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=default; +alter table t1 add period for system_time(f,h); +alter table t1 add system versioning; +alter table t1 drop system versioning; +alter table t1 drop column f, drop column g , drop column h, force , algorithm=default; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=default ;; +alter table t1 alter column f set default "****", force , algorithm=default ;; +alter table t1 alter column f drop default, force , algorithm=default ;; +alter table t1 change column g new_g char, force , algorithm=copy;; +alter table t1 modify column h varchar(100), force , algorithm=copy;; +alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=default ;; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=default; +alter table t1 add index if not exists index_1(f), force , algorithm=default; +alter table t1 disable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 enable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 rename t2, force , algorithm=default; +alter table t2 rename t1, force , algorithm=default; +alter table a1 order by a; +alter table t1 rename column f to new_f, force , algorithm=copy; +alter table t1 convert to character set 'utf8', force , algorithm=copy; +alter table t1 default character set 'utf8', force , algorithm=copy; +alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy; +alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=default; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=default; +alter table t1 partition by hash(b) partitions 8; +alter table t1 remove partitioning; +alter table t1 drop column f ,drop column g, drop column h, force , algorithm=default; +# show binlog and clear status +connection slave; +reset master; +connection master; +connection master; +drop table t1, a1; +drop temporary table tmp_tbl; +connection slave; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +include/start_slave.inc +connection slave; +stop slave; +change master to master_use_gtid= current_pos; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +connection master; +set binlog_alter_two_phase=true; +create table t1(a int , b int) engine=innodb; +create table a1(a int , b int) engine=myisam; +create temporary table tmp_tbl(a int, b int) engine=innodb; +alter table t1 add column if not exists c int , force , algorithm=inplace; +alter table t1 add column d int first, force , algorithm=inplace; +alter table t1 add column e int after c, force , algorithm=inplace; +alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=inplace; +alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=inplace; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=inplace; +alter table t1 add index if not exists index_1(f), force , algorithm=inplace; +alter table t1 drop index index_1, force , algorithm=inplace; +alter table t1 add unique key unique_1(g), force , algorithm=inplace; +alter table t1 drop index unique_1, force , algorithm=inplace; +alter table t1 add fulltext key f_1(h), force , algorithm=inplace; +alter table t1 drop column f, drop column g , force , algorithm=inplace; +alter table t1 add primary key(h), force , algorithm=copy; +alter table t1 drop primary key, force , algorithm=copy; +alter table t1 drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=inplace; +alter table t1 add period for system_time(f,h); +alter table t1 add system versioning; +alter table t1 drop system versioning; +alter table t1 drop column f, drop column g , drop column h, force , algorithm=inplace; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=inplace ;; +alter table t1 alter column f set default "****", force , algorithm=inplace ;; +alter table t1 alter column f drop default, force , algorithm=inplace ;; +alter table t1 change column g new_g char, force , algorithm=copy;; +alter table t1 modify column h varchar(100), force , algorithm=copy;; +alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=inplace ;; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=inplace; +alter table t1 add index if not exists index_1(f), force , algorithm=inplace; +alter table t1 disable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 enable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 rename t2, force , algorithm=inplace; +alter table t2 rename t1, force , algorithm=inplace; +alter table a1 order by a; +alter table t1 rename column f to new_f, force , algorithm=copy; +alter table t1 convert to character set 'utf8', force , algorithm=copy; +alter table t1 default character set 'utf8', force , algorithm=copy; +alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy; +alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=inplace; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=inplace; +alter table t1 partition by hash(b) partitions 8; +alter table t1 remove partitioning; +alter table t1 drop column f ,drop column g, drop column h, force , algorithm=inplace; +# show binlog and clear status +connection slave; +reset master; +connection master; +connection master; +drop table t1, a1; +drop temporary table tmp_tbl; +connection slave; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +include/start_slave.inc +connection slave; +stop slave; +change master to master_use_gtid= current_pos; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +connection master; +set binlog_alter_two_phase=true; +create table t1(a int , b int) engine=innodb; +create table a1(a int , b int) engine=myisam; +create temporary table tmp_tbl(a int, b int) engine=innodb; +alter table t1 add column if not exists c int , force , algorithm=copy; +alter table t1 add column d int first, force , algorithm=copy; +alter table t1 add column e int after c, force , algorithm=copy; +alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=copy; +alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=copy; +alter table tmp_tbl add column if not exists c int , force , algorithm=copy; +alter table tmp_tbl add column d int first, force , algorithm=copy; +alter table tmp_tbl add column e int after c, force , algorithm=copy; +alter table tmp_tbl add column f int after c, force , add column g int first ,add column h char, algorithm=copy; +alter table tmp_tbl drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=copy; +alter table t1 add index if not exists index_1(f), force , algorithm=copy; +alter table t1 drop index index_1, force , algorithm=copy; +alter table t1 add unique key unique_1(g), force , algorithm=copy; +alter table t1 drop index unique_1, force , algorithm=copy; +alter table t1 add fulltext key f_1(h), force , algorithm=copy; +alter table t1 drop column f, drop column g , force , algorithm=copy; +alter table tmp_tbl add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=copy; +alter table tmp_tbl add index if not exists index_1(f), force , algorithm=copy; +alter table tmp_tbl drop index index_1, force , algorithm=copy; +alter table tmp_tbl add unique key unique_1(g), force , algorithm=copy; +alter table tmp_tbl drop index unique_1, force , algorithm=copy; +alter table tmp_tbl drop column f, drop column g , force , algorithm=copy; +alter table t1 add primary key(h), force , algorithm=copy; +alter table t1 drop primary key, force , algorithm=copy; +alter table t1 drop column h, force , algorithm=copy; +alter table tmp_tbl add primary key(h), force , algorithm=copy; +alter table tmp_tbl drop primary key, force , algorithm=copy; +alter table tmp_tbl drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=copy; +alter table t1 add period for system_time(f,h); +alter table t1 add system versioning; +alter table t1 drop system versioning; +alter table t1 drop column f, drop column g , drop column h, force , algorithm=copy; +# show binlog and clear status +alter table tmp_tbl add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=copy; +alter table tmp_tbl drop column f, drop column g , drop column h, force , algorithm=copy; +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=copy ;; +alter table t1 alter column f set default "****", force , algorithm=copy ;; +alter table t1 alter column f drop default, force , algorithm=copy ;; +alter table t1 change column g new_g char, force , algorithm=copy;; +alter table t1 modify column h varchar(100), force , algorithm=copy;; +alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=copy ;; +alter table tmp_tbl add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=copy ;; +alter table tmp_tbl alter column f set default "****", force , algorithm=copy ;; +alter table tmp_tbl alter column f drop default, force , algorithm=copy ;; +alter table tmp_tbl change column g new_g char, force , algorithm=copy;; +alter table tmp_tbl modify column h varchar(100), force , algorithm=copy;; +alter table tmp_tbl drop column new_g ,drop column f, drop column h, force , algorithm=copy ;; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=copy; +alter table t1 add index if not exists index_1(f), force , algorithm=copy; +alter table t1 disable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 enable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 rename t2, force , algorithm=copy; +alter table t2 rename t1, force , algorithm=copy; +alter table a1 order by a; +alter table t1 rename column f to new_f, force , algorithm=copy; +alter table t1 convert to character set 'utf8', force , algorithm=copy; +alter table t1 default character set 'utf8', force , algorithm=copy; +alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy; +alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=copy; +alter table tmp_tbl add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=copy; +alter table tmp_tbl add index if not exists index_1(f), force , algorithm=copy; +alter table tmp_tbl disable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`tmp_tbl` doesn't have this option +alter table tmp_tbl enable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`tmp_tbl` doesn't have this option +alter table a1 order by a; +alter table tmp_tbl rename column f to new_f, force , algorithm=copy; +alter table tmp_tbl convert to character set 'utf8', force , algorithm=copy; +alter table tmp_tbl default character set 'utf8', force , algorithm=copy; +alter table tmp_tbl default collate 'utf8_icelandic_ci', force , algorithm=copy; +alter table tmp_tbl drop column new_f ,drop column g, drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=copy; +alter table t1 partition by hash(b) partitions 8; +alter table t1 remove partitioning; +alter table t1 drop column f ,drop column g, drop column h, force , algorithm=copy; +alter table tmp_tbl add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=copy; +alter table tmp_tbl drop column f ,drop column g, drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +connection master; +drop table t1, a1; +drop temporary table tmp_tbl; +connection slave; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +include/start_slave.inc +# Prove formal support for nocopy and instant +connection slave; +stop slave; +change master to master_use_gtid= current_pos; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +connection master; +set binlog_alter_two_phase=true; +create table t1(a int , b int) engine=innodb; +create table a1(a int , b int) engine=myisam; +create temporary table tmp_tbl(a int, b int) engine=innodb; +alter table t1 add column if not exists c int , force , algorithm=instant; +alter table t1 add column d int first, force , algorithm=instant; +alter table t1 add column e int after c, force , algorithm=instant; +alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=instant; +alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=instant; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=instant; +alter table t1 add index if not exists index_1(f), force , algorithm=instant; +alter table t1 drop index index_1, force , algorithm=instant; +alter table t1 add unique key unique_1(g), force , algorithm=instant; +alter table t1 drop index unique_1, force , algorithm=instant; +alter table t1 add fulltext key f_1(h), force , algorithm=instant; +alter table t1 drop column f, drop column g , force , algorithm=instant; +alter table t1 add primary key(h), force , algorithm=copy; +alter table t1 drop primary key, force , algorithm=copy; +alter table t1 drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=instant; +alter table t1 add period for system_time(f,h); +alter table t1 add system versioning; +alter table t1 drop system versioning; +alter table t1 drop column f, drop column g , drop column h, force , algorithm=instant; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=instant ;; +alter table t1 alter column f set default "****", force , algorithm=instant ;; +alter table t1 alter column f drop default, force , algorithm=instant ;; +alter table t1 change column g new_g char, force , algorithm=copy;; +alter table t1 modify column h varchar(100), force , algorithm=copy;; +alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=instant ;; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=instant; +alter table t1 add index if not exists index_1(f), force , algorithm=instant; +alter table t1 disable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 enable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 rename t2, force , algorithm=instant; +alter table t2 rename t1, force , algorithm=instant; +alter table a1 order by a; +alter table t1 rename column f to new_f, force , algorithm=copy; +alter table t1 convert to character set 'utf8', force , algorithm=copy; +alter table t1 default character set 'utf8', force , algorithm=copy; +alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy; +alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=instant; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=instant; +alter table t1 partition by hash(b) partitions 8; +alter table t1 remove partitioning; +alter table t1 drop column f ,drop column g, drop column h, force , algorithm=instant; +# show binlog and clear status +connection slave; +reset master; +connection master; +connection master; +drop table t1, a1; +drop temporary table tmp_tbl; +connection slave; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +include/start_slave.inc +connection slave; +stop slave; +change master to master_use_gtid= current_pos; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +connection master; +set binlog_alter_two_phase=true; +create table t1(a int , b int) engine=innodb; +create table a1(a int , b int) engine=myisam; +create temporary table tmp_tbl(a int, b int) engine=innodb; +alter table t1 add column if not exists c int , force , algorithm=nocopy; +alter table t1 add column d int first, force , algorithm=nocopy; +alter table t1 add column e int after c, force , algorithm=nocopy; +alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=nocopy; +alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=nocopy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=nocopy; +alter table t1 add index if not exists index_1(f), force , algorithm=nocopy; +alter table t1 drop index index_1, force , algorithm=nocopy; +alter table t1 add unique key unique_1(g), force , algorithm=nocopy; +alter table t1 drop index unique_1, force , algorithm=nocopy; +alter table t1 add fulltext key f_1(h), force , algorithm=nocopy; +alter table t1 drop column f, drop column g , force , algorithm=nocopy; +alter table t1 add primary key(h), force , algorithm=copy; +alter table t1 drop primary key, force , algorithm=copy; +alter table t1 drop column h, force , algorithm=copy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=nocopy; +alter table t1 add period for system_time(f,h); +alter table t1 add system versioning; +alter table t1 drop system versioning; +alter table t1 drop column f, drop column g , drop column h, force , algorithm=nocopy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=nocopy ;; +alter table t1 alter column f set default "****", force , algorithm=nocopy ;; +alter table t1 alter column f drop default, force , algorithm=nocopy ;; +alter table t1 change column g new_g char, force , algorithm=copy;; +alter table t1 modify column h varchar(100), force , algorithm=copy;; +alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=nocopy ;; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=nocopy; +alter table t1 add index if not exists index_1(f), force , algorithm=nocopy; +alter table t1 disable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 enable keys, force , algorithm=copy; +Warnings: +Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option +alter table t1 rename t2, force , algorithm=nocopy; +alter table t2 rename t1, force , algorithm=nocopy; +alter table a1 order by a; +alter table t1 rename column f to new_f, force , algorithm=copy; +alter table t1 convert to character set 'utf8', force , algorithm=copy; +alter table t1 default character set 'utf8', force , algorithm=copy; +alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy; +alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=nocopy; +# show binlog and clear status +connection slave; +reset master; +connection master; +alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=nocopy; +alter table t1 partition by hash(b) partitions 8; +alter table t1 remove partitioning; +alter table t1 drop column f ,drop column g, drop column h, force , algorithm=nocopy; +# show binlog and clear status +connection slave; +reset master; +connection master; +connection master; +drop table t1, a1; +drop temporary table tmp_tbl; +connection slave; +include/stop_slave.inc +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result b/mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result new file mode 100644 index 00000000000..d93ec724372 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result @@ -0,0 +1,14 @@ +include/master-slave.inc +[connection master] +connection master; +CREATE TABLE t1 (a1 int, d1 int DEFAULT 0); +INSERT INTO t1 VALUES (1,1) ; +SET binlog_alter_two_phase = ON; +ALTER TABLE t1 WAIT 9 RENAME COLUMN a1 TO a2; +SET binlog_alter_two_phase = OFF; +ALTER TABLE t1 ALTER COLUMN d1 DROP DEFAULT; +connection slave; +connection master; +drop table t1; +connection slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_restart_master.result b/mysql-test/suite/rpl/r/rpl_start_alter_restart_master.result new file mode 100644 index 00000000000..a2aba33aee0 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_restart_master.result @@ -0,0 +1,85 @@ +include/master-slave.inc +[connection master] +connection slave; +SET @old_debug_slave= @@global.debug; +stop slave; +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; +connection master; +call mtr.add_suppression("ALTER query started at .+ could not be completed"); +SET @old_debug_master= @@global.debug; +set binlog_alter_two_phase=true; +create table t3( a int primary key, b int) engine=innodb; +connection master; +connection slave; +include/stop_slave.inc +connection master; +SET SESSION debug_dbug="d,start_alter_kill_after_binlog"; +alter table t3 add column d int; +ERROR HY000: Lost connection to server during query +include/rpl_reconnect.inc +set binlog_alter_two_phase= true; +alter table t3 add column d int; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int(11) NOT NULL, + `b` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'ALTER query started at .+ could not be completed' COLLATE 'latin1_swedish_ci')) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t3( a int primary key, b int) engine=innodb +master-bin.000001 # Gtid # # GTID #-#-# START ALTER +master-bin.000001 # Query # # use `test`; alter table t3 add column d int +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid # # GTID #-#-# START ALTER +master-bin.000002 # Query # # use `test`; alter table t3 add column d int +master-bin.000002 # Gtid # # GTID #-#-# COMMIT ALTER id=# +master-bin.000002 # Query # # use `test`; alter table t3 add column d int +connection slave; +include/start_slave.inc +connection master; +connection slave; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Gtid # # BEGIN GTID #-#-# +slave-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'ALTER query started at .+ could not be completed' COLLATE 'latin1_swedish_ci')) +slave-bin.000001 # Query # # COMMIT +slave-bin.000001 # Gtid # # GTID #-#-# +slave-bin.000001 # Query # # use `test`; create table t3( a int primary key, b int) engine=innodb +slave-bin.000001 # Gtid # # GTID #-#-# START ALTER +slave-bin.000001 # Query # # use `test`; alter table t3 add column d int +slave-bin.000001 # Gtid # # GTID #-#-# START ALTER +slave-bin.000001 # Query # # use `test`; alter table t3 add column d int +slave-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=# +slave-bin.000001 # Query # # use `test`; alter table t3 add column d int +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int(11) NOT NULL, + `b` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection master; +SET GLOBAL debug_dbug= @old_debug_master; +drop table t3; +set global binlog_alter_two_phase = 0; +connection slave; +SET GLOBAL debug_dbug= @old_debug_slave; +stop slave; +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +start slave; +connection master; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result b/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result new file mode 100644 index 00000000000..0a1c1f7971e --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_start_alter_restart_slave.result @@ -0,0 +1,119 @@ +include/master-slave.inc +[connection master] +connection slave; +SET @old_debug_slave= @@global.debug; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +set global debug_dbug="+d,rpl_slave_stop_CA_before_binlog"; +include/start_slave.inc +connection master; +SET @old_debug_master= @@global.debug; +set global debug_dbug="+d,start_alter_delay_master"; +set global binlog_alter_two_phase=true; +create table t1( a int primary key, b int) engine=myisam; +create table t2( a int primary key, b int) engine=myisam; +connect con1,localhost,root,,; +alter table t1 add column c int;; +connection master; +# Get into binlog first and wait +# master gtid state is 0-1-3 +connect con2,localhost,root,,; +alter table t2 add column c int;; +connection master; +# Get into binlog next and wait as well +# master gtid state is 0-1-4 +set DEBUG_SYNC= "now signal alter_cont"; +connection con1; +connection con2; +create table t3( a int primary key, b int) engine=innodb; +# master gtid state is 0-1-7 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid_list 1 # [] +master-bin.000001 # Binlog_checkpoint 1 # master-bin.000001 +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; create table t1( a int primary key, b int) engine=myisam +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; create table t2( a int primary key, b int) engine=myisam +master-bin.000001 # Gtid 1 # GTID #-#-# START ALTER +master-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +master-bin.000001 # Gtid 1 # GTID #-#-# START ALTER +master-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +master-bin.000001 # Gtid 1 # GTID #-#-# COMMIT ALTER id=<seq_no> +master-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +master-bin.000001 # Gtid 1 # GTID #-#-# COMMIT ALTER id=<seq_no> +master-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +master-bin.000001 # Gtid 1 # GTID #-#-# +master-bin.000001 # Query 1 # use `test`; create table t3( a int primary key, b int) engine=innodb +# Stop Slave +# As master binlog is SA SA CA CA +# let's stop at first CA processing (in process_commit_alter) +connection slave; +include/sync_with_master_gtid.inc +connect extra_slave,127.0.0.1,root,,test,$SLAVE_MYPORT; +stop slave;; +connection slave; +connection extra_slave; +SET GLOBAL debug_dbug= @old_debug_slave; +connection slave; +include/wait_for_slave_sql_to_stop.inc +# The list of events after the slave has stopped must have just one CA: +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Gtid_list 2 # [] +slave-bin.000001 # Binlog_checkpoint 2 # slave-bin.000001 +slave-bin.000001 # Gtid 1 # GTID #-#-# +slave-bin.000001 # Query 1 # use `test`; create table t1( a int primary key, b int) engine=myisam +slave-bin.000001 # Gtid 1 # GTID #-#-# +slave-bin.000001 # Query 1 # use `test`; create table t2( a int primary key, b int) engine=myisam +slave-bin.000001 # Gtid 1 # GTID #-#-# START ALTER +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +slave-bin.000001 # Gtid 1 # GTID #-#-# START ALTER +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +slave-bin.000001 # Gtid 1 # GTID #-#-# COMMIT ALTER id=<seq_no> +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +domain_id seq_no +0 5 +include/start_slave.inc +connection master; +connection slave; +# Everything from the master binlog must have been applied now: +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +domain_id seq_no +0 7 +# slave gtid state is 0-1-7 +# The list of events after the slave has synchronized must have both CA: +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Gtid_list 2 # [] +slave-bin.000001 # Binlog_checkpoint 2 # slave-bin.000001 +slave-bin.000001 # Gtid 1 # GTID #-#-# +slave-bin.000001 # Query 1 # use `test`; create table t1( a int primary key, b int) engine=myisam +slave-bin.000001 # Gtid 1 # GTID #-#-# +slave-bin.000001 # Query 1 # use `test`; create table t2( a int primary key, b int) engine=myisam +slave-bin.000001 # Gtid 1 # GTID #-#-# START ALTER +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +slave-bin.000001 # Gtid 1 # GTID #-#-# START ALTER +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +slave-bin.000001 # Gtid 1 # GTID #-#-# COMMIT ALTER id=<seq_no> +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +slave-bin.000001 # Gtid 1 # GTID #-#-# COMMIT ALTER id=<seq_no> +slave-bin.000001 # Query 1 # use `test`; alter table <t> add column c int +slave-bin.000001 # Gtid 1 # GTID #-#-# +slave-bin.000001 # Query 1 # use `test`; create table t3( a int primary key, b int) engine=innodb +connection master; +drop table t1,t2,t3; +set global binlog_alter_two_phase = 0; +SET GLOBAL debug_dbug= @old_debug_master; +set DEBUG_SYNC= 'RESET'; +connection slave; +stop slave; +set global slave_parallel_threads = 0;; +set global slave_parallel_mode = optimistic;; +set global gtid_strict_mode = 0;; +set DEBUG_SYNC= 'RESET'; +start slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_alter_rollback.test b/mysql-test/suite/rpl/t/rpl_alter_rollback.test new file mode 100644 index 00000000000..c24f01ff007 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_alter_rollback.test @@ -0,0 +1,42 @@ +# +# MENT-662: Lag Free Alter On Slave +# + +--echo # +--echo # Test verifies that "ROLLBACK ALTER" is written to binary log upon +--echo #ALTER command execution failure. +--echo # +--source include/have_innodb.inc +--source include/master-slave.inc + +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +create table t1 (f1 int primary key) engine=InnoDB; +--error ER_CANT_CREATE_TABLE +create table t2 (f1 int primary key, +constraint c1 foreign key (f1) references t1(f1), +constraint c1 foreign key (f1) references t1(f1)) engine=InnoDB; +create table t2 (f1 int primary key, + constraint c1 foreign key (f1) references t1(f1)) engine=innodb; + +--error ER_CANT_CREATE_TABLE +alter table t2 add constraint c1 foreign key (f1) references t1(f1); +--source include/show_binlog_events.inc + +set foreign_key_checks = 0; +--error ER_DUP_CONSTRAINT_NAME +alter table t2 add constraint c1 foreign key (f1) references t1(f1); +--source include/show_binlog_events.inc +--sync_slave_with_master + +--connection master +drop table t2, t1; +--sync_slave_with_master + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_blackhole_row_annotate.test b/mysql-test/suite/rpl/t/rpl_blackhole_row_annotate.test index 07fc1e558cb..f7aefd625a1 100644 --- a/mysql-test/suite/rpl/t/rpl_blackhole_row_annotate.test +++ b/mysql-test/suite/rpl/t/rpl_blackhole_row_annotate.test @@ -44,6 +44,6 @@ FLUSH LOGS; let $MYSQLD_DATADIR= `select @@datadir`; --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /CRC32 0x[0-9a-f]*/CRC32 XXX/ /xid=\d*/xid=<xid>/ ---exec $MYSQL_BINLOG --base64-output=decode-rows $MYSQLD_DATADIR/slave-bin.000001 +--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-gtid-strict-mode $MYSQLD_DATADIR/slave-bin.000001 source include/rpl_end.inc; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test b/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test index c02e2670c92..412489b3ee3 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test @@ -5,6 +5,7 @@ --echo *** Test that we check against incorrect table definition for mysql.gtid_slave_pos *** --connection master CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +call mtr.add_suppression("Incorrect definition of table mysql.gtid_slave_pos:.*"); --sync_slave_with_master --connection slave diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_1.test b/mysql-test/suite/rpl/t/rpl_start_alter_1.test new file mode 100644 index 00000000000..9ce061f1031 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_1.test @@ -0,0 +1,33 @@ +# +# Start Alter with Legacy Replication +# +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/master-slave.inc + +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +--connection slave +--let $gtid_strict_mode= `select @@gtid_strict_mode` +set global gtid_strict_mode=1; + +--echo # Legacy Master Slave +--let $domain_1=0 +--let $domain_2=0 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=1 + +--source include/start_alter_include.inc +--connection master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc +--eval set global gtid_strict_mode = $gtid_strict_mode; + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_2.test b/mysql-test/suite/rpl/t/rpl_start_alter_2.test new file mode 100644 index 00000000000..457409c51a6 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_2.test @@ -0,0 +1,53 @@ +# +# Start Alter with Parallel Replication +# 1 domain id +# |Concurrent alters| < |Parallel workers on slave| +# |x| denotes number of entities it encloses +# +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/master-slave.inc +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +--connection slave +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +set global gtid_strict_mode=1; + + +--connection slave +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + +--echo # Parallel Slave +--connection master +--let $master_server= "master" +--let $domain_1=0 +--let $domain_2=0 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=1 +--source include/start_alter_include.inc +--connection master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set global gtid_domain_id= 0; +--source include/start_slave.inc + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_3.test b/mysql-test/suite/rpl/t/rpl_start_alter_3.test new file mode 100644 index 00000000000..b280aeb9e5e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_3.test @@ -0,0 +1,54 @@ +# +# Start Alter with Parallel Replication +# 1 domain id +# |Concurrent alters| >= |Parallel workers on slave| +# |x| denotes number of entities it encloses +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/have_debug.inc +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +--connection slave +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +set global gtid_strict_mode=1; + + +--connection slave +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + +--echo # Parallel Slave +--connection master +--let $master_server= "master" +--let $domain_1=0 +--let $domain_2=0 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=1 +--source include/start_alter_include.inc +--connection master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set global gtid_domain_id= 0; +--source include/start_slave.inc + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_4.test b/mysql-test/suite/rpl/t/rpl_start_alter_4.test new file mode 100644 index 00000000000..8c67b50a7bf --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_4.test @@ -0,0 +1,54 @@ +# +# Start Alter with Parallel Replication +# 2 domain id +# |Concurrent alters| < |Parallel workers on slave| +# |x| denotes number of entities it encloses +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/have_debug.inc +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +--connection slave +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +set global gtid_strict_mode=1; + +--connection slave +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + +--echo # Parallel Slave +--connection master +--let $master_server= "master" +--let $domain_1=11 +--let $domain_2=12 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=1 +--source include/start_alter_include.inc +--connection master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set global gtid_domain_id= 0; +--source include/start_slave.inc + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +set global gtid_domain_id= 0; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_5.test b/mysql-test/suite/rpl/t/rpl_start_alter_5.test new file mode 100644 index 00000000000..10d0d523a68 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_5.test @@ -0,0 +1,54 @@ +# +# Start Alter with Parallel Replication +# 2 domain id +# |Concurrent alters| >= |Parallel workers on slave| +# |x| denotes number of entities it encloses +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/have_debug.inc +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +--connection slave +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +set global gtid_strict_mode=1; + +--connection slave +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + +--echo # Parallel Slave +--connection master +--let $master_server= "master" +--let $domain_1=11 +--let $domain_2=12 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=1 +--source include/start_alter_include.inc +--connection master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set global gtid_domain_id= 0; +--source include/start_slave.inc + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +set global gtid_domain_id= 0; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_6.test b/mysql-test/suite/rpl/t/rpl_start_alter_6.test new file mode 100644 index 00000000000..fc49ea4a406 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_6.test @@ -0,0 +1,58 @@ +# +# Start Alter with Parallel Replication +# 2 domain id +# |Concurrent alters| < |Parallel workers on slave| +# |x| denotes number of entities it encloses +# slave_domain_parallel_threads < |Concurrent Alters| +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/have_debug.inc +--connection master +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; +--connection slave +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +--let $slave_domain_parallel_threads= `select @@slave_domain_parallel_threads` +set global gtid_strict_mode=1; + +--connection slave +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +set global slave_domain_parallel_threads=3; +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + +--echo # Parallel Slave +--connection master +--let $master_server= "master" +--let $domain_1=11 +--let $domain_2=12 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=1 +--source include/start_alter_include.inc +--connection master +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +--eval set global slave_domain_parallel_threads = $slave_domain_parallel_threads; +set global gtid_domain_id= 0; +--source include/start_slave.inc + +--connection master +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +set global gtid_domain_id= 0; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_7.cnf b/mysql-test/suite/rpl/t/rpl_start_alter_7.cnf new file mode 100644 index 00000000000..a0f6dc5710c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_7.cnf @@ -0,0 +1,19 @@ +!include ../my.cnf + +[mysqld.1] +log-bin +log-slave-updates + +[mysqld.2] +log-bin +log-slave-updates + +[mysqld.3] +log-bin +log-slave-updates + + +[ENV] +SERVER_MYPORT_1= @mysqld.1.port +SERVER_MYPORT_2= @mysqld.2.port +SERVER_MYPORT_3= @mysqld.3.port diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_7.test b/mysql-test/suite/rpl/t/rpl_start_alter_7.test new file mode 100644 index 00000000000..7225c075ea7 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_7.test @@ -0,0 +1,112 @@ +# +# Start Alter with Parallel Replication, With 2 sources +# 2 domain id (From 2 sources) +# |Concurrent alters| >= |Parallel workers on slave| +# |x| denotes number of entities it encloses +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--connection server_1 +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +--connection server_2 +stop slave; +set global binlog_alter_two_phase=true; + +--connection server_3 +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +SET GLOBAL slave_parallel_threads=8; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; + + +--disable_warnings +--disable_query_log +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--enable_query_log +--enable_warnings + +--connection server_1 +set gtid_domain_id= 11; +create database s1; +use s1; +--let $domain_1=11 +--let $domain_2=11 +--let $M_port= $SERVER_MYPORT_1 +--let $S_port= $SERVER_MYPORT_3 +--let $sync_slave=0 +--let $db_name=s1 +--source include/start_alter_include.inc +--connection server_1 +drop database s1; +select @@gtid_binlog_pos; +--let $master_pos_1= `SELECT @@gtid_binlog_pos` + +--connection server_2 +set gtid_domain_id= 12; +create database s2; +use s2; +--let $domain_1=12 +--let $domain_2=12 +--let $M_port= $SERVER_MYPORT_2 +--let $S_port= $SERVER_MYPORT_3 +--let $sync_slave=0 +--let $db_name=s2 +--source include/start_alter_include.inc +--connection server_2 +drop database s2; +select @@gtid_binlog_pos; +--let $master_pos_2= `SELECT @@gtid_binlog_pos` + +--connection server_3 +start all slaves; +set default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc + +set default_master_connection = 'm1'; +--let $master_pos= $master_pos_1 +--source include/sync_with_master_gtid.inc +set default_master_connection = 'm2'; +--let $master_pos= $master_pos_2 +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--connection server_3 +set default_master_connection = 'm1'; +--source include/stop_slave.inc +set default_master_connection = 'm2'; +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set global gtid_domain_id= 0; +reset master; +RESET SLAVE ALL; +SET GLOBAL gtid_slave_pos= ''; + +--connection server_1 +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +set global gtid_domain_id= 0; +reset master; +--connection server_2 +set global gtid_domain_id= 0; +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase +reset master; + +--disconnect server_1 +--disconnect server_2 +--disconnect server_3 diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_8.cnf b/mysql-test/suite/rpl/t/rpl_start_alter_8.cnf new file mode 100644 index 00000000000..a0f6dc5710c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_8.cnf @@ -0,0 +1,19 @@ +!include ../my.cnf + +[mysqld.1] +log-bin +log-slave-updates + +[mysqld.2] +log-bin +log-slave-updates + +[mysqld.3] +log-bin +log-slave-updates + + +[ENV] +SERVER_MYPORT_1= @mysqld.1.port +SERVER_MYPORT_2= @mysqld.2.port +SERVER_MYPORT_3= @mysqld.3.port diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_8.test b/mysql-test/suite/rpl/t/rpl_start_alter_8.test new file mode 100644 index 00000000000..4ab8e2b01e5 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_8.test @@ -0,0 +1,109 @@ +# +# Start Alter with Parallel Replication, With 2 sources +# 2 domain id (From 2 sources) +# |Concurrent alters| < |Parallel workers on slave| +# |x| denotes number of entities it encloses +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--connection server_1 +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase = ON; +set binlog_alter_two_phase = ON; + +--connection server_2 +stop slave; +set global binlog_alter_two_phase=true; + +--connection server_3 +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +SET GLOBAL slave_parallel_threads=20; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; + +--disable_warnings +--disable_query_log +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--enable_query_log +--enable_warnings + +--connection server_1 +set gtid_domain_id= 11; +create database s1; +use s1; +--let $domain_1=11 +--let $domain_2=11 +--let $M_port= $SERVER_MYPORT_1 +--let $S_port= $SERVER_MYPORT_3 +--let $sync_slave=0 +--let $db_name=s1 +--source include/start_alter_include.inc +--connection server_1 +drop database s1; +--let $master_pos_1= `SELECT @@gtid_binlog_pos` + +--connection server_2 +set gtid_domain_id= 12; +create database s2; +use s2; +--let $domain_1=12 +--let $domain_2=12 +--let $M_port= $SERVER_MYPORT_2 +--let $S_port= $SERVER_MYPORT_3 +--let $sync_slave=0 +--let $db_name=s2 +--source include/start_alter_include.inc +--connection server_2 +drop database s2; +--let $master_pos_2= `SELECT @@gtid_binlog_pos` + +--connection server_3 +start all slaves; +set default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc + +set default_master_connection = 'm1'; +--let $master_pos= $master_pos_1 +--source include/sync_with_master_gtid.inc +set default_master_connection = 'm2'; +--let $master_pos= $master_pos_2 +--source include/sync_with_master_gtid.inc + +--echo # cleanup +--connection server_3 +set default_master_connection = 'm1'; +--source include/stop_slave.inc +set default_master_connection = 'm2'; +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set global gtid_domain_id= 0; +reset master; +RESET SLAVE ALL; +SET GLOBAL gtid_slave_pos= ''; + +--connection server_1 +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +set global gtid_domain_id= 0; +reset master; +--connection server_2 +set global gtid_domain_id= 0; +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase; +reset master; + +--disconnect server_1 +--disconnect server_2 +--disconnect server_3 diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_bugs.test b/mysql-test/suite/rpl/t/rpl_start_alter_bugs.test new file mode 100644 index 00000000000..52eef9fbb16 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_bugs.test @@ -0,0 +1,47 @@ +# +# MDEV-22985 Assertion `!(thd->rgi_slave && thd->rgi_slave->did_mark_start_commit)' failed in ha_rollback_trans# +# +# + +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--connection master +set global binlog_alter_two_phase=true; + +--connection slave +stop slave; +SET global slave_parallel_threads=2; +set global slave_parallel_mode=optimistic; +start slave; +--connection master + +CREATE TABLE t1 (i int primary key) ENGINE = InnoDB; +--connection master1 +ALTER TABLE t1 DROP PRIMARY KEY; +ALTER TABLE t1 ADD UNIQUE KEY ui (i); +ALTER TABLE t1 ADD PRIMARY KEY (i); + +--sync_slave_with_master + + #MENT 1274 +--connection master +drop table t1; +CREATE TABLE t1 (a int)engine=innodb; +ALTER TABLE t1 add column b int, LOCK=EXCLUSIVE; +drop table t1; +CREATE TABLE t1 (pk int)engine=innodb; +--error ER_CANT_DROP_FIELD_OR_KEY +ALTER TABLE t1 DROP FOREIGN KEY y, LOCK=EXCLUSIVE; +drop table t1; +--sync_slave_with_master +--connection master +set global binlog_alter_two_phase=false; + +--connection slave +--source include/stop_slave.inc +SET global slave_parallel_threads=0; +--source include/start_slave.inc + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_chain_basic.cnf b/mysql-test/suite/rpl/t/rpl_start_alter_chain_basic.cnf new file mode 100644 index 00000000000..498d8ed1096 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_chain_basic.cnf @@ -0,0 +1,24 @@ +!include ../my.cnf + +[mysqld.1] +log-slave-updates +loose-innodb + +[mysqld.2] +log-slave-updates +loose-innodb + +[mysqld.3] +log-slave-updates +binlog_alter_two_phase=1 +loose-innodb + +[mysqld.4] +loose-innodb + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket + +SERVER_MYPORT_4= @mysqld.4.port +SERVER_MYSOCK_4= @mysqld.4.socket diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_chain_basic.test b/mysql-test/suite/rpl/t/rpl_start_alter_chain_basic.test new file mode 100644 index 00000000000..2c6f9c0fd72 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_chain_basic.test @@ -0,0 +1,54 @@ +# +# MENT-662 Lag Free alter for slave +# In this we will see if chain replication works as +# M->S(Legacy)->S(Parallel)->S(Legacy, without log-slave-upadates) +# +--source include/have_innodb.inc +--let $rpl_topology=1->2->3->4 +--source include/rpl_init.inc + +--connection server_3 +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +set global gtid_strict_mode=1; + +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=10; +set global slave_parallel_mode=optimistic; +change master to master_use_gtid=slave_pos; +--source include/start_slave.inc + + +--connection server_1 +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase=ON; +set binlog_alter_two_phase=ON; +--let $engine=innodb +--let $sync_slave= 1 +connect(master_node,127.0.0.1,root,,$db_name, $SERVER_MYPORT_1); +connect(slave_node,127.0.0.1,root,,test, $SERVER_MYPORT_2); +--source include/start_alter_basic.inc +--disconnect master_node +--disconnect slave_node +--connection server_1 +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase +--source include/rpl_sync.inc + + +--connection server_2 +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; + +--connection server_3 +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +--source include/start_slave.inc +select @@slave_parallel_threads; + +--connection server_4 +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_ftwrl.test b/mysql-test/suite/rpl/t/rpl_start_alter_ftwrl.test new file mode 100644 index 00000000000..a8528cc6197 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_ftwrl.test @@ -0,0 +1,91 @@ +# +# MDEV-11675 Two phase ALTER binlogging +# +# Prove that FTWRL in the middle of START and "COMPLETE" parts of ALTER +# is safe. + +--source include/have_debug.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--connection slave +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +--let $debug = `SELECT @@global.debug_dbug` + +--source include/stop_slave.inc + +SET @@global.slave_parallel_threads=4; +SET @@global.slave_parallel_mode=optimistic; +CHANGE MASTER TO master_use_gtid=slave_pos; + +SET @@global.debug_dbug="+d,at_write_start_alter"; +--source include/start_slave.inc + +--connection master +SET @@session.binlog_alter_two_phase=true; + +CREATE TABLE t1 (a INT) ENGINE=innodb; +--source include/save_master_gtid.inc + +# Make sure the table exists on slave now. +--connection slave +--source include/sync_with_master_gtid.inc + +--connection master +SET @@session.alter_algorithm='INSTANT'; +SET @@session.gtid_domain_id=11; +ALTER TABLE t1 ADD COLUMN b int; + + +--echo # START Alter having exclusive lock is waiting for the signal +--connection slave +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now' +--source include/wait_condition.inc + +--echo # FTWRL is sent first to wait for SA +--connection slave1 +--send FLUSH TABLES WITH READ LOCK + +--echo # SA completes +# First wait for the FTWRL arrival. +--connection slave +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'FLUSH TABLES WITH READ LOCK' and STATE = 'Waiting for worker threads to pause for global read lock' +--source include/wait_condition.inc + +set DEBUG_SYNC= "now signal alter_cont"; + +--connection slave1 +--reap + +# Commit ALTER is hanging now +--connection slave +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND = 'Slave_worker' AND STATE = 'Waiting for backup lock' +--source include/wait_condition.inc + +--echo # Release CA +--connection slave1 +UNLOCK TABLES; + +--connection master +--sync_slave_with_master + +SHOW CREATE TABLE t1; +--source include/show_binlog_events.inc + +--connection master +DROP TABLE t1; + +--sync_slave_with_master + +--echo # cleanup +--connection slave +set DEBUG_SYNC = RESET; +--source include/stop_slave.inc +--eval set global slave_parallel_threads = $slave_parallel_threads +--eval set global slave_parallel_mode = $slave_parallel_mode +--eval set @@global.debug_dbug = "$debug" +--source include/start_slave.inc + + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_instant.test b/mysql-test/suite/rpl/t/rpl_start_alter_instant.test new file mode 100644 index 00000000000..ecb62e04fad --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_instant.test @@ -0,0 +1,30 @@ +# MDEV-11675 +# Prove that "fast" ALTER options also combine with @@binlog_alter_two_phase. +--source include/have_innodb.inc +--source include/master-slave.inc + +--connection master +set binlog_alter_two_phase=true; +CREATE OR REPLACE TABLE tab ( + a int PRIMARY KEY, + b varchar(50), + c varchar(50) +) CHARACTER SET=latin1 engine=innodb; + +SET SESSION alter_algorithm='INSTANT'; +ALTER TABLE tab MODIFY COLUMN b varchar(100); +SET SESSION alter_algorithm='NOCOPY'; +ALTER TABLE tab MODIFY COLUMN c varchar(100); +SHOW CREATE TABLE tab; +--source include/show_binlog_events.inc + +--sync_slave_with_master +SHOW CREATE TABLE tab; +--source include/show_binlog_events.inc + +--connection master +DROP TABLE tab; + +--sync_slave_with_master + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_1.test b/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_1.test new file mode 100644 index 00000000000..5c78eb290c8 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_1.test @@ -0,0 +1,39 @@ +# +# Start Alter with binlog applied using mysqlbinlog +# single maser with only one domain id +# +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/master-slave.inc + +--connection master +set global binlog_alter_two_phase=true; +--connection slave +--source include/stop_slave.inc +change master to master_use_gtid= current_pos; +set global gtid_strict_mode=1; + +--echo # Legacy Master Slave +--let $domain_1=0 +--let $domain_2=0 +--let $M_port= $MASTER_MYPORT +--let $S_port= $SLAVE_MYPORT +--let $sync_slave=0 + +--source include/start_alter_include.inc +--connection master +--let $MYSQLD_DATADIR= `select @@datadir;` +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql +select @@gtid_binlog_state; +RESET master; + +--connection slave +--exec $MYSQL --host=127.0.0.1 --port=$SLAVE_MYPORT -e "source $MYSQLTEST_VARDIR/tmp/master.sql" +select @@gtid_binlog_state; +set global gtid_strict_mode=0; +--source include/start_slave.inc + +--connection master +set global binlog_alter_two_phase=false; +remove_file $MYSQLTEST_VARDIR/tmp/master.sql; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_2.cnf b/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_2.cnf new file mode 100644 index 00000000000..a0f6dc5710c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_2.cnf @@ -0,0 +1,19 @@ +!include ../my.cnf + +[mysqld.1] +log-bin +log-slave-updates + +[mysqld.2] +log-bin +log-slave-updates + +[mysqld.3] +log-bin +log-slave-updates + + +[ENV] +SERVER_MYPORT_1= @mysqld.1.port +SERVER_MYPORT_2= @mysqld.2.port +SERVER_MYPORT_3= @mysqld.3.port diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_2.test b/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_2.test new file mode 100644 index 00000000000..c7d5bd66e2b --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_mysqlbinlog_2.test @@ -0,0 +1,164 @@ +# +# MENT-662 Lag Free Alter On Slave +# + +# Start Alter with Parallel Replication, With 2 sources +# 2 domain id (From 2 sources) +# |Concurrent alters| < |Parallel workers on slave| +# |x| denotes number of entities it encloses +# And then binary log from slave is replayed to slave again to check if +# binlog output is okay. +# + +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--connection server_1 +SET @save_binlog_alter_two_phase= @@GLOBAL.binlog_alter_two_phase; +SET GLOBAL binlog_alter_two_phase = ON; +SET binlog_alter_two_phase = ON; +--echo # Create table and perform CA and RA +CREATE TABLE t1( a INT, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1,1); +INSERT INTO t1 VALUES(2,2); +--echo # Normal Alter +ALTER TABLE t1 ADD COLUMN c INT; +--echo # Failed Alter +INSERT INTO t1 VALUES(1,1, NULL); +--error ER_DUP_ENTRY +ALTER TABLE t1 CHANGE a a INT UNIQUE; +SHOW CREATE TABLE t1; +SELECT @@gtid_binlog_state; + +--echo # apply the binlog +let MYSQLD_DATADIR= `select @@datadir;`; +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master_1.sql +DROP TABLE t1; +--echo # reset the binlog +RESET MASTER; + +--echo # execute the binlog +--exec $MYSQL --port=$SERVER_MYPORT_1 --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/master_1.sql" +SELECT @@gtid_binlog_state; +--echo # Same as before +SHOW CREATE TABLE t1; +DROP TABLE t1; +--echo # reset the binlog +RESET MASTER; +RESET SLAVE; +remove_file $MYSQLTEST_VARDIR/tmp/master_1.sql; + +--connection server_2 +SET @save_binlog_alter_two_phase= @@GLOBAL.binlog_alter_two_phase; +SET GLOBAL binlog_alter_two_phase = ON; + +--connection server_3 +SET @save_gtid_strict_mode= @@GLOBAL.gtid_strict_mode; +SET @slave_parallel_threads= @@GLOBAL.slave_parallel_threads; +SET @slave_parallel_mode= @@GLOBAL.slave_parallel_mode; +SET GLOBAL slave_parallel_threads=20; +SET GLOBAL slave_parallel_mode=optimistic; +SET GLOBAL gtid_strict_mode=1; + +--disable_warnings +--disable_query_log +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'm1' TO MASTER_PORT=$SERVER_MYPORT_1, MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_USE_GTID=slave_pos; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'm2' TO MASTER_PORT=$SERVER_MYPORT_2, MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_USE_GTID=slave_pos; +--enable_query_log +--enable_warnings + +--connection server_1 +SET gtid_domain_id= 11; +CREATE DATABASE s1; +USE s1; +--let $domain_1=11 +--let $domain_2=11 +--let $M_port= $SERVER_MYPORT_1 +--let $S_port= $SERVER_MYPORT_3 +--let $sync_slave=0 +--let $db_name=s1 +--source include/start_alter_include.inc + +--connection server_1 +DROP DATABASE s1; +--let $master_pos_1= `SELECT @@gtid_binlog_pos` + +--connection server_2 +SET gtid_domain_id= 12; +CREATE DATABASE s2; +USE s2; +--let $domain_1=12 +--let $domain_2=12 +--let $M_port= $SERVER_MYPORT_2 +--let $S_port= $SERVER_MYPORT_3 +--let $sync_slave=0 +--let $db_name=s2 +--source include/start_alter_include.inc +--connection server_2 +DROP DATABASE s2; +--let $master_pos_2= `SELECT @@gtid_binlog_pos` + +--connection server_3 +START ALL SLAVES; +SET default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc + +SET default_master_connection = 'm1'; +--let $master_pos= $master_pos_1 +--source include/sync_with_master_gtid.inc +SET default_master_connection = 'm2'; +--let $master_pos= $master_pos_2 +--source include/sync_with_master_gtid.inc + +--echo # Stop slaves and apply binlog +--connection server_3 +SET default_master_connection = 'm1'; +--source include/stop_slave.inc +SET default_master_connection = 'm2'; +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads = @slave_parallel_threads; +SET GLOBAL slave_parallel_mode = @slave_parallel_mode; +SET GLOBAL gtid_strict_mode = @save_gtid_strict_mode; +SET GLOBAL gtid_domain_id= 0; +SELECT @@gtid_binlog_state; + +let MYSQLD_DATADIR= `select @@datadir;`; +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_1.sql +--echo # reset the binlog +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$SERVER_MYPORT_3 --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_1.sql" +SELECT @@gtid_binlog_state; + +--echo # One more time to simulate S->S case +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_2.sql +RESET MASTER; +--echo # execute the binlog +--exec $MYSQL --port=$SERVER_MYPORT_3 --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_2.sql" +SELECT @@gtid_binlog_state; +remove_file $MYSQLTEST_VARDIR/tmp/slave_1.sql; +remove_file $MYSQLTEST_VARDIR/tmp/slave_2.sql; +RESET MASTER; +RESET SLAVE ALL; +SET GLOBAL gtid_slave_pos= ''; + +--connection server_1 +SET GLOBAL binlog_alter_two_phase=@save_binlog_alter_two_phase; +SET GLOBAL gtid_domain_id= 0; +RESET MASTER; +--connection server_2 +SET GLOBAL gtid_domain_id= 0; +SET GLOBAL binlog_alter_two_phase=@save_binlog_alter_two_phase; +RESET MASTER; + +--disconnect server_1 +--disconnect server_2 +--disconnect server_3 diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_optimize.test b/mysql-test/suite/rpl/t/rpl_start_alter_optimize.test new file mode 100644 index 00000000000..528f2b52af7 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_optimize.test @@ -0,0 +1,25 @@ +# MDEV-11675 two phase logged ALTER +# +# The tests verifies execution of non-ALTER queries that are handled +# through mysql_alter_table function. + +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--connection master +set binlog_alter_two_phase = ON; + +--connection master +CREATE TABLE t1 (i int) engine=innodb; +CREATE TABLE t2 (i int) engine=innodb; + +ALTER TABLE t1 DROP CONSTRAINT IF EXISTS y; +OPTIMIZE TABLE t2; + +--sync_slave_with_master + +--connection master +drop table t1,t2; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_options.test b/mysql-test/suite/rpl/t/rpl_start_alter_options.test new file mode 100644 index 00000000000..12125b49122 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_options.test @@ -0,0 +1,31 @@ +# This test will test all the option related to the Alter Table command +# NOTE not all alter statements will follow alter_algorithm since for some statements +# copy is only option +# parameters +# $alter_algorithm {DEFAULT|INPLACE|COPY|NOCOPY|INSTANT} +# $show_binlog +# + +--source include/have_partition.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--let $alter_algorithm= default +#--let $show_binlog= false +--source include/start_alter_options.inc + +--let $alter_algorithm= inplace +--source include/start_alter_options.inc + +--let $alter_algorithm= copy +--source include/start_alter_options.inc + +--echo # Prove formal support for nocopy and instant +--let $alter_algorithm= instant +--source include/start_alter_options.inc + +--let $alter_algorithm= nocopy +--source include/start_alter_options.inc + + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test b/mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test new file mode 100644 index 00000000000..37e253139d2 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test @@ -0,0 +1,24 @@ +# MDEV-11675 binlog_alter_two_phase +# MDEV-27511 Assertion `rgi->gtid_ev_flags_extra & Gtid_log_event::FL_COMMIT_ALTER_E1' failed +# in write_bin_log_start_alter +# +--source include/have_log_bin.inc +--source include/master-slave.inc + +# The test proves the assert is not hit anymore. +--connection master +CREATE TABLE t1 (a1 int, d1 int DEFAULT 0); +INSERT INTO t1 VALUES (1,1) ; +SET binlog_alter_two_phase = ON; +ALTER TABLE t1 WAIT 9 RENAME COLUMN a1 TO a2; +SET binlog_alter_two_phase = OFF; +ALTER TABLE t1 ALTER COLUMN d1 DROP DEFAULT; + +--sync_slave_with_master + +# Cleanup +--connection master +drop table t1; +--sync_slave_with_master + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_restart_master.test b/mysql-test/suite/rpl/t/rpl_start_alter_restart_master.test new file mode 100644 index 00000000000..83e82bf9509 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_restart_master.test @@ -0,0 +1,75 @@ +# Test crashing of master after writing start alter into binary log. +# And the doing the same alter again, to test on slave if that is successful +# ====> SA Crash SA CA Case +# +--source include/have_log_bin.inc +--source include/have_binlog_format_mixed.inc +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/have_debug.inc + +--connection slave +SET @old_debug_slave= @@global.debug; +stop slave; +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; +start slave; + +--connection master +call mtr.add_suppression("ALTER query started at .+ could not be completed"); + +SET @old_debug_master= @@global.debug; +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set binlog_alter_two_phase=true; +create table t3( a int primary key, b int) engine=innodb; + +--connection master +--sync_slave_with_master +--source include/stop_slave.inc + + +--connection master +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +SET SESSION debug_dbug="d,start_alter_kill_after_binlog"; +--error 2013 +alter table t3 add column d int; + +--let $rpl_server_number= 1 +--source include/rpl_reconnect.inc +set binlog_alter_two_phase= true; +alter table t3 add column d int; +show create table t3; +--source include/show_binlog_events.inc +--let $binlog_file=master-bin.000002 +--source include/show_binlog_events.inc +--let $binlog_file= + +--connection slave +--source include/start_slave.inc + +--connection master +--sync_slave_with_master +--source include/show_binlog_events.inc +show create table t3; + + +--connection master +SET GLOBAL debug_dbug= @old_debug_master; +drop table t3; +--eval set global binlog_alter_two_phase = $binlog_alter_two_phase + +--sync_slave_with_master +SET GLOBAL debug_dbug= @old_debug_slave; +stop slave; +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +start slave; +--connection master +let MYSQLD_DATADIR= `select @@datadir;`; +--remove_files_wildcard $MYSQLD_DATADIR/test #sql*.frm +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test b/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test new file mode 100644 index 00000000000..df028ff1820 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test @@ -0,0 +1,121 @@ +# This test will restart the slave in middle of start alter commit alter processing +# slave will be restarted after start alter and before binlogging of commit alter, +# Then we will recieved commit alter from the master. +# Commit alter will act like standalone alter +# =====> SA SA CA(Stop Slave before binlogging) CA +# +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/have_debug.inc + +--connection slave +SET @old_debug_slave= @@global.debug; +--source include/stop_slave.inc +--let $gtid_strict_mode= `select @@gtid_strict_mode` +--let $slave_parallel_threads= `select @@slave_parallel_threads` +--let $slave_parallel_mode= `select @@slave_parallel_mode` +SET GLOBAL slave_parallel_threads=4; +set global slave_parallel_mode=optimistic; +set global gtid_strict_mode=1; + +set global debug_dbug="+d,rpl_slave_stop_CA_before_binlog"; + +--source include/start_slave.inc +# +# SLAVE Shutdown +--connection master +SET @old_debug_master= @@global.debug; +set global debug_dbug="+d,start_alter_delay_master"; +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set global binlog_alter_two_phase=true; +create table t1( a int primary key, b int) engine=myisam; +create table t2( a int primary key, b int) engine=myisam; + +--connect (con1,localhost,root,,) +--send alter table t1 add column c int; + +--connection master +--echo # Get into binlog first and wait +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now'; +--source include/wait_condition.inc +--let $master_gtid_state = `select @@gtid_binlog_state` +--echo # master gtid state is $master_gtid_state + +--connect (con2,localhost,root,,) +--send alter table t2 add column c int; + +--connection master +--echo # Get into binlog next and wait as well +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now'; +--source include/wait_condition.inc +--let $master_gtid_state = `select @@gtid_binlog_state` +--echo # master gtid state is $master_gtid_state + +# Memorize for slave's next sync with master +--let $master_pos=$master_gtid_state + +set DEBUG_SYNC= "now signal alter_cont"; + +--connection con1 +--reap +--connection con2 +--reap +create table t3( a int primary key, b int) engine=innodb; +--let $master_gtid_state = `select @@gtid_binlog_state` +--echo # master gtid state is $master_gtid_state +--let $replace_regexp=/alter table t[12]/alter table <t>/ /id=[0-9]+/id=<seq_no>/ +--source include/show_binlog_events2.inc + +--echo # Stop Slave +--echo # As master binlog is SA SA CA CA +--echo # let's stop at first CA processing (in process_commit_alter) + +--connection slave +--source include/sync_with_master_gtid.inc +# set debug_sync="now wait_for CA_1_processing"; +connect(extra_slave,127.0.0.1,root,,test,$SLAVE_MYPORT); +--send stop slave; +--connection slave +# set debug_sync="now signal proceed_CA_1"; +--connection extra_slave +--reap +SET GLOBAL debug_dbug= @old_debug_slave; + +--connection slave +--source include/wait_for_slave_sql_to_stop.inc +--echo # The list of events after the slave has stopped must have just one CA: +--let $replace_regexp=/alter table t[12]/alter table <t>/ /id=[0-9]+/id=<seq_no>/ +--source include/show_binlog_events2.inc + +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +--source include/start_slave.inc +--connection master +--sync_slave_with_master +--echo # Everything from the master binlog must have been applied now: +select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1; +--let $slave_gtid_state = `select @@gtid_binlog_state` +--echo # slave gtid state is $slave_gtid_state +if (`select $master_gtid_state <> $slave_gtid_state`) +{ + --echo Gtid state mismatch: $master_gtid_state <> $slave_gtid_state + --die +} +--echo # The list of events after the slave has synchronized must have both CA: +--let $replace_regexp=/alter table t[12]/alter table <t>/ /id=[0-9]+/id=<seq_no>/ +--source include/show_binlog_events2.inc + +--connection master +drop table t1,t2,t3; +--eval set global binlog_alter_two_phase = $binlog_alter_two_phase +SET GLOBAL debug_dbug= @old_debug_master; +set DEBUG_SYNC= 'RESET'; + +--sync_slave_with_master +stop slave; +--eval set global slave_parallel_threads = $slave_parallel_threads; +--eval set global slave_parallel_mode = $slave_parallel_mode; +--eval set global gtid_strict_mode = $gtid_strict_mode; +set DEBUG_SYNC= 'RESET'; +start slave; +--source include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/binlog_alter_two_phase.result b/mysql-test/suite/sys_vars/r/binlog_alter_two_phase.result new file mode 100644 index 00000000000..540d1b49458 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/binlog_alter_two_phase.result @@ -0,0 +1,53 @@ +set binlog_alter_two_phase = OFF; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +0 +set binlog_alter_two_phase = ON; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +1 +# wrong value +set binlog_alter_two_phase=BINLOG_OY; +ERROR 42000: Variable 'binlog_alter_two_phase' can't be set to the value of 'BINLOG_OY' +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +1 +#true and false +set binlog_alter_two_phase=false; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +0 +set binlog_alter_two_phase=true; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +1 +set binlog_alter_two_phase=0; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +0 +set binlog_alter_two_phase=1; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +1 +##wrong value +set binlog_alter_two_phase=2; +ERROR 42000: Variable 'binlog_alter_two_phase' can't be set to the value of '2' +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +1 +#Global value +set global binlog_alter_two_phase = OFF; +connect con1,localhost,root,,; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +0 +disconnect con1; +connection default; +set global binlog_alter_two_phase = ON; +connect con1,localhost,root,,; +select @@binlog_alter_two_phase; +@@binlog_alter_two_phase +1 +disconnect con1; +connection default; +set global binlog_alter_two_phase=0; diff --git a/mysql-test/suite/sys_vars/r/histogram_type_basic.result b/mysql-test/suite/sys_vars/r/histogram_type_basic.result index db42204ac1f..c24192002aa 100644 --- a/mysql-test/suite/sys_vars/r/histogram_type_basic.result +++ b/mysql-test/suite/sys_vars/r/histogram_type_basic.result @@ -1,11 +1,11 @@ SET @start_global_value = @@global.histogram_type; SELECT @start_global_value; @start_global_value -DOUBLE_PREC_HB +JSON_HB SET @start_session_value = @@session.histogram_type; SELECT @start_session_value; @start_session_value -DOUBLE_PREC_HB +JSON_HB SET @@global.histogram_type = 1; SET @@global.histogram_type = DEFAULT; SELECT @@global.histogram_type; @@ -71,9 +71,9 @@ HISTOGRAM_TYPE DOUBLE_PREC_HB SET @@global.histogram_type = @start_global_value; SELECT @@global.histogram_type; @@global.histogram_type -DOUBLE_PREC_HB +JSON_HB SET @@session.histogram_type = @start_session_value; SELECT @@session.histogram_type; @@session.histogram_type -DOUBLE_PREC_HB +JSON_HB set sql_mode=''; diff --git a/mysql-test/suite/sys_vars/r/innodb_log_write_ahead_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_log_write_ahead_size_basic.result deleted file mode 100644 index 5c9eb69de50..00000000000 --- a/mysql-test/suite/sys_vars/r/innodb_log_write_ahead_size_basic.result +++ /dev/null @@ -1,88 +0,0 @@ -SET @start_global_value = @@global.innodb_log_write_ahead_size; -SET global innodb_log_write_ahead_size=4096; -Valid values are positive number -SELECT @@global.innodb_log_write_ahead_size >= 512; -@@global.innodb_log_write_ahead_size >= 512 -1 -SELECT @@global.innodb_log_write_ahead_size <= 16*1024; -@@global.innodb_log_write_ahead_size <= 16*1024 -1 -SELECT @@session.innodb_log_write_ahead_size; -ERROR HY000: Variable 'innodb_log_write_ahead_size' is a GLOBAL variable -SHOW global variables LIKE 'innodb_log_write_ahead_size'; -Variable_name Value -innodb_log_write_ahead_size 4096 -SHOW session variables LIKE 'innodb_log_write_ahead_size'; -Variable_name Value -innodb_log_write_ahead_size 4096 -SELECT * FROM information_schema.global_variables -WHERE variable_name='innodb_log_write_ahead_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_LOG_WRITE_AHEAD_SIZE 4096 -SELECT * FROM information_schema.session_variables -WHERE variable_name='innodb_log_write_ahead_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_LOG_WRITE_AHEAD_SIZE 4096 -SET global innodb_log_write_ahead_size=1024; -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -1024 -SELECT * FROM information_schema.global_variables -WHERE variable_name='innodb_log_write_ahead_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_LOG_WRITE_AHEAD_SIZE 1024 -SELECT * FROM information_schema.session_variables -WHERE variable_name='innodb_log_write_ahead_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_LOG_WRITE_AHEAD_SIZE 1024 -SET session innodb_log_write_ahead_size=2048; -ERROR HY000: Variable 'innodb_log_write_ahead_size' is a GLOBAL variable and should be set with SET GLOBAL -SET global innodb_log_write_ahead_size=512; -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -512 -SET global innodb_log_write_ahead_size=2048; -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -2048 -SET global innodb_log_write_ahead_size=4096; -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -4096 -SET global innodb_log_write_ahead_size=0; -Warnings: -Warning 1292 Truncated incorrect innodb_log_write_ahead_size value: '0' -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -512 -SET global innodb_log_write_ahead_size=-1024; -Warnings: -Warning 1292 Truncated incorrect innodb_log_write_ahead_size value: '-1024' -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -512 -SET global innodb_log_write_ahead_size=3000; -Warnings: -Warning 1292 Truncated incorrect innodb_log_write_ahead_size value: '3000' -Warning 1210 innodb_log_write_ahead_size should be set 2^n value and larger than 512. -Warning 1210 Setting innodb_log_write_ahead_size to 4096 -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -4096 -SET global innodb_log_write_ahead_size=1.1; -ERROR 42000: Incorrect argument type to variable 'innodb_log_write_ahead_size' -SET global innodb_log_write_ahead_size=1e1; -ERROR 42000: Incorrect argument type to variable 'innodb_log_write_ahead_size' -SET global innodb_log_write_ahead_size="foo"; -ERROR 42000: Incorrect argument type to variable 'innodb_log_write_ahead_size' -SET global innodb_log_write_ahead_size=-7; -Warnings: -Warning 1292 Truncated incorrect innodb_log_write_ahead_size value: '-7' -SELECT @@global.innodb_log_write_ahead_size; -@@global.innodb_log_write_ahead_size -512 -SELECT * FROM information_schema.global_variables -WHERE variable_name='innodb_log_write_ahead_size'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_LOG_WRITE_AHEAD_SIZE 512 -SET @@global.innodb_log_write_ahead_size = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result b/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result index 01ad4659b46..f7889f3f7dd 100644 --- a/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result +++ b/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result @@ -8,23 +8,35 @@ SELECT @start_session_value; 0 '#--------------------FN_DYNVARS_054_01-------------------------#' SET @@global.keep_files_on_create = ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SET @@global.keep_files_on_create = DEFAULT; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 0 SET @@session.keep_files_on_create = ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SET @@session.keep_files_on_create = DEFAULT; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 0 '#--------------------FN_DYNVARS_054_02-------------------------#' SET @@global.keep_files_on_create = DEFAULT; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create = 'OFF'; @@global.keep_files_on_create = 'OFF' 1 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'OFF' SET @@session.keep_files_on_create = DEFAULT; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create = 'OFF'; @@session.keep_files_on_create = 'OFF' 1 @@ -32,51 +44,75 @@ Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'OFF' '#--------------------FN_DYNVARS_054_03-------------------------#' SET @@global.keep_files_on_create = ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 1 SET @@global.keep_files_on_create = OFF; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 0 SET @@global.keep_files_on_create = 0; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 0 SET @@global.keep_files_on_create = 1; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 1 SET @@global.keep_files_on_create = TRUE; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 1 SET @@global.keep_files_on_create = FALSE; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 0 '#--------------------FN_DYNVARS_054_04-------------------------#' SET @@session.keep_files_on_create = ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 1 SET @@session.keep_files_on_create = OFF; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 0 SET @@session.keep_files_on_create = 0; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 0 SET @@session.keep_files_on_create = 1; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 1 SET @@session.keep_files_on_create = TRUE; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 1 SET @@session.keep_files_on_create = FALSE; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 0 @@ -130,12 +166,18 @@ IF(@@session.keep_files_on_create, "ON", "OFF") = VARIABLE_VALUE 1 '#---------------------FN_DYNVARS_001_08----------------------#' SET @@keep_files_on_create = OFF; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SET @@global.keep_files_on_create = ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@keep_files_on_create = @@global.keep_files_on_create; @@keep_files_on_create = @@global.keep_files_on_create 0 '#---------------------FN_DYNVARS_001_09----------------------#' SET @@keep_files_on_create = ON; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@keep_files_on_create = @@local.keep_files_on_create; @@keep_files_on_create = @@local.keep_files_on_create 1 @@ -144,6 +186,8 @@ SELECT @@local.keep_files_on_create = @@session.keep_files_on_create; 1 '#---------------------FN_DYNVARS_001_10----------------------#' SET keep_files_on_create = 1; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@keep_files_on_create; @@keep_files_on_create 1 @@ -154,10 +198,14 @@ ERROR 42S02: Unknown table 'session' in field list SELECT keep_files_on_create = @@session.keep_files_on_create; ERROR 42S22: Unknown column 'keep_files_on_create' in 'field list' SET @@global.keep_files_on_create = @start_global_value; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@global.keep_files_on_create; @@global.keep_files_on_create 0 SET @@session.keep_files_on_create = @start_session_value; +Warnings: +Warning 1287 '@@keep_files_on_create' is deprecated and will be removed in a future release SELECT @@session.keep_files_on_create; @@session.keep_files_on_create 0 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff index 2a7bd72a700..3c6f2c3b8d9 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff @@ -18,14 +18,14 @@ NUMERIC_MAX_VALUE 2 @@ -85,10 +85,10 @@ SESSION_VALUE NULL - DEFAULT_VALUE 134217728 + DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Size of a single memory chunk for resizing buffer pool. Online buffer pool resizing happens at this granularity. 0 means disable resizing buffer pool. - NUMERIC_MIN_VALUE 1048576 --NUMERIC_MAX_VALUE 9223372036854775807 -+NUMERIC_MAX_VALUE 2147483647 + VARIABLE_COMMENT Size of a single memory chunk for resizing buffer pool. Online buffer pool resizing happens at this granularity. 0 means autosize this variable based on buffer pool size. + NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 NUMERIC_BLOCK_SIZE 1048576 ENUM_VALUE_LIST NULL READ_ONLY YES @@ -65,7 +65,7 @@ VARIABLE_COMMENT Percentage of empty space on a data page that can be reserved to make the page compressible. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 75 -@@ -649,7 +649,7 @@ +@@ -625,7 +625,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 600 VARIABLE_SCOPE GLOBAL @@ -74,7 +74,7 @@ VARIABLE_COMMENT Maximum number of seconds that semaphore times out in InnoDB. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -697,7 +697,7 @@ +@@ -673,7 +673,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 30 VARIABLE_SCOPE GLOBAL @@ -83,7 +83,7 @@ VARIABLE_COMMENT Number of iterations over which the background flushing is averaged. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1000 -@@ -721,7 +721,7 @@ +@@ -697,7 +697,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -92,7 +92,7 @@ VARIABLE_COMMENT Controls the durability/speed trade-off for commits. Set to 0 (write and flush redo log to disk only once per second), 1 (flush to disk at each commit), 2 (write to log at commit but flush to disk only once per second) or 3 (flush to disk at prepare and at commit, slower and usually redundant). 1 and 3 guarantees that after a crash, committed transactions will not be lost and will be consistent with the binlog and other transactional engines. 2 can get inconsistent and lose transactions if there is a power failure or kernel crash but not if mysqld crashes. 0 has no guarantees in case of crash. 0 and 2 can be faster than 1 or 3. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 3 -@@ -745,7 +745,7 @@ +@@ -721,7 +721,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -101,7 +101,7 @@ VARIABLE_COMMENT Set to 0 (don't flush neighbors from buffer pool), 1 (flush contiguous neighbors from buffer pool) or 2 (flush neighbors from buffer pool), when flushing a block NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -781,7 +781,7 @@ +@@ -757,7 +757,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -110,7 +110,7 @@ VARIABLE_COMMENT Helps to save your data in case the disk image of the database becomes corrupt. Value 5 can return bogus data, and 6 can permanently corrupt data. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 6 -@@ -805,10 +805,10 @@ +@@ -781,10 +781,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 8000000 VARIABLE_SCOPE GLOBAL @@ -123,7 +123,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -841,7 +841,7 @@ +@@ -817,7 +817,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 84 VARIABLE_SCOPE GLOBAL @@ -132,7 +132,7 @@ VARIABLE_COMMENT InnoDB Fulltext search maximum token size in characters NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 84 -@@ -853,7 +853,7 @@ +@@ -829,7 +829,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 3 VARIABLE_SCOPE GLOBAL @@ -141,7 +141,7 @@ VARIABLE_COMMENT InnoDB Fulltext search minimum token size in characters NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16 -@@ -865,7 +865,7 @@ +@@ -841,7 +841,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 2000 VARIABLE_SCOPE GLOBAL @@ -150,7 +150,7 @@ VARIABLE_COMMENT InnoDB Fulltext search number of words to optimize for each optimize table call NUMERIC_MIN_VALUE 1000 NUMERIC_MAX_VALUE 10000 -@@ -877,10 +877,10 @@ +@@ -853,10 +853,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 2000000000 VARIABLE_SCOPE GLOBAL @@ -163,7 +163,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -901,7 +901,7 @@ +@@ -877,7 +877,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 2 VARIABLE_SCOPE GLOBAL @@ -172,7 +172,7 @@ VARIABLE_COMMENT InnoDB Fulltext search parallel sort degree, will round up to nearest power of 2 number NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 16 -@@ -913,10 +913,10 @@ +@@ -889,10 +889,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 640000000 VARIABLE_SCOPE GLOBAL @@ -185,7 +185,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -961,22 +961,22 @@ +@@ -937,22 +937,22 @@ SESSION_VALUE NULL DEFAULT_VALUE 200 VARIABLE_SCOPE GLOBAL @@ -213,29 +213,20 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1009,10 +1009,10 @@ +@@ -985,10 +985,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 16777216 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk. - NUMERIC_MIN_VALUE 262144 --NUMERIC_MAX_VALUE 9223372036854775807 -+NUMERIC_MAX_VALUE 2147483647 - NUMERIC_BLOCK_SIZE 1024 + VARIABLE_COMMENT Redo log buffer size in bytes. + NUMERIC_MIN_VALUE 2097152 +-NUMERIC_MAX_VALUE 18446744073709551615 ++NUMERIC_MAX_VALUE 4294967295 + NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -1057,7 +1057,7 @@ - SESSION_VALUE NULL - DEFAULT_VALUE 8192 - VARIABLE_SCOPE GLOBAL --VARIABLE_TYPE BIGINT UNSIGNED -+VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Redo log write ahead unit size to avoid read-on-write, it should match the OS cache block IO size - NUMERIC_MIN_VALUE 512 - NUMERIC_MAX_VALUE 16384 -@@ -1069,10 +1069,10 @@ +@@ -1033,10 +1033,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 32 VARIABLE_SCOPE GLOBAL @@ -248,7 +239,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1081,10 +1081,10 @@ +@@ -1045,10 +1045,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 1536 VARIABLE_SCOPE GLOBAL @@ -261,7 +252,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1129,10 +1129,10 @@ +@@ -1081,10 +1081,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -274,7 +265,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1141,7 +1141,7 @@ +@@ -1093,7 +1093,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -283,7 +274,7 @@ VARIABLE_COMMENT Maximum delay of user threads in micro-seconds NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 10000000 -@@ -1273,10 +1273,10 @@ +@@ -1225,10 +1225,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -296,7 +287,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -1309,7 +1309,7 @@ +@@ -1249,7 +1249,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 16384 VARIABLE_SCOPE GLOBAL @@ -305,7 +296,7 @@ VARIABLE_COMMENT Page size to use for all InnoDB tablespaces. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 65536 -@@ -1345,7 +1345,7 @@ +@@ -1285,7 +1285,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 300 VARIABLE_SCOPE GLOBAL @@ -314,7 +305,7 @@ VARIABLE_COMMENT Number of UNDO log pages to purge in one batch from the history list. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5000 -@@ -1357,7 +1357,7 @@ +@@ -1297,7 +1297,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 128 VARIABLE_SCOPE GLOBAL @@ -323,7 +314,7 @@ VARIABLE_COMMENT Dictates rate at which UNDO records are purged. Value N means purge rollback segment(s) on every Nth iteration of purge invocation NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 128 -@@ -1393,7 +1393,7 @@ +@@ -1333,7 +1333,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 56 VARIABLE_SCOPE GLOBAL @@ -332,7 +323,7 @@ VARIABLE_COMMENT Number of pages that must be accessed sequentially for InnoDB to trigger a readahead. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 64 -@@ -1465,7 +1465,7 @@ +@@ -1405,7 +1405,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1048576 VARIABLE_SCOPE GLOBAL @@ -341,7 +332,7 @@ VARIABLE_COMMENT Memory buffer size for index creation NUMERIC_MIN_VALUE 65536 NUMERIC_MAX_VALUE 67108864 -@@ -1633,10 +1633,10 @@ +@@ -1573,10 +1573,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 30 VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 5a52b2e4251..c3dd970f6e3 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -5,6 +5,7 @@ variable_name not in ( 'innodb_numa_interleave', # only available WITH_NUMA 'innodb_evict_tables_on_commit_debug', # one may want to override this 'innodb_use_native_aio', # default value depends on OS +'innodb_log_file_buffering', # only available on Linux and Windows 'innodb_buffer_pool_load_pages_abort') # debug build only, and is only for testing order by variable_name; VARIABLE_NAME INNODB_ADAPTIVE_FLUSHING @@ -81,12 +82,12 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_BUFFER_POOL_CHUNK_SIZE SESSION_VALUE NULL -DEFAULT_VALUE 134217728 +DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Size of a single memory chunk for resizing buffer pool. Online buffer pool resizing happens at this granularity. 0 means disable resizing buffer pool. -NUMERIC_MIN_VALUE 1048576 -NUMERIC_MAX_VALUE 9223372036854775807 +VARIABLE_COMMENT Size of a single memory chunk for resizing buffer pool. Online buffer pool resizing happens at this granularity. 0 means autosize this variable based on buffer pool size. +NUMERIC_MIN_VALUE 0 +NUMERIC_MAX_VALUE 18446744073709551615 NUMERIC_BLOCK_SIZE 1048576 ENUM_VALUE_LIST NULL READ_ONLY YES @@ -984,10 +985,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 16777216 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk. -NUMERIC_MIN_VALUE 262144 -NUMERIC_MAX_VALUE 9223372036854775807 -NUMERIC_BLOCK_SIZE 1024 +VARIABLE_COMMENT Redo log buffer size in bytes. +NUMERIC_MIN_VALUE 2097152 +NUMERIC_MAX_VALUE 18446744073709551615 +NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED @@ -1008,10 +1009,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 100663296 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Size of each log file in a log group. -NUMERIC_MIN_VALUE 1048576 +VARIABLE_COMMENT Redo log size in bytes. +NUMERIC_MIN_VALUE 4194304 NUMERIC_MAX_VALUE 18446744073709551615 -NUMERIC_BLOCK_SIZE 65536 +NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED @@ -1020,25 +1021,13 @@ SESSION_VALUE NULL DEFAULT_VALUE VARIABLE_SCOPE GLOBAL VARIABLE_TYPE VARCHAR -VARIABLE_COMMENT Path to InnoDB log files. +VARIABLE_COMMENT Path to ib_logfile0 NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED -VARIABLE_NAME INNODB_LOG_WRITE_AHEAD_SIZE -SESSION_VALUE NULL -DEFAULT_VALUE 8192 -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Redo log write ahead unit size to avoid read-on-write, it should match the OS cache block IO size -NUMERIC_MIN_VALUE 512 -NUMERIC_MAX_VALUE 16384 -NUMERIC_BLOCK_SIZE 512 -ENUM_VALUE_LIST NULL -READ_ONLY NO -COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_LRU_FLUSH_SIZE SESSION_VALUE NULL DEFAULT_VALUE 32 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 3eb3f52bd0f..29e5d03dd98 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -1205,11 +1205,11 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME HISTOGRAM_TYPE VARIABLE_SCOPE SESSION VARIABLE_TYPE ENUM -VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced. +VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced, JSON_HB - height-balanced, stored as JSON. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB +ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB,JSON_HB READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME HOSTNAME diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index ff87672bfa3..f0dda77da15 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -322,6 +322,16 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME BINLOG_ALTER_TWO_PHASE +VARIABLE_SCOPE SESSION +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT When set, split ALTER at binary logging into 2 statements: START ALTER and COMMIT/ROLLBACK ALTER +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME BINLOG_ANNOTATE_ROW_EVENTS VARIABLE_SCOPE SESSION VARIABLE_TYPE BOOLEAN @@ -1305,11 +1315,11 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME HISTOGRAM_TYPE VARIABLE_SCOPE SESSION VARIABLE_TYPE ENUM -VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced. +VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced, JSON_HB - height-balanced, stored as JSON. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB +ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB,JSON_HB READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME HOSTNAME diff --git a/mysql-test/suite/sys_vars/t/binlog_alter_two_phase.test b/mysql-test/suite/sys_vars/t/binlog_alter_two_phase.test new file mode 100644 index 00000000000..bc3adf12c15 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/binlog_alter_two_phase.test @@ -0,0 +1,52 @@ +# +# binlog_alter_two_phase system variable +# Session as well as global +# Allowed values NO_SPLIT, SPLIT, BINLOG_ONLY (0,1,2) + +--source include/not_embedded.inc + +--let $binlog_alter_two_phase= `select @@binlog_alter_two_phase` +set binlog_alter_two_phase = OFF; +select @@binlog_alter_two_phase; + +set binlog_alter_two_phase = ON; +select @@binlog_alter_two_phase; + +--echo # wrong value +--error ER_WRONG_VALUE_FOR_VAR +set binlog_alter_two_phase=BINLOG_OY; +select @@binlog_alter_two_phase; + +--echo #true and false +set binlog_alter_two_phase=false; +select @@binlog_alter_two_phase; + +set binlog_alter_two_phase=true; +select @@binlog_alter_two_phase; + +set binlog_alter_two_phase=0; +select @@binlog_alter_two_phase; + +set binlog_alter_two_phase=1; +select @@binlog_alter_two_phase; + +--echo ##wrong value +--error ER_WRONG_VALUE_FOR_VAR +set binlog_alter_two_phase=2; +select @@binlog_alter_two_phase; + + +--echo #Global value +set global binlog_alter_two_phase = OFF; +connect (con1,localhost,root,,); +select @@binlog_alter_two_phase; +disconnect con1; + +connection default; +set global binlog_alter_two_phase = ON; +connect (con1,localhost,root,,); +select @@binlog_alter_two_phase; +disconnect con1; + +connection default; +--eval set global binlog_alter_two_phase=$binlog_alter_two_phase diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_size_basic.test index f37e3e2e0fd..dada2a9a455 100644 --- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_size_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_size_basic.test @@ -25,7 +25,7 @@ --source include/have_innodb.inc let $wait_condition = - SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool' FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; diff --git a/mysql-test/suite/sys_vars/t/innodb_log_write_ahead_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_log_write_ahead_size_basic.test deleted file mode 100644 index 8693c6a7b1b..00000000000 --- a/mysql-test/suite/sys_vars/t/innodb_log_write_ahead_size_basic.test +++ /dev/null @@ -1,93 +0,0 @@ ---source include/have_innodb.inc - -SET @start_global_value = @@global.innodb_log_write_ahead_size; - -# default value is limited by innodb_page_size and varying along with the page size. -#SELECT @start_global_value; - -#set common valid value -SET global innodb_log_write_ahead_size=4096; - -# -# exists as global only -# ---echo Valid values are positive number -SELECT @@global.innodb_log_write_ahead_size >= 512; -SELECT @@global.innodb_log_write_ahead_size <= 16*1024; - ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -SELECT @@session.innodb_log_write_ahead_size; -SHOW global variables LIKE 'innodb_log_write_ahead_size'; -SHOW session variables LIKE 'innodb_log_write_ahead_size'; ---disable_warnings -SELECT * FROM information_schema.global_variables -WHERE variable_name='innodb_log_write_ahead_size'; -SELECT * FROM information_schema.session_variables -WHERE variable_name='innodb_log_write_ahead_size'; ---enable_warnings - -# -# show that it's writable -# -SET global innodb_log_write_ahead_size=1024; -SELECT @@global.innodb_log_write_ahead_size; ---disable_warnings -SELECT * FROM information_schema.global_variables -WHERE variable_name='innodb_log_write_ahead_size'; -SELECT * FROM information_schema.session_variables -WHERE variable_name='innodb_log_write_ahead_size'; ---enable_warnings ---error ER_GLOBAL_VARIABLE -SET session innodb_log_write_ahead_size=2048; - -# -# Valid values -# -SET global innodb_log_write_ahead_size=512; -SELECT @@global.innodb_log_write_ahead_size; -SET global innodb_log_write_ahead_size=2048; -SELECT @@global.innodb_log_write_ahead_size; -SET global innodb_log_write_ahead_size=4096; -SELECT @@global.innodb_log_write_ahead_size; - -# limited by innodb_page_size, and the followings are occationally invalid -#SET global innodb_log_write_ahead_size=8192; -#SELECT @@global.innodb_log_write_ahead_size; -#SET global innodb_log_write_ahead_size=16384; -#SELECT @@global.innodb_log_write_ahead_size; - -# -# Invalid values -# -SET global innodb_log_write_ahead_size=0; -SELECT @@global.innodb_log_write_ahead_size; -SET global innodb_log_write_ahead_size=-1024; -SELECT @@global.innodb_log_write_ahead_size; -SET global innodb_log_write_ahead_size=3000; -SELECT @@global.innodb_log_write_ahead_size; - -# limited by innodb_page_size, and the followings result occationally different -#SET global innodb_log_write_ahead_size=32768; -#SELECT @@global.innodb_log_write_ahead_size; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -SET global innodb_log_write_ahead_size=1.1; ---error ER_WRONG_TYPE_FOR_VAR -SET global innodb_log_write_ahead_size=1e1; ---error ER_WRONG_TYPE_FOR_VAR -SET global innodb_log_write_ahead_size="foo"; -SET global innodb_log_write_ahead_size=-7; -SELECT @@global.innodb_log_write_ahead_size; ---disable_warnings -SELECT * FROM information_schema.global_variables -WHERE variable_name='innodb_log_write_ahead_size'; ---enable_warnings - -# -# cleanup -# - -SET @@global.innodb_log_write_ahead_size = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/sysvars_innodb.test b/mysql-test/suite/sys_vars/t/sysvars_innodb.test index 15fd99e9984..6d46c22683f 100644 --- a/mysql-test/suite/sys_vars/t/sysvars_innodb.test +++ b/mysql-test/suite/sys_vars/t/sysvars_innodb.test @@ -12,5 +12,6 @@ select VARIABLE_NAME, SESSION_VALUE, DEFAULT_VALUE, VARIABLE_SCOPE, VARIABLE_TYP 'innodb_numa_interleave', # only available WITH_NUMA 'innodb_evict_tables_on_commit_debug', # one may want to override this 'innodb_use_native_aio', # default value depends on OS + 'innodb_log_file_buffering', # only available on Linux and Windows 'innodb_buffer_pool_load_pages_abort') # debug build only, and is only for testing order by variable_name; |