diff --git a/mysql-test/extra/rpl_tests/rpl_deadlock.test b/mysql-test/extra/rpl_tests/rpl_deadlock.test index 62fe9b2223a..1b331cc948b 100644 --- a/mysql-test/extra/rpl_tests/rpl_deadlock.test +++ b/mysql-test/extra/rpl_tests/rpl_deadlock.test @@ -7,125 +7,126 @@ # (Guilhem) have seen the test manage to provoke lock wait timeout # error but not deadlock error; that is ok as code deals with the two # errors in exactly the same way. -# We don't 'show status like 'slave_retried_transactions'' because this -# is not repeatable (depends on sleeps). --- source include/master-slave.inc +--source include/master-slave.inc + +# 0) Prepare tables and data +--echo *** Prepare tables and data *** connection master; eval CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type; -eval CREATE TABLE t2 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type; -# requiring 'unique' for the timeout part of the test -eval CREATE TABLE t3 (a INT UNIQUE) ENGINE=$engine_type; -eval CREATE TABLE t4 (a INT) ENGINE=$engine_type; -show variables like 'slave_transaction_retries'; +eval CREATE TABLE t2 (a INT) ENGINE=$engine_type; +eval CREATE TABLE t3 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type; sync_slave_with_master; -show create table t1; -show create table t2; -show variables like 'slave_transaction_retries'; -stop slave; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +SHOW CREATE TABLE t3; +SHOW VARIABLES LIKE 'slave_transaction_retries'; +--source include/stop_slave.inc + +connection master; +BEGIN; +INSERT INTO t1 VALUES (1); +# We make a long transaction here +INSERT INTO t2 VALUES (2), (2), (2), (2), (2), (2), (2), (2), (2), (2); +INSERT INTO t3 VALUES (3); +COMMIT; +save_master_pos; +# Save BEGIN event into variable +let $master_pos_begin= query_get_value(SHOW BINLOG EVENTS, Pos, 5); +--echo # 1) Test deadlock - -connection master; -begin; -# Let's keep BEGIN and the locked statement in two different relay logs. -insert into t2 values (0); # t2,t1 actors of deadlock in repl-ed ta -#insert into t3 select * from t2 for update; -let $1=10; -disable_query_log; -while ($1) -{ - eval insert into t3 values( $1 ); - dec $1; -} -enable_query_log; -insert into t1 values(1); -commit; -save_master_pos; +# Block slave SQL thread, wait retries of transaction, unlock slave before lock timeout +--echo *** Test deadlock *** connection slave; -begin; -# Let's make our transaction large so that it's repl-ed msta that's victim -let $1=100; -disable_query_log; -while ($1) -{ - eval insert into t4 values( $1 ); - dec $1; -} -enable_query_log; -select * from t1 for update; # t1,t2 on local slave's -start slave; - -# bad option, todo: replicate a non-transactional t_sync with the transaction -# and use wait_until_rows_count macro below ---real_sleep 3 # hope that slave is blocked now -#let $count=11; -#let $table=t_sync; -#--include wait_until_rows_count.inc - -select * from t2 for update /* dl */; # provoke deadlock, repl-ed should be victim -commit; +BEGIN; +SELECT * FROM t1 FOR UPDATE; +# Save variable 'Slave_retried_transactions' before deadlock +let $slave_retried_transactions= query_get_value(SHOW GLOBAL STATUS LIKE 'Slave_retried_transactions', Value, 1); +START SLAVE; +# Wait until SQL thread blocked: variable 'Slave_retried_transactions' will incremented +let $status_var= Slave_retried_transactions; +let $status_var_value= $slave_retried_transactions; +let $status_type= GLOBAL; +let $status_var_comparsion= >; +--source include/wait_for_status_var.inc +SELECT COUNT(*) FROM t2; +COMMIT; sync_with_master; -select * from t1; # check that repl-ed succeeded finally -select * from t2 /* must be 1 */; -# check that no error is reported ---replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # ---replace_result $MASTER_MYPORT MASTER_MYPORT ---vertical_results -show slave status; ---horizontal_results + +# Check the data +SELECT * FROM t1; +SELECT * FROM t3; +# Check that no error is reported +--source include/show_slave_status2.inc +--echo # 2) Test lock wait timeout +# Block slave and wait lock timeout error +--echo *** Test lock wait timeout *** -stop slave; -delete from t3; -change master to master_log_pos=548; # the BEGIN log event -begin; -select * from t2 for update; # hold lock -start slave; ---real_sleep 10 # repl-ed should have blocked, and be retrying -select count(*) from t3 /* must be zero */; # replaying begins after rollback -commit; +connection slave; +--source include/stop_slave.inc +DELETE FROM t2; +# Set slave position to the BEGIN log event +--replace_result $master_pos_begin MASTER_POS_BEGIN +eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin; +BEGIN; +# Hold lock +SELECT * FROM t1 FOR UPDATE; +# Wait until slave stopped with error 'Lock wait timeout exceeded' +START SLAVE; +let $slave_sql_errno= 1205; +--source include/wait_for_slave_sql_error.inc +SELECT COUNT(*) FROM t2; +COMMIT; +--source include/start_slave.inc sync_with_master; -select * from t1; # check that repl-ed succeeded finally -select * from t2; -# check that no error is reported ---replace_column 1 # 7 # 8 # 9 # 11 # 16 # 22 # 23 # 33 # ---replace_result $MASTER_MYPORT MASTER_MYPORT ---vertical_results -show slave status; ---horizontal_results +# Check data from tables +SELECT * FROM t1; +SELECT * FROM t3; +# Check that no error is reported +--source include/show_slave_status2.inc +--echo -# Now we repeat 2), but with BEGIN in the same relay log as -# COMMIT (to see if seeking into hot log is ok). -set @my_max_relay_log_size= @@global.max_relay_log_size; -set global max_relay_log_size=0; +# 3) Test lock wait timeout and purged relay log +# Set max_relay_log_size=0, block slave and wait lock timeout error. +# Restart slave and check that no erros appear +--echo *** Test lock wait timeout and purged relay logs *** -# This is really copy-paste of 2) of above -stop slave; -delete from t3; -change master to master_log_pos=548; -begin; -select * from t2 for update; -start slave; ---real_sleep 10 -select count(*) from t3 /* must be zero */; # replaying begins after rollback -commit; +connection slave; +SET @my_max_relay_log_size= @@global.max_relay_log_size; +SET global max_relay_log_size=0; +--source include/stop_slave.inc +DELETE FROM t2; +# Set slave position to the BEGIN log event +eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin; +BEGIN; +# Hold lock +SELECT * FROM t1 FOR UPDATE; +# Wait until slave stopped with error 'Lock wait timeout exceeded' +START SLAVE; +let $slave_sql_errno= 1205; +--source include/wait_for_slave_sql_error.inc +SELECT COUNT(*) FROM t2; +COMMIT; +--source include/start_slave.inc sync_with_master; -select * from t1; -select * from t2; ---replace_column 1 # 7 # 8 # 9 # 11 # 16 # 22 # 23 # 33 # 35 # 36 # ---replace_result $MASTER_MYPORT MASTER_MYPORT ---vertical_results -show slave status; ---horizontal_results +# Check data from tables +SELECT * FROM t1; +SELECT * FROM t3; +# Check that no error is reported +--source include/show_slave_status2.inc +--echo +# Clean up +--echo *** Clean up *** connection master; -drop table t1,t2,t3,t4; +DROP TABLE t1,t2,t3; sync_slave_with_master; -set global max_relay_log_size= @my_max_relay_log_size; +SET global max_relay_log_size= @my_max_relay_log_size; --echo End of 5.1 tests diff --git a/mysql-test/include/diff_master_slave.inc b/mysql-test/include/diff_master_slave.inc new file mode 100644 index 00000000000..b6d79190671 --- /dev/null +++ b/mysql-test/include/diff_master_slave.inc @@ -0,0 +1,21 @@ +# ==== Purpose ==== +# +# Diff the output of a statement on master and slave +# +# ==== Usage ===== +# +# let $diff_statement= SELECT * FROM t1 WHERE a < 100; +# source include/diff_master_slave.inc; + +--echo source include/diff_master_slave.inc; +disable_query_log; +disable_result_log; + +exec $MYSQL test -e "$diff_statement" > $MYSQLTEST_VARDIR/tmp/diff_master.out; +sync_slave_with_master; +exec $MYSQL_SLAVE test -e "$diff_statement" > $MYSQLTEST_VARDIR/tmp/diff_slave.out; + +diff_files $MYSQLTEST_VARDIR/tmp/diff_master.out $MYSQLTEST_VARDIR/tmp/diff_slave.out; + +enable_result_log; +enable_query_log; diff --git a/mysql-test/include/kill_query.inc b/mysql-test/include/kill_query.inc new file mode 100644 index 00000000000..341c3b93535 --- /dev/null +++ b/mysql-test/include/kill_query.inc @@ -0,0 +1,68 @@ +# ==== Purpose ==== +# +# Kill a query in the master connection, and then try to reap the +# result of the killed query. +# +# ==== Usage ==== +# +# The following variables should be set before sourcing this file. +# +# $debug_lock: name of the debug user lock, if set, will release/lock +# the specified debug lock accordingly, and before +# sourcing this, connection 'master' should get the user +# lock and run a query in another thread, which will +# block before creating statement event. +# +# $connection_name: name of the connection that is waiting for the +# lock, this can not be 'master' +# +# $connection_id: id of the connection that is waiting for the lock +# +# Example: +# let $debug_lock=; +# connection master1; +# let $connection_name= master1; +# let $connection_id= `SELECT CONNECTION_ID()`; +# send CREATE TABLE t1; +# source kill_query.inc; +# +# let $debug_lock= "debug_lock.before_query_log_event"; +# connection master; +# eval SELECT GET_LOCK($debug_lock, 10); +# connection master1; +# let $connection_name= master1; +# let $connection_id= `SELECT CONNECTION_ID()`; +# send CREATE TABLE t1; +# source kill_query.inc; + + +--echo source include/kill_query.inc; +disable_query_log; +disable_result_log; +connection master; + +# kill the query that is waiting +eval kill query $connection_id; + +if (`SELECT '$debug_lock' != ''`) +{ + # release the lock to allow binlog continue + eval SELECT RELEASE_LOCK($debug_lock); +} + +# reap the result of the waiting query +connection $connection_name; +error 0, 1317, 1307, 1306, 1334, 1305; +reap; + +connection master; + +if (`SELECT '$debug_lock' != ''`) +{ + # get lock again to make the next query wait + eval SELECT GET_LOCK($debug_lock, 10); +} + +connection $connection_name; +enable_query_log; +enable_result_log; diff --git a/mysql-test/include/kill_query_and_diff_master_slave.inc b/mysql-test/include/kill_query_and_diff_master_slave.inc new file mode 100644 index 00000000000..611d6929c99 --- /dev/null +++ b/mysql-test/include/kill_query_and_diff_master_slave.inc @@ -0,0 +1,43 @@ +# ==== Purpose ==== +# +# Kill a query, sync master with slave, and diff the output of a +# statement on master and slave to check if statement is correctly +# replicated. +# +# ==== Usage ==== +# +# connection ; +# let $connection_name= +# let $connection_id=`SELECT CONNECTION_ID()`; +# let $diff_statement=; +# send ; +# source include/kill_query_and_diff_master_slave.inc; +# +# Note: must not be 'master'. +# +# See also kill_query.inc and diff_master_slave.inc for more +# information + +source include/kill_query.inc; + +# Release the debug lock if used, so that the statements in +# diff_master_slave.inc will not be blocked. +connection master; +disable_query_log; +disable_result_log; +if (`SELECT '$debug_lock' != ''`) +{ + eval SELECT RELEASE_LOCK($debug_lock); +} +enable_result_log; +enable_query_log; + +source include/diff_master_slave.inc; + +# Acquire the debug lock again if used +connection master; +disable_query_log; disable_result_log; if (`SELECT '$debug_lock' != +''`) { eval SELECT GET_LOCK($debug_lock, 10); } enable_result_log; +enable_query_log; + +connection $connection_name; diff --git a/mysql-test/include/wait_for_status_var.inc b/mysql-test/include/wait_for_status_var.inc new file mode 100644 index 00000000000..4c168da7f1a --- /dev/null +++ b/mysql-test/include/wait_for_status_var.inc @@ -0,0 +1,68 @@ +# ==== Purpose ==== +# +# Waits until a variable from SHOW STATUS has returned a specified +# value, or until a timeout is reached. +# +# ==== Usage ==== +# +# let $status_var= Threads_connected; +# let $status_var_value= 1; +# --source include/wait_for_status_var.inc +# +# Parameters: +# +# $status_var, $status_var_value +# This macro will wait until the variable of SHOW STATUS +# named $status_var gets the value $status_var_value. See +# the example above. +# +# $status_type= GLOBAL|SESSION +# To specify the type (attribute) of status variable and +# run either SHOW GLOBAL STATUS or SHOW SESSION STATUS. +# +# $status_var_comparsion +# By default, this file waits until $status_var becomes equal to +# $status_var_value. If you want to wait until $status_var +# becomes *unequal* to $status_var_value, set this parameter to the +# string '!=', like this: +# let $status_var_comparsion= !=; +# +# $status_timeout +# The default timeout is 1 minute. You can change the timeout by +# setting $status_timeout. The unit is tenths of seconds. +# + +if (`SELECT STRCMP('$status_type', '') * STRCMP(UPPER('$status_type'), 'SESSION') * STRCMP(UPPER('$status_type'), 'GLOBAL')`) +{ + --echo **** ERROR: Unknown type of variable status_type: allowed values are: SESSION or GLOBAL **** + exit; +} + +let $_status_timeout_counter= $status_timeout; +if (!$_status_timeout_counter) +{ + let $_status_timeout_counter= 600; +} + +let $_status_var_comparsion= $status_var_comparsion; +if (`SELECT '$_status_var_comparsion' = ''`) +{ + let $_status_var_comparsion= =; +} + +let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1); +while (`SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value')`) +{ + if (!$_status_timeout_counter) + { + --echo **** ERROR: failed while waiting for $status_type $status_var $_status_var_comparison $status_var_value **** + --echo Note: the following output may have changed since the failure was detected + --echo **** Showing STATUS, PROCESSLIST **** + eval SHOW $status_type STATUS LIKE '$status_var'; + SHOW PROCESSLIST; + exit; + } + dec $_status_timeout_counter; + sleep 0.1; + let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1); +} diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c5a68662d5b..3949148ec49 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1600,14 +1600,22 @@ sub mysql_fix_arguments () { } -sub client_arguments ($) { +sub client_arguments ($;$) { my $client_name= shift; + my $group_suffix= shift; my $client_exe= mtr_exe_exists("$path_client_bindir/$client_name"); my $args; mtr_init_args(\$args); mtr_add_arg($args, "--defaults-file=%s", $path_config_file); - client_debug_arg($args, $client_name); + if (defined($group_suffix)) { + mtr_add_arg($args, "--defaults-group-suffix=%s", $group_suffix); + client_debug_arg($args, "$client_name-$group_suffix"); + } + else + { + client_debug_arg($args, $client_name); + } return mtr_args2str($client_exe, @$args); } @@ -1858,6 +1866,7 @@ sub environment_setup { $ENV{'MYSQL_SHOW'}= client_arguments("mysqlshow"); $ENV{'MYSQL_BINLOG'}= client_arguments("mysqlbinlog"); $ENV{'MYSQL'}= client_arguments("mysql"); + $ENV{'MYSQL_SLAVE'}= client_arguments("mysql", ".2"); $ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade"); $ENV{'MYSQLADMIN'}= native_path($exe_mysqladmin); $ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments(); diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 919aff4bfb7..3f91039d592 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -633,4 +633,9 @@ SELECT * FROM t2; c1 15449237462 DROP TABLE t1, t2; +CREATE TABLE t1(f1 FLOAT); +INSERT INTO t1 VALUES (1.23); +CREATE TABLE t2(f1 CHAR(1)); +INSERT INTO t2 SELECT f1 FROM t1; +DROP TABLE t1, t2; End of 5.0 tests. diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index 35bc7376296..d8768e802ea 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -96,6 +96,61 @@ alter table t1 auto_increment=0; alter table t1 auto_increment=0; unlock tables; drop table t1; +create table t1 (a int); +create table t2 like t1; +# con1 +lock tables t1 write; +# con2 +flush tables with read lock; +# con5 +# global read lock is taken +# con3 +select * from t2 for update; +# waiting for release of read lock +# con4 +# would hang and later cause a deadlock +flush tables t2; +# clean up +unlock tables; +unlock tables; +a +drop table t1,t2; +# +# Lightweight version: +# Ensure that the wait for a GRL is done before opening tables. +# +create table t1 (a int); +create table t2 like t1; +# +# UPDATE +# +# default +flush tables with read lock; +# con1 +update t2 set a = 1; +# default +# statement is waiting for release of read lock +# con2 +flush table t2; +# default +unlock tables; +# con1 +# +# LOCK TABLES .. WRITE +# +# default +flush tables with read lock; +# con1 +lock tables t2 write; +# default +# statement is waiting for release of read lock +# con2 +flush table t2; +# default +unlock tables; +# con1 +unlock tables; +drop table t1,t2; End of 5.0 tests create table t1 (i int); lock table t1 read; diff --git a/mysql-test/r/myisam_crash_before_flush_keys.result b/mysql-test/r/myisam_crash_before_flush_keys.result new file mode 100644 index 00000000000..372f2e41590 --- /dev/null +++ b/mysql-test/r/myisam_crash_before_flush_keys.result @@ -0,0 +1,45 @@ +# +# BUG#41330 - Myisam table open count set to zero before index blocks are written. +# +# Don't test this under valgrind, memory leaks will occur +# Binary must be compiled with debug for crash to occur +SET GLOBAL delay_key_write=ALL; +CREATE TABLE t1(a INT, +b INT, +PRIMARY KEY(a , b), +KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1; +INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6); +# Setup the mysqld to crash at certain point +SET SESSION debug="d,crash_before_flush_keys"; +# Write file to make mysql-test-run.pl expect crash +# Run the crashing query +FLUSH TABLE t1; +ERROR HY000: Lost connection to MySQL server during query +# Run MYISAMCHK tool to check the table t1 and repair +myisamchk: MyISAM file MYSQLD_DATADIR/test/t1 +myisamchk: warning: 1 client is using or hasn't closed the table properly +myisamchk: error: Size of indexfile is: 1024 Should be: 3072 +MYISAMCHK: Unknown error 126 +myisamchk: error: Can't read indexpage from filepos: 1024 +MyISAM-table 'MYSQLD_DATADIR/test/t1' is corrupted +Fix it using switch "-r" or "-o" +# Write file to make mysql-test-run.pl start the server +# Turn on reconnect +# Call script that will poll the server waiting for +# it to be back online again +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`a`,`b`), + KEY `b` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DELAY_KEY_WRITE=1 +SELECT * FROM t1 FORCE INDEX (PRIMARY); +a b +1 2 +2 3 +3 4 +4 5 +5 6 +DROP TABLE t1; diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index dc7f3e396d1..fbcd8aed17a 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -65,3 +65,25 @@ SELECT COUNT(*) FROM t1; COUNT(*) 1024 DROP TABLE t1; +# +# Bug #43973 - backup_myisam.test fails on 6.0-bugteam +# +CREATE DATABASE mysql_db1; +CREATE TABLE mysql_db1.t1 (c1 VARCHAR(5), c2 int); +CREATE INDEX i1 ON mysql_db1.t1 (c1, c2); +INSERT INTO mysql_db1.t1 VALUES ('A',1); +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +FLUSH TABLE mysql_db1.t1; +# Compress the table using MYISAMPACK tool +# Run MYISAMCHK tool on the compressed table +SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5; +COUNT(*) +128 +DROP TABLE mysql_db1.t1; +DROP DATABASE mysql_db1; diff --git a/mysql-test/r/mysqlbinlog_row_big.result b/mysql-test/r/mysqlbinlog_row_big.result index f2ca72f9936..46fa0dc79cd 100644 --- a/mysql-test/r/mysqlbinlog_row_big.result +++ b/mysql-test/r/mysqlbinlog_row_big.result @@ -9,7 +9,17 @@ SET timestamp=1000000000; # # We need big packets. # +# Capture initial value to reset at the end of the test +# Now adjust max_allowed_packet SET @@global.max_allowed_packet= 1024*1024*1024; +max_allowed_packet is a global variable. +In order for the preceding change in max_allowed_packets' value +to be seen and used, we must start a new connection. +The change does not take effect with the current one. +For simplicity, we just disconnect / reconnect connection default here. +Disconnecting default connection... +Reconnecting default connection... +default connection established, continuing with the test # # Delete all existing binary logs. # @@ -21,40 +31,56 @@ CREATE TABLE t1 ( c1 LONGTEXT ) ENGINE=MyISAM DEFAULT CHARSET latin1; # -# Show how much rows are affected by each statement. +# Show how many rows are affected by each statement. # # -# Insert a big row. +# Insert some big rows. # +256MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216)); +affected rows: 1 +32MB INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152)); affected rows: 1 +4MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144)); +affected rows: 1 +512KB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768)); +affected rows: 1 # # Show what we have in the table. # Do not display the column value itself, just its length. # SELECT LENGTH(c1) FROM t1; +LENGTH(c1) 268435456 LENGTH(c1) 33554432 -affected rows: 1 +LENGTH(c1) 4194304 +LENGTH(c1) 524288 +affected rows: 4 # -# Grow the row by updating. +# Grow the rows by updating. # UPDATE t1 SET c1 = CONCAT(c1, c1); -affected rows: 1 -info: Rows matched: 1 Changed: 1 Warnings: 0 +affected rows: 4 +info: Rows matched: 4 Changed: 4 Warnings: 0 # # Show what we have in the table. # Do not display the column value itself, just its length. # SELECT LENGTH(c1) FROM t1; +LENGTH(c1) 536870912 +LENGTH(c1) 1048576 LENGTH(c1) 67108864 -affected rows: 1 +LENGTH(c1) 8388608 +affected rows: 4 # -# Delete the row. +# Delete the rows. # DELETE FROM t1 WHERE c1 >= 'ManyMegaByteBlck'; -affected rows: 1 +affected rows: 4 # -# Hide how much rows are affected by each statement. +# Hide how many rows are affected by each statement. # # # Flush all log buffers to the log file. @@ -70,5 +96,7 @@ FLUSH LOGS; # # Cleanup. # +# reset variable value to pass testcase checks +SET @@global.max_allowed_packet = 1048576; DROP TABLE t1; remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 002fbd02c2a..097f6dc69ff 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -615,3 +615,55 @@ UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0; SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')}; a1 a4 DROP TABLE t1, t2, t3; +# +# Bug#39559: dump of stored procedures / functions with C-style +# comment can't be read back +# ++----------+--------+ +| expected | result | ++----------+--------+ +| 2 | 2 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 1 | 1 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 3 | 3 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 2 | 2 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 7 | 7 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 8 | 8 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 7 | 7 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 4 | 4 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 4 | 4 | ++----------+--------+ +# +# End of 5.1 tests +# diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index adf81efe8e3..711e69094f7 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -84,3 +84,23 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin2 drop database `a-b-c`; drop database `tabc`; +use `#mysql50#a-b-c`; +create table t1(f1 char(10)); +show databases like '%a-b-c%'; +Database (%a-b-c%) +#mysql50#a-b-c +ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME; +show databases like '%a-b-c%'; +Database (%a-b-c%) +a-b-c +show create view `a-b-c`.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `a`.`f1` AS `f1` from (`a-b-c`.`t1` `a` join `information_schema`.`tables` `b`) where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`) utf8 utf8_general_ci +Warnings: +Note 1600 Creation context of view `a-b-c`.`v1' is invalid +select * from `a-b-c`.v1; +f1 +Warnings: +Note 1600 Creation context of view `a-b-c`.`v1' is invalid +drop database `a-b-c`; +use test; diff --git a/mysql-test/suite/binlog/r/binlog_stm_ps.result b/mysql-test/suite/binlog/r/binlog_stm_ps.result index 1cf7429987e..ea7cc6f16df 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ps.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ps.result @@ -11,7 +11,7 @@ prepare s from "insert into t1 select 100 limit ?"; set @a=100; execute s using @a; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index a0809c79fa2..675c327e9e7 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -10,25 +10,25 @@ INSERT DELAYED INTO t1 VALUES (5); ---- Insert directly ---- INSERT INTO t1 VALUES (@@global.sync_binlog); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. INSERT INTO t1 VALUES (@@session.insert_id); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. INSERT INTO t1 VALUES (@@global.auto_increment_increment); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. INSERT INTO t2 SELECT UUID(); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. INSERT INTO t2 VALUES (@@session.sql_mode); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. INSERT INTO t2 VALUES (@@global.init_slave); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. INSERT INTO t2 VALUES (@@hostname); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. ---- Insert from stored procedure ---- CREATE PROCEDURE proc() BEGIN @@ -42,13 +42,13 @@ INSERT INTO t2 VALUES (@@hostname); END| CALL proc(); Warnings: -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. ---- Insert from stored function ---- CREATE FUNCTION func() RETURNS INT @@ -66,13 +66,13 @@ SELECT func(); func() 0 Warnings: -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. ---- Insert from trigger ---- CREATE TRIGGER trig BEFORE INSERT ON trigger_table @@ -88,14 +88,14 @@ INSERT INTO t2 VALUES (@@hostname); END| INSERT INTO trigger_table VALUES ('bye.'); Warnings: -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. ---- Insert from prepared statement ---- PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)'; PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)'; @@ -106,25 +106,25 @@ PREPARE p6 FROM 'INSERT INTO t2 VALUES (@@global.init_slave)'; PREPARE p7 FROM 'INSERT INTO t2 VALUES (@@hostname)'; EXECUTE p1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. EXECUTE p2; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. EXECUTE p3; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. EXECUTE p4; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. EXECUTE p5; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. EXECUTE p6; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. EXECUTE p7; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. ---- Insert from nested call of triggers / functions / procedures ---- CREATE PROCEDURE proc1() INSERT INTO trigger_table VALUES ('ha!')| @@ -154,13 +154,13 @@ EXECUTE prep6; func5() 0 Warnings: -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. ==== Variables that should *not* be unsafe ==== INSERT INTO t1 VALUES (@@session.pseudo_thread_id); INSERT INTO t1 VALUES (@@session.pseudo_thread_id); @@ -195,16 +195,16 @@ DROP TABLE t1, t2, t3, trigger_table, trigger_table2; CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b)); INSERT INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. REPLACE INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. UPDATE t1 SET a=1 LIMIT 1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. DELETE FROM t1 LIMIT 1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. CREATE PROCEDURE p1() BEGIN INSERT INTO t1 SELECT * FROM t1 LIMIT 1; @@ -214,10 +214,10 @@ DELETE FROM t1 LIMIT 1; END| CALL p1(); Warnings: -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. DROP PROCEDURE p1; DROP TABLE t1; DROP TABLE IF EXISTS t1; @@ -225,7 +225,7 @@ CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100)); INSERT INTO t1 VALUES ('a','b'); UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. DROP TABLE t1; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1(i INT PRIMARY KEY); @@ -234,7 +234,7 @@ CREATE TABLE t3(i INT, ch CHAR(50)); "Should issue message Statement is not safe to log in statement format." INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. CREATE FUNCTION func6() RETURNS INT BEGIN @@ -246,7 +246,7 @@ END| "Should issue message Statement is not safe to log in statement format only once" INSERT INTO t3 VALUES(func6(), UUID()); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements" CREATE FUNCTION fun_check_log_bin() RETURNS INT BEGIN @@ -259,7 +259,7 @@ SELECT fun_check_log_bin(); fun_check_log_bin() 100 Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. "SQL_LOG_BIN should be ON still" SHOW VARIABLES LIKE "SQL_LOG_BIN"; Variable_name Value @@ -309,4 +309,22 @@ DROP FUNCTION func7; DROP TRIGGER trig; DROP TABLE t1, t2, t3, trigger_table; set @@SESSION.SQL_LOG_BIN = @save_log_bin; +SET @save_sql_mode = @@SESSION.SQL_MODE; +SET @@SESSION.SQL_MODE = STRICT_ALL_TABLES; +CREATE TABLE t1(i INT PRIMARY KEY); +CREATE TABLE t2(i INT PRIMARY KEY); +INSERT INTO t1 SELECT * FROM t2 LIMIT 1; +Warnings: +Note 1592 Statement is not safe to log in statement format. +INSERT INTO t1 VALUES(@@global.sync_binlog); +Warnings: +Note 1592 Statement is not safe to log in statement format. +UPDATE t1 SET i = 999 LIMIT 1; +Warnings: +Note 1592 Statement is not safe to log in statement format. +DELETE FROM t1 LIMIT 1; +Warnings: +Note 1592 Statement is not safe to log in statement format. +DROP TABLE t1, t2; +SET @@SESSION.SQL_MODE = @save_sql_mode; "End of tests" diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 642dc3a46f7..1b0f0a6c30a 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -46,6 +46,7 @@ # BUG#34732: mysqlbinlog does not print default values for auto_increment variables # BUG#34768: nondeterministic INSERT using LIMIT logged in stmt mode if binlog_format=mixed # BUG#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0 +# BUG#42640: mysqld crashes when unsafe statements are executed (STRICT_TRANS_TABLES mode) # # ==== Related test cases ==== # @@ -369,4 +370,22 @@ DROP FUNCTION func7; DROP TRIGGER trig; DROP TABLE t1, t2, t3, trigger_table; set @@SESSION.SQL_LOG_BIN = @save_log_bin; + +# +# For BUG#42640: mysqld crashes when unsafe statements are executed (STRICT_TRANS_TABLES mode) +# +SET @save_sql_mode = @@SESSION.SQL_MODE; +SET @@SESSION.SQL_MODE = STRICT_ALL_TABLES; + +CREATE TABLE t1(i INT PRIMARY KEY); +CREATE TABLE t2(i INT PRIMARY KEY); + +INSERT INTO t1 SELECT * FROM t2 LIMIT 1; +INSERT INTO t1 VALUES(@@global.sync_binlog); + +UPDATE t1 SET i = 999 LIMIT 1; +DELETE FROM t1 LIMIT 1; + +DROP TABLE t1, t2; +SET @@SESSION.SQL_MODE = @save_sql_mode; --echo "End of tests" diff --git a/mysql-test/suite/rpl/r/rpl_bug33931.result b/mysql-test/suite/rpl/r/rpl_bug33931.result index 1b3f2cfc7dc..85c8fb0da9c 100644 --- a/mysql-test/suite/rpl/r/rpl_bug33931.result +++ b/mysql-test/suite/rpl/r/rpl_bug33931.result @@ -1,5 +1,5 @@ reset master; -call mtr.add_suppression("Failed during slave.*thread initialization"); +call mtr.add_suppression("Failed during slave thread initialization"); stop slave; reset slave; SET GLOBAL debug="d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init"; @@ -23,8 +23,8 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 0 -Last_Error +Last_Errno # +Last_Error Failed during slave thread initialization Skip_Counter 0 Exec_Master_Log_Pos 0 Relay_Log_Space # @@ -41,6 +41,6 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno 0 Last_IO_Error -Last_SQL_Errno 0 -Last_SQL_Error +Last_SQL_Errno # +Last_SQL_Error Failed during slave thread initialization SET GLOBAL debug=""; diff --git a/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result b/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result index 1753fc0cb2d..6c8d35619e5 100644 --- a/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result @@ -4,51 +4,57 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +*** Prepare tables and data *** CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=innodb; -CREATE TABLE t2 (a INT NOT NULL, KEY(a)) ENGINE=innodb; -CREATE TABLE t3 (a INT UNIQUE) ENGINE=innodb; -CREATE TABLE t4 (a INT) ENGINE=innodb; -show variables like 'slave_transaction_retries'; -Variable_name Value -slave_transaction_retries 10 -show create table t1; +CREATE TABLE t2 (a INT) ENGINE=innodb; +CREATE TABLE t3 (a INT NOT NULL, KEY(a)) ENGINE=innodb; +SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, KEY `a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -show create table t2; +SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL, KEY `a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -show variables like 'slave_transaction_retries'; +SHOW VARIABLES LIKE 'slave_transaction_retries'; Variable_name Value slave_transaction_retries 2 -stop slave; -begin; -insert into t2 values (0); -insert into t1 values(1); -commit; -begin; -select * from t1 for update; +include/stop_slave.inc +BEGIN; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2), (2), (2), (2), (2), (2), (2), (2), (2), (2); +INSERT INTO t3 VALUES (3); +COMMIT; + +*** Test deadlock *** +BEGIN; +SELECT * FROM t1 FOR UPDATE; a -start slave; -select * from t2 for update /* dl */; -a -commit; -select * from t1; +START SLAVE; +SELECT COUNT(*) FROM t2; +COUNT(*) +0 +COMMIT; +SELECT * FROM t1; a 1 -select * from t2 /* must be 1 */; +SELECT * FROM t3; a -0 -show slave status; +3 +SHOW SLAVE STATUS; Slave_IO_State # Master_Host 127.0.0.1 Master_User root -Master_Port MASTER_MYPORT +Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 Read_Master_Log_Pos # @@ -83,102 +89,41 @@ Last_IO_Errno # Last_IO_Error # Last_SQL_Errno 0 Last_SQL_Error -stop slave; -delete from t3; -change master to master_log_pos=548; -begin; -select * from t2 for update; + +*** Test lock wait timeout *** +include/stop_slave.inc +DELETE FROM t2; +CHANGE MASTER TO MASTER_LOG_POS=MASTER_POS_BEGIN; +BEGIN; +SELECT * FROM t1 FOR UPDATE; a +1 +START SLAVE; +SELECT COUNT(*) FROM t2; +COUNT(*) 0 -start slave; -select count(*) from t3 /* must be zero */; -count(*) -0 -commit; -select * from t1; +COMMIT; +include/start_slave.inc +SELECT * FROM t1; a 1 1 -select * from t2; +SELECT * FROM t3; a -0 -0 -show slave status; +3 +3 +SHOW SLAVE STATUS; Slave_IO_State # Master_Host 127.0.0.1 Master_User root -Master_Port MASTER_MYPORT +Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 Read_Master_Log_Pos # Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 -Slave_IO_Running # -Slave_SQL_Running Yes -Replicate_Do_DB -Replicate_Ignore_DB -Replicate_Do_Table -Replicate_Ignore_Table # -Replicate_Wild_Do_Table -Replicate_Wild_Ignore_Table -Last_Errno 0 -Last_Error -Skip_Counter 0 -Exec_Master_Log_Pos # -Relay_Log_Space # -Until_Condition None -Until_Log_File -Until_Log_Pos 0 -Master_SSL_Allowed No -Master_SSL_CA_File -Master_SSL_CA_Path -Master_SSL_Cert -Master_SSL_Cipher -Master_SSL_Key -Seconds_Behind_Master # -Master_SSL_Verify_Server_Cert No -Last_IO_Errno 0 -Last_IO_Error -Last_SQL_Errno 0 -Last_SQL_Error -set @my_max_relay_log_size= @@global.max_relay_log_size; -set global max_relay_log_size=0; -stop slave; -delete from t3; -change master to master_log_pos=548; -begin; -select * from t2 for update; -a -0 -0 -start slave; -select count(*) from t3 /* must be zero */; -count(*) -0 -commit; -select * from t1; -a -1 -1 -1 -select * from t2; -a -0 -0 -0 -show slave status; -Slave_IO_State # -Master_Host 127.0.0.1 -Master_User root -Master_Port MASTER_MYPORT -Connect_Retry 1 -Master_Log_File master-bin.000001 -Read_Master_Log_Pos # -Relay_Log_File # -Relay_Log_Pos # -Relay_Master_Log_File master-bin.000001 -Slave_IO_Running # +Slave_IO_Running Yes Slave_SQL_Running Yes Replicate_Do_DB Replicate_Ignore_DB @@ -206,6 +151,75 @@ Last_IO_Errno # Last_IO_Error # Last_SQL_Errno 0 Last_SQL_Error -drop table t1,t2,t3,t4; -set global max_relay_log_size= @my_max_relay_log_size; + +*** Test lock wait timeout and purged relay logs *** +SET @my_max_relay_log_size= @@global.max_relay_log_size; +SET global max_relay_log_size=0; +include/stop_slave.inc +DELETE FROM t2; +CHANGE MASTER TO MASTER_LOG_POS=440; +BEGIN; +SELECT * FROM t1 FOR UPDATE; +a +1 +1 +START SLAVE; +SELECT COUNT(*) FROM t2; +COUNT(*) +0 +COMMIT; +include/start_slave.inc +SELECT * FROM t1; +a +1 +1 +1 +SELECT * FROM t3; +a +3 +3 +3 +SHOW SLAVE STATUS; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos # +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running Yes +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table # +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos # +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # +Master_SSL_Verify_Server_Cert No +Last_IO_Errno # +Last_IO_Error # +Last_SQL_Errno 0 +Last_SQL_Error + +*** Clean up *** +DROP TABLE t1,t2,t3; +SET global max_relay_log_size= @my_max_relay_log_size; End of 5.1 tests diff --git a/mysql-test/suite/rpl/r/rpl_idempotency.result b/mysql-test/suite/rpl/r/rpl_idempotency.result index f39d0f1f37f..3341c03db0f 100644 --- a/mysql-test/suite/rpl/r/rpl_idempotency.result +++ b/mysql-test/suite/rpl/r/rpl_idempotency.result @@ -141,9 +141,9 @@ select * from ti1 order by b /* must be (2),(3) */; b 2 3 -*** slave must stop +*** slave must stop (Trying to delete a referenced foreing key) Last_SQL_Error -0 +1451 select * from ti1 order by b /* must be (1),(2),(3) - not deleted */; b 1 @@ -159,7 +159,7 @@ set global slave_exec_mode='STRICT'; *** conspire future problem delete from ti1 where b=3; insert into ti2 set a=3, b=3 /* offending write event */; -*** slave must stop +*** slave must stop (Trying to insert an invalid foreign key) Last_SQL_Error 1452 select * from ti2 order by b /* must be (2,2) */; @@ -179,7 +179,7 @@ a b *** conspiring query insert into ti1 set b=1; insert into ti1 set b=1 /* offending write event */; -*** slave must stop +*** slave must stop (Trying to insert a dupliacte key) Last_SQL_Error 1062 set foreign_key_checks= 0; @@ -195,32 +195,32 @@ INSERT INTO t2 VALUES (-1),(-2),(-3); DELETE FROM t1 WHERE a = -2; DELETE FROM t2 WHERE a = -2; DELETE FROM t1 WHERE a = -2; -*** slave must stop +*** slave must stop (Key was not found) Last_SQL_Error 1032 set global slave_exec_mode='IDEMPOTENT'; start slave sql_thread; set global slave_exec_mode='STRICT'; DELETE FROM t2 WHERE a = -2; -*** slave must stop +*** slave must stop (Key was not found) Last_SQL_Error -0 +1032 set global slave_exec_mode='IDEMPOTENT'; start slave sql_thread; set global slave_exec_mode='STRICT'; UPDATE t1 SET a = 1 WHERE a = -1; UPDATE t2 SET a = 1 WHERE a = -1; UPDATE t1 SET a = 1 WHERE a = -1; -*** slave must stop +*** slave must stop (Key was not found) Last_SQL_Error 1032 set global slave_exec_mode='IDEMPOTENT'; start slave sql_thread; set global slave_exec_mode='STRICT'; UPDATE t2 SET a = 1 WHERE a = -1; -*** slave must stop +*** slave must stop (Key was not found) Last_SQL_Error -0 +1032 set global slave_exec_mode='IDEMPOTENT'; start slave sql_thread; SET @@global.slave_exec_mode= @old_slave_exec_mode; diff --git a/mysql-test/suite/rpl/r/rpl_init_slave_errors.result b/mysql-test/suite/rpl/r/rpl_init_slave_errors.result new file mode 100644 index 00000000000..ab957e6d9bc --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_init_slave_errors.result @@ -0,0 +1,18 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +stop slave; +reset slave; +SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init"; +start slave; +Reporting the following error: Failed during slave thread initialization +SET GLOBAL debug= ""; +stop slave; +reset slave; +SET GLOBAL init_slave= "garbage"; +start slave; +Reporting the following error: Slave SQL thread aborted. Can't execute init_slave query +SET GLOBAL init_slave= ""; diff --git a/mysql-test/suite/rpl/r/rpl_killed_ddl.result b/mysql-test/suite/rpl/r/rpl_killed_ddl.result new file mode 100644 index 00000000000..a15b3c30766 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_killed_ddl.result @@ -0,0 +1,169 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +DROP DATABASE IF EXISTS d1; +DROP DATABASE IF EXISTS d2; +DROP DATABASE IF EXISTS d3; +DROP DATABASE IF EXISTS d4; +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; +DROP EVENT IF EXISTS e3; +DROP EVENT IF EXISTS e4; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +DROP SERVER IF EXISTS s1; +DROP SERVER IF EXISTS s2; +DROP SERVER IF EXISTS s3; +DROP SERVER IF EXISTS s4; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +DROP TABLE IF EXISTS t4; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +DROP TRIGGER IF EXISTS tr1; +DROP TRIGGER IF EXISTS tr2; +DROP TRIGGER IF EXISTS tr3; +DROP TRIGGER IF EXISTS tr4; +CREATE DATABASE d1; +CREATE EVENT e1 +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY +DO INSERT INTO test.t1 VALUES (1); +CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC +RETURN 1; +CREATE PROCEDURE p1 (OUT rows INT) +BEGIN +SELECT COUNT(*) INTO rows FROM t1; +END; +// +CREATE SERVER s1 +FOREIGN DATA WRAPPER mysql +OPTIONS (USER 'user1', HOST '192.168.1.106', DATABASE 'test'); +CREATE TABLE t1 (a int); +CREATE TABLE t3 (a int); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 +FOR EACH ROW BEGIN +DELETE FROM t4 WHERE a=NEW.a; +END; +// +CREATE INDEX i1 ON t1 (a); +CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100; +[on master] +[on master1] +CREATE DATABASE d2; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP DATABASE d1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP DATABASE d2; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE EVENT e2 +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY +DO INSERT INTO test.t1 VALUES (2); +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP EVENT e1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP EVENT IF EXISTS e2; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC +RETURN 1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +ALTER FUNCTION f1 SQL SECURITY INVOKER; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP FUNCTION f1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE PROCEDURE p2 (OUT rows INT) +BEGIN +SELECT COUNT(*) INTO rows FROM t2; +END; +// +source include/kill_query.inc; +source include/diff_master_slave.inc; +ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows of table t1'; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP PROCEDURE p1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE TABLE t2 (b int); +source include/kill_query.inc; +source include/diff_master_slave.inc; +ALTER TABLE t1 ADD (d int); +source include/kill_query.inc; +source include/diff_master_slave.inc; +RENAME TABLE t3 TO t4; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE INDEX i2 on t1 (a); +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP INDEX i1 on t1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE TRIGGER tr2 BEFORE INSERT ON t4 +FOR EACH ROW BEGIN +DELETE FROM t1 WHERE a=NEW.a; +END; +// +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP TRIGGER tr1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP TRIGGER IF EXISTS tr2; +source include/kill_query.inc; +source include/diff_master_slave.inc; +CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP VIEW v1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP VIEW IF EXISTS v2; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP TABLE t1; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP TABLE IF EXISTS t2; +source include/kill_query.inc; +source include/diff_master_slave.inc; +DROP DATABASE IF EXISTS d1; +DROP DATABASE IF EXISTS d2; +DROP DATABASE IF EXISTS d3; +DROP DATABASE IF EXISTS d4; +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; +DROP EVENT IF EXISTS e3; +DROP EVENT IF EXISTS e4; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +DROP SERVER IF EXISTS s1; +DROP SERVER IF EXISTS s2; +DROP SERVER IF EXISTS s3; +DROP SERVER IF EXISTS s4; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +DROP TABLE IF EXISTS t4; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; diff --git a/mysql-test/r/rpl_name_const.result b/mysql-test/suite/rpl/r/rpl_name_const.result similarity index 100% rename from mysql-test/r/rpl_name_const.result rename to mysql-test/suite/rpl/r/rpl_name_const.result diff --git a/mysql-test/suite/rpl/r/rpl_skip_error.result b/mysql-test/suite/rpl/r/rpl_skip_error.result index b90d8113e8e..d955859f030 100644 --- a/mysql-test/suite/rpl/r/rpl_skip_error.result +++ b/mysql-test/suite/rpl/r/rpl_skip_error.result @@ -74,19 +74,16 @@ Last_SQL_Error drop table t1; create table t1(a int primary key); insert into t1 values (1),(2); -delete from t1 where @@server_id=1; -Warnings: -Warning 1592 Statement is not safe to log in statement format. +SET SQL_LOG_BIN=0; +delete from t1; +SET SQL_LOG_BIN=1; set sql_mode=strict_trans_tables; -insert into t1 values (7), (8), (9); +insert into t1 values (1), (2), (3); [on slave] select * from t1; a 1 2 -7 -8 -9 SHOW SLAVE STATUS; Slave_IO_State # Master_Host 127.0.0.1 @@ -128,3 +125,66 @@ Last_SQL_Errno 0 Last_SQL_Error ==== Clean Up ==== drop table t1; +==== Using Innodb ==== +SET SQL_LOG_BIN=0; +CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `data` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SET SQL_LOG_BIN=1; +CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) NOT NULL, + `data` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES(1, 1); +INSERT INTO t1 VALUES(2, 1); +INSERT INTO t1 VALUES(3, 1); +INSERT INTO t1 VALUES(4, 1); +SET SQL_LOG_BIN=0; +DELETE FROM t1 WHERE id = 4; +SET SQL_LOG_BIN=1; +UPDATE t1 SET id= id + 3, data = 2; + +**** We cannot execute a select as there are differences in the +**** behavior between STMT and RBR. +==== Using MyIsam ==== +SET SQL_LOG_BIN=0; +CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `data` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SET SQL_LOG_BIN=1; +CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `data` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t2 VALUES(1, 1); +INSERT INTO t2 VALUES(2, 1); +INSERT INTO t2 VALUES(3, 1); +INSERT INTO t2 VALUES(5, 1); +SET SQL_LOG_BIN=0; +DELETE FROM t2 WHERE id = 5; +SET SQL_LOG_BIN=1; +UPDATE t2 SET id= id + 3, data = 2; + +**** We cannot execute a select as there are differences in the +**** behavior between STMT and RBR. +==== Clean Up ==== +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result index d18befe6e4c..72f58268d5f 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result +++ b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result @@ -10,7 +10,7 @@ CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a)); INSERT INTO test.t1 VALUES(1,'test'); UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1; Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. create procedure test.p1() begin INSERT INTO test.t1 VALUES(2,'test'); @@ -18,7 +18,7 @@ UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2; end| CALL test.p1(); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. SELECT * FROM test.t1 ORDER BY blob_column; a blob_column 1 abase diff --git a/mysql-test/suite/rpl/r/rpl_udf.result b/mysql-test/suite/rpl/r/rpl_udf.result index 79a82b5fbc7..56df5b30d93 100644 --- a/mysql-test/suite/rpl/r/rpl_udf.result +++ b/mysql-test/suite/rpl/r/rpl_udf.result @@ -182,19 +182,19 @@ CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); Warnings: -Warning 1592 Statement is not safe to log in statement format. +Note 1592 Statement is not safe to log in statement format. affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price diff --git a/mysql-test/suite/rpl/t/rpl_bug33931.test b/mysql-test/suite/rpl/t/rpl_bug33931.test index a439b346538..13f781c644b 100644 --- a/mysql-test/suite/rpl/t/rpl_bug33931.test +++ b/mysql-test/suite/rpl/t/rpl_bug33931.test @@ -15,7 +15,7 @@ reset master; connection slave; # Add suppression for expected warnings in slaves error log -call mtr.add_suppression("Failed during slave.*thread initialization"); +call mtr.add_suppression("Failed during slave thread initialization"); --disable_warnings stop slave; @@ -37,8 +37,8 @@ connection slave; # source include/wait_for_slave_to_stop.inc; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # +--replace_result $MASTER_MYPORT MASTER_PORT +--replace_column 1 # 8 # 9 # 19 # 23 # 33 # 37 # query_vertical show slave status; # diff --git a/mysql-test/suite/rpl/t/rpl_idempotency.test b/mysql-test/suite/rpl/t/rpl_idempotency.test index 1946aa100ab..bfd1860759e 100644 --- a/mysql-test/suite/rpl/t/rpl_idempotency.test +++ b/mysql-test/suite/rpl/t/rpl_idempotency.test @@ -208,7 +208,7 @@ select * from ti1 order by b /* must be (2),(3) */; # foreign key: row is referenced ---echo *** slave must stop +--echo *** slave must stop (Trying to delete a referenced foreing key) connection slave; source include/wait_for_slave_sql_to_stop.inc; @@ -242,7 +242,7 @@ delete from ti1 where b=3; connection master; insert into ti2 set a=3, b=3 /* offending write event */; ---echo *** slave must stop +--echo *** slave must stop (Trying to insert an invalid foreign key) connection slave; source include/wait_for_slave_sql_to_stop.inc; @@ -281,7 +281,7 @@ insert into ti1 set b=1; connection master; insert into ti1 set b=1 /* offending write event */; ---echo *** slave must stop +--echo *** slave must stop (Trying to insert a dupliacte key) connection slave; source include/wait_for_slave_sql_to_stop.inc; @@ -316,7 +316,7 @@ DELETE FROM t2 WHERE a = -2; connection master; DELETE FROM t1 WHERE a = -2; ---echo *** slave must stop +--echo *** slave must stop (Key was not found) connection slave; source include/wait_for_slave_sql_to_stop.inc; @@ -333,8 +333,8 @@ sync_slave_with_master; set global slave_exec_mode='STRICT'; connection master; -DELETE FROM t2 WHERE a = -2; ---echo *** slave must stop +DELETE FROM t2 WHERE a = -2; +--echo *** slave must stop (Key was not found) connection slave; source include/wait_for_slave_sql_to_stop.inc; @@ -356,7 +356,7 @@ UPDATE t2 SET a = 1 WHERE a = -1; connection master; UPDATE t1 SET a = 1 WHERE a = -1; ---echo *** slave must stop +--echo *** slave must stop (Key was not found) connection slave; source include/wait_for_slave_sql_to_stop.inc; @@ -376,7 +376,7 @@ set global slave_exec_mode='STRICT'; connection master; UPDATE t2 SET a = 1 WHERE a = -1; ---echo *** slave must stop +--echo *** slave must stop (Key was not found) connection slave; source include/wait_for_slave_sql_to_stop.inc; diff --git a/mysql-test/suite/rpl/t/rpl_init_slave_errors.test b/mysql-test/suite/rpl/t/rpl_init_slave_errors.test new file mode 100644 index 00000000000..4ca0de6ec66 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_init_slave_errors.test @@ -0,0 +1,86 @@ +###################################################################### +# Some errors that cause the slave SQL thread to stop are not shown in +# the Slave_SQL_Error column of "SHOW SLAVE STATUS". Instead, the error +# is only in the server's error log. +# +# Two failures and their respective reporting are verified: +# +# 1 - Failures during slave thread initialization +# 2 - Failures while processing queries passed through the init_slave +# option. +# +# In order to check the first type of failure, we inject a fault in the +# SQL/IO Threads through SET GLOBAL debug. +# +# To check the second type, we set @@global.init_slave to an invalid +# command thus preventing the initialization of the SQL Thread. +# +# Obs: +# 1 - Note that testing failures while initializing the relay log position +# is hard as the same function is called before the code reaches the point +# that we want to test. +# +# 2 - This test does not target failures that are reported while applying +# events such as duplicate keys, errors while reading the relay-log.bin*, +# etc. Such errors are already checked on other tests. +###################################################################### + +###################################################################### +# Configuring the Environment +###################################################################### +source include/have_debug.inc; +source include/master-slave.inc; +source include/have_log_bin.inc; + +connection slave; + +--disable_warnings +stop slave; +--enable_warnings +reset slave; + +###################################################################### +# Injecting faults in the threads' initialization +###################################################################### +connection slave; + +# Set debug flags on slave to force errors to occur +SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init"; + +start slave; + +# +# slave is going to stop because of emulated failures +# but there won't be any crashes nor asserts hit. +# +source include/wait_for_slave_to_stop.inc; + +let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1); +echo Reporting the following error: $error; + +SET GLOBAL debug= ""; + +###################################################################### +# Injecting faults in the init_slave option +###################################################################### +connection slave; + +--disable_warnings +stop slave; +--enable_warnings +source include/wait_for_slave_to_stop.inc; + +reset slave; + +SET GLOBAL init_slave= "garbage"; + +start slave; +source include/wait_for_slave_sql_to_stop.inc; + +let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1); +echo Reporting the following error: $error; + +###################################################################### +# Clean up +###################################################################### +SET GLOBAL init_slave= ""; diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt b/mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt new file mode 100644 index 00000000000..aaf2d8a4251 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt @@ -0,0 +1 @@ +--debug=d,debug_lock_before_query_log_event diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl.test b/mysql-test/suite/rpl/t/rpl_killed_ddl.test new file mode 100644 index 00000000000..26bd4957279 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test @@ -0,0 +1,352 @@ +# ==== Purpose ==== +# +# This test check if DDL statements are correctly binlogged when the +# thread is killed +# +# ==== Method ==== +# +# Start a DDL query and kill it, check if the error code of the binlog +# event is correct. +# +# DDL statements tested: +# CREATE/ALTER/RENAME/DROP DATABASE +# CREATE/ALTER/DROP EVENT +# CREATE/ALTER/DROP FUNCTION +# CREATE/ALTER/DROP PROCEDURE +# CREATE/ALTER/DROP SERVER +# CREATE/ALTER/RENAME/DROP TABLE +# CREATE/DROP TRIGGER +# CREATE/ALTER/DROP VIEW +# +# ==== Bugs ===== +# +# BUG#37145 +# +# ==== TODO ==== +# +# There are some part of the test are temporarily disabled because of +# the following bugs, please enable then once they get fixed: +# - BUG#44041 +# - BUG#43353 +# - BUG#25705 +# - BUG#44171 + +source include/have_debug.inc; +source include/master-slave.inc; + +# Use the DBUG_SYNC_POINT to make sure the thread running the DDL is +# waiting before creating the query log event + +let $debug_lock= "debug_lock.before_query_log_event"; + +######## INITIALIZATION ######## + +disable_warnings; +DROP DATABASE IF EXISTS d1; +DROP DATABASE IF EXISTS d2; +DROP DATABASE IF EXISTS d3; +DROP DATABASE IF EXISTS d4; +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; +DROP EVENT IF EXISTS e3; +DROP EVENT IF EXISTS e4; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +DROP SERVER IF EXISTS s1; +DROP SERVER IF EXISTS s2; +DROP SERVER IF EXISTS s3; +DROP SERVER IF EXISTS s4; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +DROP TABLE IF EXISTS t4; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +DROP TRIGGER IF EXISTS tr1; +DROP TRIGGER IF EXISTS tr2; +DROP TRIGGER IF EXISTS tr3; +DROP TRIGGER IF EXISTS tr4; +enable_warnings; + +CREATE DATABASE d1; + +CREATE EVENT e1 + ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY + DO INSERT INTO test.t1 VALUES (1); + +CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC + RETURN 1; + +DELIMITER //; +CREATE PROCEDURE p1 (OUT rows INT) + BEGIN + SELECT COUNT(*) INTO rows FROM t1; + END; + // +DELIMITER ;// + +CREATE SERVER s1 +FOREIGN DATA WRAPPER mysql +OPTIONS (USER 'user1', HOST '192.168.1.106', DATABASE 'test'); + +CREATE TABLE t1 (a int); +CREATE TABLE t3 (a int); + +DELIMITER //; +CREATE TRIGGER tr1 BEFORE INSERT ON t1 + FOR EACH ROW BEGIN + DELETE FROM t4 WHERE a=NEW.a; + END; + // +DELIMITER ;// + +CREATE INDEX i1 ON t1 (a); + +CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100; + +sync_slave_with_master; + +connection master1; +let $connection_name= master1; +let $connection_id= `SELECT CONNECTION_ID()`; + +connection master; +echo [on master]; + +# This will block the execution of a statement at the DBUG_SYNC_POINT +# with given lock name +if (`SELECT '$debug_lock' != ''`) +{ + disable_query_log; + disable_result_log; + eval SELECT IS_FREE_LOCK($debug_lock); + eval SELECT GET_LOCK($debug_lock, 10); + eval SELECT IS_FREE_LOCK($debug_lock); + enable_query_log; + enable_result_log; +} + +######## START TEST ######## + +connection master1; +echo [on master1]; + +disable_warnings; + +######## DATABASE ######## + +let $diff_statement= SHOW DATABASES LIKE 'd%'; + +send CREATE DATABASE d2; +source include/kill_query_and_diff_master_slave.inc; + +# Temporarily disabled, see BUG#44041, the ALTER DATABASE can affect the +# collation of other database on slave +#send ALTER DATABASE d1 +# DEFAULT CHARACTER SET = 'utf8'; +#source include/kill_query_and_diff_master_slave.inc; + +send DROP DATABASE d1; +source include/kill_query_and_diff_master_slave.inc; + +send DROP DATABASE d2; +source include/kill_query_and_diff_master_slave.inc; + +######## EVENT ######## + +let $diff_statement= SELECT event_name, event_body, execute_at + FROM information_schema.events where event_name like 'e%'; + +send CREATE EVENT e2 + ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY + DO INSERT INTO test.t1 VALUES (2); +source include/kill_query_and_diff_master_slave.inc; + +# Temporarily disabled because of BUG#44171, killing ALTER EVENT can +# crash the server +#send ALTER EVENT e1 +# ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 DAY; +#source include/kill_query_and_diff_master_slave.inc; + +send DROP EVENT e1; +source include/kill_query_and_diff_master_slave.inc; + +send DROP EVENT IF EXISTS e2; +source include/kill_query_and_diff_master_slave.inc; + +######## FUNCTION ######## + +let $diff_statement= SHOW FUNCTION STATUS LIKE 'f%'; + +send CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC + RETURN 1; +source include/kill_query_and_diff_master_slave.inc; + +send ALTER FUNCTION f1 SQL SECURITY INVOKER; +source include/kill_query_and_diff_master_slave.inc; + +# function f1 probably does not exist because the ALTER query was +# killed +send DROP FUNCTION f1; +source include/kill_query_and_diff_master_slave.inc; + +# function f2 probably does not exist because the CREATE query was +# killed +# +# Temporarily disabled. Because of BUG#43353, KILL the query may +# result in function not found, and for 5.1, DROP statements will be +# logged if the function is not found on master, so the following DROP +# FUNCTION statement may be interrupted and not drop the function on +# master, but still get logged and executed on slave and cause +# inconsistence. Also disable the following DROP PROCEDURE IF EXITS +# below. +#send DROP FUNCTION IF EXISTS f2; +#source include/kill_query_and_diff_master_slave.inc; + +######## PROCEDURE ######## + +let $diff_statement= SHOW PROCEDURE STATUS LIKE 'p%'; + +DELIMITER //; +send CREATE PROCEDURE p2 (OUT rows INT) + BEGIN + SELECT COUNT(*) INTO rows FROM t2; + END; + // +DELIMITER ;// +source include/kill_query_and_diff_master_slave.inc; + +send ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows of table t1'; +source include/kill_query_and_diff_master_slave.inc; + +send DROP PROCEDURE p1; +source include/kill_query_and_diff_master_slave.inc; + +# Temporarily disabled, see comment above for DROP FUNCTION IF EXISTS +#send DROP PROCEDURE IF EXISTS p2; +#source include/kill_query_and_diff_master_slave.inc; + +######## TABLE ######## + +let $diff_statement= SHOW TABLES LIKE 't%'; + +send CREATE TABLE t2 (b int); +source include/kill_query_and_diff_master_slave.inc; + +send ALTER TABLE t1 ADD (d int); +source include/kill_query_and_diff_master_slave.inc; + +send RENAME TABLE t3 TO t4; +source include/kill_query_and_diff_master_slave.inc; + +######## INDEX ######## + +let $diff_statement= SHOW INDEX FROM t1; + +send CREATE INDEX i2 on t1 (a); +source include/kill_query_and_diff_master_slave.inc; + +send DROP INDEX i1 on t1; +source include/kill_query_and_diff_master_slave.inc; + + +######## SERVER ######## + +# Tempoarily disabled, see bug#25705 + +# let $diff_statement= SELECT * FROM mysql.server WHERE name like 's%'; + +# send CREATE SERVER s2 +# FOREIGN DATA WRAPPER mysql +# OPTIONS (USER 'user2', HOST '192.168.1.108', DATABASE 'test'); +# source include/kill_query_and_diff_master_slave.inc; + +# send ALTER SERVER s1 +# OPTIONS (DATABASE 'test1'); +# source include/kill_query_and_diff_master_slave.inc; + +# send DROP SERVER s1; +# source include/kill_query_and_diff_master_slave.inc; + +# send DROP SERVER IF EXIST s1; +# source include/kill_query_and_diff_master_slave.inc; + +######## TRIGGER ######## + +let $diff_statement= SHOW TRIGGERS LIKE 'v%'; + +DELIMITER //; +send CREATE TRIGGER tr2 BEFORE INSERT ON t4 + FOR EACH ROW BEGIN + DELETE FROM t1 WHERE a=NEW.a; + END; + // +DELIMITER ;// +source include/kill_query_and_diff_master_slave.inc; + +send DROP TRIGGER tr1; +source include/kill_query_and_diff_master_slave.inc; + +send DROP TRIGGER IF EXISTS tr2; +source include/kill_query_and_diff_master_slave.inc; + +######## VIEW ######## + +let $diff_statement= SHOW TABLES LIKE 'v%'; + +send CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100; +source include/kill_query_and_diff_master_slave.inc; + +send DROP VIEW v1; +source include/kill_query_and_diff_master_slave.inc; + +send DROP VIEW IF EXISTS v2; +source include/kill_query_and_diff_master_slave.inc; + +######## DROP TABLE ######## + +let $diff_statement= SHOW TABLES LIKE 't%'; + +send DROP TABLE t1; +source include/kill_query_and_diff_master_slave.inc; + +send DROP TABLE IF EXISTS t2; +source include/kill_query_and_diff_master_slave.inc; + +######## CLEAN UP ######## + +connection master; + +# The DROP statements above are killed during the process, so they +# does not make sure the objects are dropped. + +disable_warnings; +DROP DATABASE IF EXISTS d1; +DROP DATABASE IF EXISTS d2; +DROP DATABASE IF EXISTS d3; +DROP DATABASE IF EXISTS d4; +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; +DROP EVENT IF EXISTS e3; +DROP EVENT IF EXISTS e4; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +DROP SERVER IF EXISTS s1; +DROP SERVER IF EXISTS s2; +DROP SERVER IF EXISTS s3; +DROP SERVER IF EXISTS s4; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +DROP TABLE IF EXISTS t4; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +enable_warnings; diff --git a/mysql-test/t/rpl_name_const.test b/mysql-test/suite/rpl/t/rpl_name_const.test similarity index 100% rename from mysql-test/t/rpl_name_const.test rename to mysql-test/suite/rpl/t/rpl_name_const.test diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test index cac797d3797..9c6aa3dcb57 100644 --- a/mysql-test/suite/rpl/t/rpl_skip_error.test +++ b/mysql-test/suite/rpl/t/rpl_skip_error.test @@ -8,18 +8,23 @@ # ==== Method ==== # # We run the slave with --slave-skip-errors=1062 (the code for -# duplicate key). On slave, we insert value 1 in a table, and then, -# on master, we insert value 1 in the table. The error should be -# ignored on slave. -# +# duplicate key). Then we have two set of tests. In the first +# set, we insert value 1 in a table on the slave, and then, on +# master, we insert value 1 in the table. In the second set, we +# insert several values on the master, disable the binlog and +# delete one of the values and re-enable the binlog. Right after, +# we perform an update on the set of values in order to generate +# a duplicate key on the slave. The errors should be ignored on +# the slave. +# # ==== Related bugs ==== # # BUG#28839: Errors in strict mode silently stop SQL thread if --slave-skip-errors exists -# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic +# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic: +# BUG#39393: slave-skip-errors does not work when using ROW based replication source include/master-slave.inc; -source include/have_binlog_format_statement.inc; - +source include/have_innodb.inc; --echo ==== Test Without sql_mode=strict_trans_tables ==== @@ -64,9 +69,11 @@ sync_slave_with_master; connection master; create table t1(a int primary key); insert into t1 values (1),(2); -delete from t1 where @@server_id=1; +SET SQL_LOG_BIN=0; +delete from t1; +SET SQL_LOG_BIN=1; set sql_mode=strict_trans_tables; -insert into t1 values (7), (8), (9); +insert into t1 values (1), (2), (3); --echo [on slave] sync_slave_with_master; @@ -80,3 +87,83 @@ connection master; drop table t1; sync_slave_with_master; # End of 5.0 tests + +# +# BUG#39393: slave-skip-errors does not work when using ROW based replication +# +--echo ==== Using Innodb ==== + +connection master; + +SET SQL_LOG_BIN=0; +CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB; +SHOW CREATE TABLE t1; +SET SQL_LOG_BIN=1; + +connection slave; + +CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB; +SHOW CREATE TABLE t1; + +connection master; + +INSERT INTO t1 VALUES(1, 1); +INSERT INTO t1 VALUES(2, 1); +INSERT INTO t1 VALUES(3, 1); +INSERT INTO t1 VALUES(4, 1); + +SET SQL_LOG_BIN=0; +DELETE FROM t1 WHERE id = 4; +SET SQL_LOG_BIN=1; +UPDATE t1 SET id= id + 3, data = 2; + +sync_slave_with_master; + +let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); +echo $error; + +--echo **** We cannot execute a select as there are differences in the +--echo **** behavior between STMT and RBR. + +--echo ==== Using MyIsam ==== + +connection master; + +SET SQL_LOG_BIN=0; +CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam; +SHOW CREATE TABLE t2; +SET SQL_LOG_BIN=1; + +connection slave; + +CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam; +SHOW CREATE TABLE t2; + +connection master; + +INSERT INTO t2 VALUES(1, 1); +INSERT INTO t2 VALUES(2, 1); +INSERT INTO t2 VALUES(3, 1); +INSERT INTO t2 VALUES(5, 1); + +SET SQL_LOG_BIN=0; +DELETE FROM t2 WHERE id = 5; +SET SQL_LOG_BIN=1; +UPDATE t2 SET id= id + 3, data = 2; + +sync_slave_with_master; + +let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); +echo $error; + +--echo **** We cannot execute a select as there are differences in the +--echo **** behavior between STMT and RBR. + +--echo ==== Clean Up ==== + +connection master; + +DROP TABLE t1; +DROP TABLE t2; + +sync_slave_with_master; diff --git a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result index 45ed43589a3..3858df0f4d6 100644 --- a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result @@ -44,7 +44,7 @@ SET @@global.binlog_cache_size = 10000.01; ERROR 42000: Incorrect argument type to variable 'binlog_cache_size' SET @@global.binlog_cache_size = -1024; Warnings: -Warning 1292 Truncated incorrect binlog_cache_size value: '0' +Warning 1292 Truncated incorrect binlog_cache_size value: '-1024' SELECT @@global.binlog_cache_size; @@global.binlog_cache_size 4096 diff --git a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result index 9e0e8e07470..320290fbca1 100644 --- a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result @@ -66,6 +66,8 @@ SELECT @@global.bulk_insert_buffer_size; @@global.bulk_insert_buffer_size 42949672950 SET @@global.bulk_insert_buffer_size = -1024; +Warnings: +Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-1024' SELECT @@global.bulk_insert_buffer_size; @@global.bulk_insert_buffer_size 0 @@ -80,6 +82,8 @@ SELECT @@session.bulk_insert_buffer_size; @@session.bulk_insert_buffer_size 42949672950 SET @@session.bulk_insert_buffer_size = -2; +Warnings: +Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-2' SELECT @@session.bulk_insert_buffer_size; @@session.bulk_insert_buffer_size 0 diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result index 246bf0e8734..1f7d0a52e72 100644 --- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result +++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result @@ -35,7 +35,7 @@ SELECT @@global.delayed_insert_limit; 1 SET @@global.delayed_insert_limit = -1024; Warnings: -Warning 1292 Truncated incorrect delayed_insert_limit value: '0' +Warning 1292 Truncated incorrect delayed_insert_limit value: '-1024' SELECT @@global.delayed_insert_limit; @@global.delayed_insert_limit 1 diff --git a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result index d575626b0a1..ed866b7e0b4 100644 --- a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result @@ -35,7 +35,7 @@ SELECT @@global.delayed_queue_size; 1 SET @@global.delayed_queue_size = -1024; Warnings: -Warning 1292 Truncated incorrect delayed_queue_size value: '0' +Warning 1292 Truncated incorrect delayed_queue_size value: '-1024' SELECT @@global.delayed_queue_size; @@global.delayed_queue_size 1 diff --git a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result index ed652af67d2..4811d4732df 100644 --- a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result @@ -71,7 +71,7 @@ SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228; 1 SET @@global.join_buffer_size = -1024; Warnings: -Warning 1292 Truncated incorrect join_buffer_size value: '0' +Warning 1292 Truncated incorrect join_buffer_size value: '-1024' SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228; @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228 1 @@ -103,7 +103,7 @@ SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228; 1 SET @@session.join_buffer_size = -2; Warnings: -Warning 1292 Truncated incorrect join_buffer_size value: '0' +Warning 1292 Truncated incorrect join_buffer_size value: '-2' SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228; @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228 1 diff --git a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result index 9ce1ab20993..eea782701bb 100644 --- a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result @@ -17,8 +17,6 @@ SELECT @@global.key_buffer_size BETWEEN 8 AND 36; @@global.key_buffer_size BETWEEN 8 AND 36 1 SET @@global.key_buffer_size = 1800; -Warnings: -Warning 1292 Truncated incorrect key_buffer_size value: '1800' SELECT @@global.key_buffer_size BETWEEN 8 AND 36; @@global.key_buffer_size BETWEEN 8 AND 36 1 diff --git a/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result b/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result index ba6671c87a4..6a94881dad0 100644 --- a/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result +++ b/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result @@ -74,6 +74,8 @@ SELECT @@global.log_warnings; @@global.log_warnings 100000000000 SET @@global.log_warnings = -1024; +Warnings: +Warning 1292 Truncated incorrect log_warnings value: '-1024' SELECT @@global.log_warnings; @@global.log_warnings 0 @@ -92,6 +94,8 @@ SELECT @@session.log_warnings; @@session.log_warnings 100000000000 SET @@session.log_warnings = -2; +Warnings: +Warning 1292 Truncated incorrect log_warnings value: '-2' SELECT @@session.log_warnings; @@session.log_warnings 0 diff --git a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result index 30db3f14dd4..10a42f6ab0e 100644 --- a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result @@ -1,7 +1,7 @@ SET @start_value = @@global.max_binlog_cache_size; SELECT @start_value; @start_value -18446744073709551615 +18446744073709547520 '#--------------------FN_DYNVARS_072_01------------------------#' SET @@global.max_binlog_cache_size = 5000; SET @@global.max_binlog_cache_size = DEFAULT; @@ -39,7 +39,7 @@ SELECT @@global.max_binlog_cache_size; '#--------------------FN_DYNVARS_072_04-------------------------#' SET @@global.max_binlog_cache_size = -1; Warnings: -Warning 1292 Truncated incorrect max_binlog_cache_size value: '0' +Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1' SELECT @@global.max_binlog_cache_size; @@global.max_binlog_cache_size 4096 @@ -54,7 +54,7 @@ SELECT @@global.max_binlog_cache_size; 99999997952 SET @@global.max_binlog_cache_size = -1024; Warnings: -Warning 1292 Truncated incorrect max_binlog_cache_size value: '0' +Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1024' SELECT @@global.max_binlog_cache_size; @@global.max_binlog_cache_size 4096 diff --git a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result index 8117b650651..762cfd14a3a 100644 --- a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result +++ b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result @@ -39,7 +39,7 @@ SELECT @@global.max_connect_errors; '#--------------------FN_DYNVARS_073_04-------------------------#' SET @@global.max_connect_errors = -1; Warnings: -Warning 1292 Truncated incorrect max_connect_errors value: '0' +Warning 1292 Truncated incorrect max_connect_errors value: '-1' SELECT @@global.max_connect_errors; @@global.max_connect_errors 1 @@ -54,7 +54,7 @@ SELECT @@global.max_connect_errors; 100000000000 SET @@global.max_connect_errors = -1024; Warnings: -Warning 1292 Truncated incorrect max_connect_errors value: '0' +Warning 1292 Truncated incorrect max_connect_errors value: '-1024' SELECT @@global.max_connect_errors; @@global.max_connect_errors 1 diff --git a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result index ebab80f376b..6642b6024b5 100644 --- a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result @@ -73,13 +73,13 @@ SELECT @@session.max_heap_table_size; '#------------------FN_DYNVARS_077_05-----------------------#' SET @@global.max_heap_table_size = -1; Warnings: -Warning 1292 Truncated incorrect max_heap_table_size value: '0' +Warning 1292 Truncated incorrect max_heap_table_size value: '-1' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 16384 SET @@global.max_heap_table_size = -1024; Warnings: -Warning 1292 Truncated incorrect max_heap_table_size value: '0' +Warning 1292 Truncated incorrect max_heap_table_size value: '-1024' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 16384 @@ -111,7 +111,7 @@ SELECT @@global.max_heap_table_size; 4294967296 SET @@session.max_heap_table_size = -1; Warnings: -Warning 1292 Truncated incorrect max_heap_table_size value: '0' +Warning 1292 Truncated incorrect max_heap_table_size value: '-1' SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 16384 diff --git a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result index eefb829cdae..5b1e076c188 100644 --- a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result +++ b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result @@ -77,7 +77,7 @@ SELECT @@global.max_seeks_for_key; 1 SET @@global.max_seeks_for_key = -1024; Warnings: -Warning 1292 Truncated incorrect max_seeks_for_key value: '0' +Warning 1292 Truncated incorrect max_seeks_for_key value: '-1024' SELECT @@global.max_seeks_for_key; @@global.max_seeks_for_key 1 @@ -103,7 +103,7 @@ SELECT @@session.max_seeks_for_key; 1 SET @@session.max_seeks_for_key = -2; Warnings: -Warning 1292 Truncated incorrect max_seeks_for_key value: '0' +Warning 1292 Truncated incorrect max_seeks_for_key value: '-2' SELECT @@session.max_seeks_for_key; @@session.max_seeks_for_key 1 diff --git a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result index 4b9f68c509e..808e99b739d 100644 --- a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result +++ b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result @@ -71,7 +71,7 @@ SELECT @@session.max_tmp_tables; '#------------------FN_DYNVARS_086_05-----------------------#' SET @@global.max_tmp_tables = -1024; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1024' SELECT @@global.max_tmp_tables; @@global.max_tmp_tables 1 @@ -81,7 +81,7 @@ SELECT @@global.max_tmp_tables; 4294967296 SET @@global.max_tmp_tables = -1; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1' SELECT @@global.max_tmp_tables; @@global.max_tmp_tables 1 @@ -105,7 +105,7 @@ SELECT @@session.max_tmp_tables; 4294967296 SET @@session.max_tmp_tables = -1; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1' SELECT @@session.max_tmp_tables; @@session.max_tmp_tables 1 @@ -115,7 +115,7 @@ SELECT @@session.max_tmp_tables; 429496729500 SET @@session.max_tmp_tables = -001; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1' SELECT @@session.max_tmp_tables; @@session.max_tmp_tables 1 diff --git a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result index d74586841dd..934777e38d3 100644 --- a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result +++ b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result @@ -37,7 +37,7 @@ SELECT @@global.max_write_lock_count; '#------------------FN_DYNVARS_088_04-----------------------#' SET @@global.max_write_lock_count = -1024; Warnings: -Warning 1292 Truncated incorrect max_write_lock_count value: '0' +Warning 1292 Truncated incorrect max_write_lock_count value: '-1024' SELECT @@global.max_write_lock_count; @@global.max_write_lock_count 1 @@ -47,7 +47,7 @@ SELECT @@global.max_write_lock_count; 4294967296 SET @@global.max_write_lock_count = -1; Warnings: -Warning 1292 Truncated incorrect max_write_lock_count value: '0' +Warning 1292 Truncated incorrect max_write_lock_count value: '-1' SELECT @@global.max_write_lock_count; @@global.max_write_lock_count 1 diff --git a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result index fa11659c6c5..5cf77ed6dc8 100644 --- a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result +++ b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result @@ -82,6 +82,8 @@ SELECT @@global.min_examined_row_limit; @@global.min_examined_row_limit 429496726 SET @@global.min_examined_row_limit = -1024; +Warnings: +Warning 1292 Truncated incorrect min_examined_row_limit value: '-1024' SELECT @@global.min_examined_row_limit; @@global.min_examined_row_limit 0 @@ -104,6 +106,8 @@ SELECT @@session.min_examined_row_limit; @@session.min_examined_row_limit 4294967296 SET @@session.min_examined_row_limit = -1; +Warnings: +Warning 1292 Truncated incorrect min_examined_row_limit value: '-1' SELECT @@session.min_examined_row_limit; @@session.min_examined_row_limit 0 diff --git a/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result b/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result index f2115aec2e2..29019ca5971 100644 --- a/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result +++ b/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result @@ -81,7 +81,7 @@ SELECT @@global.multi_range_count; 4294967296 SET @@global.multi_range_count = -1024; Warnings: -Warning 1292 Truncated incorrect multi_range_count value: '0' +Warning 1292 Truncated incorrect multi_range_count value: '-1024' SELECT @@global.multi_range_count; @@global.multi_range_count 1 @@ -111,7 +111,7 @@ SELECT @@session.multi_range_count; 4294967296 SET @@session.multi_range_count = -1; Warnings: -Warning 1292 Truncated incorrect multi_range_count value: '0' +Warning 1292 Truncated incorrect multi_range_count value: '-1' SELECT @@session.multi_range_count; @@session.multi_range_count 1 diff --git a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result index 00ff1dfc1ab..df2a49e4dd5 100644 --- a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result @@ -1,7 +1,7 @@ SET @start_global_value = @@global.myisam_max_sort_file_size; SELECT @start_global_value; @start_global_value -9223372036854775807 +9223372036853727232 '#--------------------FN_DYNVARS_094_01-------------------------#' SET @@global.myisam_max_sort_file_size = 500000; SET @@global.myisam_max_sort_file_size = DEFAULT; @@ -48,14 +48,20 @@ SET @@local.myisam_max_sort_file_size = 4; ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_094_05-----------------------#' SET @@global.myisam_max_sort_file_size = -1; +Warnings: +Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-1' SELECT @@global.myisam_max_sort_file_size; @@global.myisam_max_sort_file_size 0 SET @@global.myisam_max_sort_file_size = -2147483648; +Warnings: +Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483648' SELECT @@global.myisam_max_sort_file_size; @@global.myisam_max_sort_file_size 0 SET @@global.myisam_max_sort_file_size = -2147483649; +Warnings: +Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483649' SELECT @@global.myisam_max_sort_file_size; @@global.myisam_max_sort_file_size 0 diff --git a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result index 8271451cc9e..0a317d28b11 100644 --- a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result +++ b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result @@ -61,7 +61,7 @@ SELECT @@global.myisam_repair_threads ; 1 SET @@global.myisam_repair_threads = -1024; Warnings: -Warning 1292 Truncated incorrect myisam_repair_threads value: '0' +Warning 1292 Truncated incorrect myisam_repair_threads value: '-1024' SELECT @@global.myisam_repair_threads ; @@global.myisam_repair_threads 1 @@ -102,7 +102,7 @@ SELECT @@session.myisam_repair_threads ; 1 SET @@session.myisam_repair_threads = -2; Warnings: -Warning 1292 Truncated incorrect myisam_repair_threads value: '0' +Warning 1292 Truncated incorrect myisam_repair_threads value: '-2' SELECT @@session.myisam_repair_threads ; @@session.myisam_repair_threads 1 diff --git a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result index bfcada76a46..be9e415d830 100644 --- a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result @@ -61,7 +61,7 @@ SELECT @@global.myisam_sort_buffer_size ; 4 SET @@global.myisam_sort_buffer_size = -1024; Warnings: -Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0' +Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-1024' SELECT @@global.myisam_sort_buffer_size ; @@global.myisam_sort_buffer_size 4 @@ -102,7 +102,7 @@ SELECT @@session.myisam_sort_buffer_size ; 4 SET @@session.myisam_sort_buffer_size = -2; Warnings: -Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0' +Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-2' SELECT @@session.myisam_sort_buffer_size ; @@session.myisam_sort_buffer_size 4 diff --git a/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result b/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result index db133d23f79..67dae3d1291 100644 --- a/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result +++ b/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result @@ -77,7 +77,7 @@ SELECT @@global.net_retry_count; 1 SET @@global.net_retry_count = -1024; Warnings: -Warning 1292 Truncated incorrect net_retry_count value: '0' +Warning 1292 Truncated incorrect net_retry_count value: '-1024' SELECT @@global.net_retry_count; @@global.net_retry_count 1 @@ -107,7 +107,7 @@ SELECT @@session.net_retry_count; 1 SET @@session.net_retry_count = -2; Warnings: -Warning 1292 Truncated incorrect net_retry_count value: '0' +Warning 1292 Truncated incorrect net_retry_count value: '-2' SELECT @@session.net_retry_count; @@session.net_retry_count 1 diff --git a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result index 57c96a8168a..7c573bdb7cb 100644 --- a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result @@ -78,7 +78,7 @@ SELECT @@global.query_alloc_block_size; 1024 SET @@global.query_alloc_block_size = -1; Warnings: -Warning 1292 Truncated incorrect query_alloc_block_size value: '0' +Warning 1292 Truncated incorrect query_alloc_block_size value: '-1' SELECT @@global.query_alloc_block_size; @@global.query_alloc_block_size 1024 @@ -110,7 +110,7 @@ SELECT @@session.query_alloc_block_size; 1024 SET @@session.query_alloc_block_size = -2; Warnings: -Warning 1292 Truncated incorrect query_alloc_block_size value: '0' +Warning 1292 Truncated incorrect query_alloc_block_size value: '-2' SELECT @@session.query_alloc_block_size; @@session.query_alloc_block_size 1024 diff --git a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result index a592883ef91..7b3e759deb4 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result +++ b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result @@ -32,6 +32,8 @@ SELECT @@global.query_cache_limit; 1048575 '#--------------------FN_DYNVARS_131_04-------------------------#' SET @@global.query_cache_limit = -1; +Warnings: +Warning 1292 Truncated incorrect query_cache_limit value: '-1' SELECT @@global.query_cache_limit; @@global.query_cache_limit 0 @@ -49,6 +51,8 @@ SELECT @@global.query_cache_limit; @@global.query_cache_limit 10240022115 SET @@global.query_cache_limit = -1024; +Warnings: +Warning 1292 Truncated incorrect query_cache_limit value: '-1024' SELECT @@global.query_cache_limit; @@global.query_cache_limit 0 diff --git a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result index e1c74d2bbc1..fdbbc71f108 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result +++ b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result @@ -42,6 +42,8 @@ SELECT @@global.query_cache_min_res_unit; 1048576 '#--------------------FN_DYNVARS_132_04-------------------------#' SET @@global.query_cache_min_res_unit = -1; +Warnings: +Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1' SELECT @@global.query_cache_min_res_unit; @@global.query_cache_min_res_unit 512 @@ -59,6 +61,8 @@ SELECT @@global.query_cache_min_res_unit; @@global.query_cache_min_res_unit 512 SET @@global.query_cache_min_res_unit = -1024; +Warnings: +Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1024' SELECT @@global.query_cache_min_res_unit; @@global.query_cache_min_res_unit 512 diff --git a/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result index 0cc508b169e..c6d7999677f 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result @@ -41,6 +41,8 @@ SELECT @@global.query_cache_size; 1047552 '#--------------------FN_DYNVARS_133_04-------------------------#' SET @@global.query_cache_size = -1; +Warnings: +Warning 1292 Truncated incorrect query_cache_size value: '-1' SELECT @@global.query_cache_size; @@global.query_cache_size 0 @@ -58,6 +60,8 @@ SELECT @@global.query_cache_size; @@global.query_cache_size 0 SET @@global.query_cache_size = -1024; +Warnings: +Warning 1292 Truncated incorrect query_cache_size value: '-1024' SELECT @@global.query_cache_size; @@global.query_cache_size 0 diff --git a/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result b/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result index 0e61fbcd4b5..a16c56f95c5 100644 --- a/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result @@ -35,10 +35,6 @@ SET @@global.query_prealloc_size = 8192; SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size 8192 -SET @@global.query_prealloc_size = 4294967295; -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -4294966272 SET @@global.query_prealloc_size = 655354; SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size @@ -48,10 +44,6 @@ SET @@session.query_prealloc_size = 8192; SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size 8192 -SET @@session.query_prealloc_size = 4294967295; -SELECT @@session.query_prealloc_size ; -@@session.query_prealloc_size -4294966272 SET @@session.query_prealloc_size = 655345; SELECT @@session.query_prealloc_size ; @@session.query_prealloc_size @@ -63,48 +55,32 @@ Warning 1292 Truncated incorrect query_prealloc_size value: '0' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size 8192 -SET @@global.query_prealloc_size = -1024; -Warnings: -Warning 1292 Truncated incorrect query_prealloc_size value: '0' -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -8192 -SET @@global.query_prealloc_size = 429496729533; -SELECT @@global.query_prealloc_size ; -@@global.query_prealloc_size -429496728576 SET @@global.query_prealloc_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = test; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = "test"; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = 'test'; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 +8192 SET @@global.query_prealloc_size = ON; ERROR 42000: Incorrect argument type to variable 'query_prealloc_size' SELECT @@global.query_prealloc_size ; @@global.query_prealloc_size -429496728576 -SET @@session.query_prealloc_size = 0; -Warnings: -Warning 1292 Truncated incorrect query_prealloc_size value: '0' -SELECT @@session.query_prealloc_size ; -@@session.query_prealloc_size 8192 -SET @@session.query_prealloc_size = -2; +SET @@session.query_prealloc_size = 0; Warnings: Warning 1292 Truncated incorrect query_prealloc_size value: '0' SELECT @@session.query_prealloc_size ; diff --git a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result index 26ddfdd2bae..29bf939edac 100644 --- a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result @@ -71,7 +71,7 @@ SELECT @@global.range_alloc_block_size; 4096 SET @@global.range_alloc_block_size = -1024; Warnings: -Warning 1292 Truncated incorrect range_alloc_block_size value: '0' +Warning 1292 Truncated incorrect range_alloc_block_size value: '-1024' SELECT @@global.range_alloc_block_size; @@global.range_alloc_block_size 4096 @@ -97,7 +97,7 @@ SELECT @@session.range_alloc_block_size; 4096 SET @@session.range_alloc_block_size = -2; Warnings: -Warning 1292 Truncated incorrect range_alloc_block_size value: '0' +Warning 1292 Truncated incorrect range_alloc_block_size value: '-2' SELECT @@session.range_alloc_block_size; @@session.range_alloc_block_size 4096 diff --git a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result index 74a47fa0f08..9ec34c677e1 100644 --- a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result +++ b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result @@ -45,14 +45,20 @@ SET @@local.rpl_recovery_rank = 4; ERROR HY000: Variable 'rpl_recovery_rank' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_142_04-----------------------#' SET @@global.rpl_recovery_rank = -1; +Warnings: +Warning 1292 Truncated incorrect rpl_recovery_rank value: '-1' SELECT @@global.rpl_recovery_rank; @@global.rpl_recovery_rank 0 SET @@global.rpl_recovery_rank = -2147483648; +Warnings: +Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483648' SELECT @@global.rpl_recovery_rank; @@global.rpl_recovery_rank 0 SET @@global.rpl_recovery_rank = -2147483649; +Warnings: +Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483649' SELECT @@global.rpl_recovery_rank; @@global.rpl_recovery_rank 0 diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result index 9434b14b238..6e0bc659f9e 100644 --- a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result +++ b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result @@ -55,6 +55,8 @@ SET @@local.slave_transaction_retries = 4; ERROR HY000: Variable 'slave_transaction_retries' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_149_05-----------------------#' SET @@global.slave_transaction_retries = -1; +Warnings: +Warning 1292 Truncated incorrect slave_transaction_retries value: '-1' SELECT @@global.slave_transaction_retries; @@global.slave_transaction_retries 0 diff --git a/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result b/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result index ffd1b3fc4f1..d3cc4e2a9c2 100644 --- a/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result +++ b/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result @@ -36,6 +36,8 @@ SELECT @@global.sync_binlog; 65536 '#--------------------FN_DYNVARS_168_04-------------------------#' SET @@global.sync_binlog = -1; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '-1' SELECT @@global.sync_binlog; @@global.sync_binlog 0 @@ -53,6 +55,8 @@ SELECT @@global.sync_binlog; @@global.sync_binlog 10240022115 SET @@global.sync_binlog = -1024; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '-1024' SELECT @@global.sync_binlog; @@global.sync_binlog 0 diff --git a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result index c968d6f108c..749df56c60b 100644 --- a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result @@ -67,7 +67,7 @@ SELECT @@global.transaction_alloc_block_size; 1024 SET @@global.transaction_alloc_block_size = -1024; Warnings: -Warning 1292 Truncated incorrect transaction_alloc_block_size value: '0' +Warning 1292 Truncated incorrect transaction_alloc_block_size value: '-1024' SELECT @@global.transaction_alloc_block_size; @@global.transaction_alloc_block_size 1024 diff --git a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result index 2fb6451372f..3455b9479c0 100644 --- a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result +++ b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result @@ -66,7 +66,7 @@ SELECT @@global.transaction_prealloc_size; 1024 SET @@global.transaction_prealloc_size = -1024; Warnings: -Warning 1292 Truncated incorrect transaction_prealloc_size value: '0' +Warning 1292 Truncated incorrect transaction_prealloc_size value: '-1024' SELECT @@global.transaction_prealloc_size; @@global.transaction_prealloc_size 1024 diff --git a/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result b/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result index ae03e677e56..c9bffc61b6f 100644 --- a/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result +++ b/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result @@ -44,7 +44,7 @@ Warnings: Warning 1292 Truncated incorrect wait_timeout value: '0' SET @@global.wait_timeout = -1024; Warnings: -Warning 1292 Truncated incorrect wait_timeout value: '0' +Warning 1292 Truncated incorrect wait_timeout value: '-1024' 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.wait_timeout = ON; ERROR 42000: Incorrect argument type to variable 'wait_timeout' diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index c58fb61ad30..8f9ed6c7d06 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -488,5 +488,14 @@ SELECT * FROM t2; DROP TABLE t1, t2; +# +# Bug#43833 Simple INSERT crashes the server +# +CREATE TABLE t1(f1 FLOAT); +INSERT INTO t1 VALUES (1.23); +CREATE TABLE t2(f1 CHAR(1)); +INSERT INTO t2 SELECT f1 FROM t1; +DROP TABLE t1, t2; + --echo End of 5.0 tests. diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index e93153f005c..47b5aa0292b 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -317,6 +317,134 @@ reap; connection locker; drop table t1; +# +# Bug#43230: SELECT ... FOR UPDATE can hang with FLUSH TABLES WITH READ LOCK indefinitely +# + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connect (con3,localhost,root,,); +connect (con4,localhost,root,,); +connect (con5,localhost,root,,); + +create table t1 (a int); +create table t2 like t1; + +connection con1; +--echo # con1 +lock tables t1 write; +connection con2; +--echo # con2 +send flush tables with read lock; +connection con5; +--echo # con5 +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Flushing tables'; +--source include/wait_show_condition.inc +--echo # global read lock is taken +connection con3; +--echo # con3 +send select * from t2 for update; +connection con5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Waiting for release of readlock'; +--source include/wait_show_condition.inc +--echo # waiting for release of read lock +connection con4; +--echo # con4 +--echo # would hang and later cause a deadlock +flush tables t2; +connection con1; +--echo # clean up +unlock tables; +connection con2; +--reap +unlock tables; +connection con3; +--reap +connection default; +disconnect con5; +disconnect con4; +disconnect con3; +disconnect con2; +disconnect con1; + +drop table t1,t2; + +--echo # +--echo # Lightweight version: +--echo # Ensure that the wait for a GRL is done before opening tables. +--echo # + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +create table t1 (a int); +create table t2 like t1; + +--echo # +--echo # UPDATE +--echo # + +connection default; +--echo # default +flush tables with read lock; +connection con1; +--echo # con1 +send update t2 set a = 1; +connection default; +--echo # default +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Waiting for release of readlock'; +--source include/wait_show_condition.inc +--echo # statement is waiting for release of read lock +connection con2; +--echo # con2 +flush table t2; +connection default; +--echo # default +unlock tables; +connection con1; +--echo # con1 +--reap + +--echo # +--echo # LOCK TABLES .. WRITE +--echo # + +connection default; +--echo # default +flush tables with read lock; +connection con1; +--echo # con1 +send lock tables t2 write; +connection default; +--echo # default +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Waiting for release of readlock'; +--source include/wait_show_condition.inc +--echo # statement is waiting for release of read lock +connection con2; +--echo # con2 +flush table t2; +connection default; +--echo # default +unlock tables; +connection con1; +--echo # con1 +--reap +unlock tables; + +connection default; +disconnect con2; +disconnect con1; + +drop table t1,t2; + --echo End of 5.0 tests diff --git a/mysql-test/t/myisam_crash_before_flush_keys-master.opt b/mysql-test/t/myisam_crash_before_flush_keys-master.opt new file mode 100644 index 00000000000..425fda95086 --- /dev/null +++ b/mysql-test/t/myisam_crash_before_flush_keys-master.opt @@ -0,0 +1 @@ +--skip-stack-trace --skip-core-file diff --git a/mysql-test/t/myisam_crash_before_flush_keys.test b/mysql-test/t/myisam_crash_before_flush_keys.test new file mode 100644 index 00000000000..d6559f7760d --- /dev/null +++ b/mysql-test/t/myisam_crash_before_flush_keys.test @@ -0,0 +1,49 @@ +--echo # +--echo # BUG#41330 - Myisam table open count set to zero before index blocks are written. +--echo # +--source include/not_embedded.inc +--echo # Don't test this under valgrind, memory leaks will occur +--source include/not_valgrind.inc + +--echo # Binary must be compiled with debug for crash to occur +--source include/have_debug.inc + +let $MYSQLD_DATADIR= `select @@datadir`; +SET GLOBAL delay_key_write=ALL; +CREATE TABLE t1(a INT, + b INT, + PRIMARY KEY(a , b), + KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1; +INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6); + +--echo # Setup the mysqld to crash at certain point +SET SESSION debug="d,crash_before_flush_keys"; + +--echo # Write file to make mysql-test-run.pl expect crash +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # Run the crashing query +--error 2013 +FLUSH TABLE t1; + +--echo # Run MYISAMCHK tool to check the table t1 and repair +--replace_result $MYISAMCHK MYISAMCHK $MYSQLD_DATADIR MYSQLD_DATADIR +--error 255 +--exec $MYISAMCHK -cs $MYSQLD_DATADIR/test/t1 2>&1 +--exec $MYISAMCHK -rs $MYSQLD_DATADIR/test/t1 + +--echo # Write file to make mysql-test-run.pl start the server +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # Turn on reconnect +--enable_reconnect + +--echo # Call script that will poll the server waiting for +--echo # it to be back online again +--source include/wait_until_connected_again.inc + +SHOW CREATE TABLE t1; + +SELECT * FROM t1 FORCE INDEX (PRIMARY); + +DROP TABLE t1; diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index a88126f2d04..9d27ed53254 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -81,3 +81,29 @@ let $MYSQLD_DATADIR= `select @@datadir`; --exec $MYISAMPACK $MYSQLD_DATADIR/test/t1 SELECT COUNT(*) FROM t1; DROP TABLE t1; + +--echo # +--echo # Bug #43973 - backup_myisam.test fails on 6.0-bugteam +--echo # +CREATE DATABASE mysql_db1; +CREATE TABLE mysql_db1.t1 (c1 VARCHAR(5), c2 int); +CREATE INDEX i1 ON mysql_db1.t1 (c1, c2); +INSERT INTO mysql_db1.t1 VALUES ('A',1); +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +FLUSH TABLE mysql_db1.t1; +# +--echo # Compress the table using MYISAMPACK tool +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYISAMPACK -s $MYSQLD_DATADIR/mysql_db1/t1 +--echo # Run MYISAMCHK tool on the compressed table +--exec $MYISAMCHK -srq $MYSQLD_DATADIR/mysql_db1/t1 +SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5; +# +DROP TABLE mysql_db1.t1; +DROP DATABASE mysql_db1; diff --git a/mysql-test/t/mysqlbinlog_row_big.test b/mysql-test/t/mysqlbinlog_row_big.test index 14e818e7214..75f3b90269f 100644 --- a/mysql-test/t/mysqlbinlog_row_big.test +++ b/mysql-test/t/mysqlbinlog_row_big.test @@ -38,8 +38,26 @@ SET timestamp=1000000000; --echo # --echo # We need big packets. --echo # +--echo # Capture initial value to reset at the end of the test +# use let $ = query_get_value as FLUSH statements +# in the test will set @ values to NULL +let $orig_max_allowed_packet = +query_get_value(SELECT @@global.max_allowed_packet, @@global.max_allowed_packet, 1); + +--echo # Now adjust max_allowed_packet SET @@global.max_allowed_packet= 1024*1024*1024; +--echo max_allowed_packet is a global variable. +--echo In order for the preceding change in max_allowed_packets' value +--echo to be seen and used, we must start a new connection. +--echo The change does not take effect with the current one. +--echo For simplicity, we just disconnect / reconnect connection default here. +--echo Disconnecting default connection... +disconnect default; +--echo Reconnecting default connection... +connect (default, localhost,root,,); +--echo default connection established, continuing with the test + --echo # --echo # Delete all existing binary logs. --echo # @@ -53,34 +71,35 @@ eval CREATE TABLE t1 ( ) ENGINE=$engine_type DEFAULT CHARSET latin1; --echo # ---echo # Show how much rows are affected by each statement. +--echo # Show how many rows are affected by each statement. --echo # --enable_info --echo # ---echo # Insert a big row. +--echo # Insert some big rows. --echo # -# -# 256MB -#INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216)); -# -# 32MB + +--echo 256MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216)); + +--echo 32MB INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152)); -# -# 4MB -#INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144)); -# -# 512KB -#INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768)); + +--echo 4MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144)); + +--echo 512KB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768)); --echo # --echo # Show what we have in the table. --echo # Do not display the column value itself, just its length. --echo # +--sorted_result query_vertical SELECT LENGTH(c1) FROM t1; --echo # ---echo # Grow the row by updating. +--echo # Grow the rows by updating. --echo # UPDATE t1 SET c1 = CONCAT(c1, c1); @@ -88,15 +107,16 @@ UPDATE t1 SET c1 = CONCAT(c1, c1); --echo # Show what we have in the table. --echo # Do not display the column value itself, just its length. --echo # +--sorted_result query_vertical SELECT LENGTH(c1) FROM t1; --echo # ---echo # Delete the row. +--echo # Delete the rows. --echo # DELETE FROM t1 WHERE c1 >= 'ManyMegaByteBlck'; --echo # ---echo # Hide how much rows are affected by each statement. +--echo # Hide how many rows are affected by each statement. --echo # --disable_info @@ -113,13 +133,15 @@ FLUSH LOGS; --echo # at the bottom of the test script. --echo # let $MYSQLD_DATADIR= `select @@datadir`; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ --exec $MYSQL_BINLOG -v -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/$mysqlbinlog_output --echo # --echo # Cleanup. --echo # +--echo # reset variable value to pass testcase checks +eval SET @@global.max_allowed_packet = $orig_max_allowed_packet; DROP TABLE t1; --echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 7efc519e441..e44fc85bc5e 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -724,3 +724,31 @@ SELECT {fn CONCAT(a1,a2)} FROM t1; UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0; SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')}; DROP TABLE t1, t2, t3; + +########################################################################### +--echo # +--echo # Bug#39559: dump of stored procedures / functions with C-style +--echo # comment can't be read back +--echo # + +--write_file $MYSQLTEST_VARDIR/tmp/bug39559.sql +select 2 as expected, /*!01000/**/*/ 2 as result; +select 1 as expected, /*!99998/**/*/ 1 as result; +select 3 as expected, /*!01000 1 + */ 2 as result; +select 2 as expected, /*!99990 1 + */ 2 as result; +select 7 as expected, /*!01000 1 + /* 8 + */ 2 + */ 4 as result; +select 8 as expected, /*!99998 1 + /* 2 + */ 4 + */ 8 as result; +select 7 as expected, /*!01000 1 + /*!01000 8 + */ 2 + */ 4 as result; +select 7 as expected, /*!01000 1 + /*!99998 8 + */ 2 + */ 4 as result; +select 4 as expected, /*!99998 1 + /*!99998 8 + */ 2 + */ 4 as result; +select 4 as expected, /*!99998 1 + /*!01000 8 + */ 2 + */ 4 as result; +select 7 as expected, /*!01000 1 + /*!01000 8 + /*!01000 error */ 16 + */ 2 + */ 4 as result; +select 4 as expected, /* 1 + /*!01000 8 + */ 2 + */ 4; +EOF + +--exec $MYSQL --comment --force --table test <$MYSQLTEST_VARDIR/tmp/bug39559.sql +--remove_file $MYSQLTEST_VARDIR/tmp/bug39559.sql + +--echo # +--echo # End of 5.1 tests +--echo # diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index 437b0f47cc0..e096b6520a1 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -89,3 +89,35 @@ show create table `a-b-c`.`t1`; drop database `a-b-c`; drop database `tabc`; +# +# Bug#43385 Cannot ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME when Views exist +# +let $MYSQLD_DATADIR= `select @@datadir`; +--mkdir $MYSQLD_DATADIR/a-b-c +use `#mysql50#a-b-c`; +create table t1(f1 char(10)); + +--write_file $MYSQLD_DATADIR/a-b-c/v1.frm +TYPE=VIEW +query=select `a`.`f1` AS `f1` from `a-b-c`.`t1` `a` join `information_schema`.`tables` `b` where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`) +md5=068271f1c657fe115e497856ca0fa493 +updatable=0 +algorithm=0 +definer_user=root +definer_host=localhost +suid=2 +with_check_option=0 +timestamp=2009-04-10 11:53:37 +create-version=1 +source=select f1 from `a-b-c`.t1 a, information_schema.tables b\nwhere a.f1 = b.table_name +EOF + +show databases like '%a-b-c%'; +ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME; +show databases like '%a-b-c%'; +show create view `a-b-c`.v1; +--disable_ps_protocol +select * from `a-b-c`.v1; +--enable_ps_protocol +drop database `a-b-c`; +use test; diff --git a/mysys/charset.c b/mysys/charset.c index e61995de1d8..7a7ef0ad3ea 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -494,29 +494,40 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) { char buf[FN_REFLEN]; CHARSET_INFO *cs; - /* - To make things thread safe we are not allowing other threads to interfere - while we may changing the cs_info_table - */ - pthread_mutex_lock(&THR_LOCK_charset); + if ((cs= all_charsets[cs_number])) { - if (!(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED)) + if (cs->state & MY_CS_READY) /* if CS is already initialized */ + return cs; + + /* + To make things thread safe we are not allowing other threads to interfere + while we may changing the cs_info_table + */ + pthread_mutex_lock(&THR_LOCK_charset); + + if (!(cs->state & (MY_CS_COMPILED|MY_CS_LOADED))) /* if CS is not in memory */ { strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS); my_read_charset_file(buf,flags); } - cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL; - } - if (cs && !(cs->state & MY_CS_READY)) - { - if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) || - (cs->coll->init && cs->coll->init(cs, cs_alloc))) - cs= NULL; + + if (cs->state & MY_CS_AVAILABLE) + { + if (!(cs->state & MY_CS_READY)) + { + if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) || + (cs->coll->init && cs->coll->init(cs, cs_alloc))) + cs= NULL; + else + cs->state|= MY_CS_READY; + } + } else - cs->state|= MY_CS_READY; + cs= NULL; + + pthread_mutex_unlock(&THR_LOCK_charset); } - pthread_mutex_unlock(&THR_LOCK_charset); return cs; } diff --git a/mysys/my_init.c b/mysys/my_init.c index b330ffac65a..a60927be693 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -136,6 +136,10 @@ void my_end(int infoflag) */ FILE *info_file= DBUG_FILE; my_bool print_info= (info_file != stderr); + + if (!my_init_done) + return; + /* We do not use DBUG_ENTER here, as after cleanup DBUG is no longer operational, so we cannot use DBUG_RETURN. diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 631e1e38cc7..3cb4665eb1c 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -293,12 +293,7 @@ sub start_mysqlds() @groups = &find_groups($groupids); for ($i = 0; defined($groups[$i]); $i++) { - # Defaults are made explicit parameters to server execution... @options = defaults_for_group($groups[$i]); - # ...so server MUST NOT try to read again from some config file, especially - # as the "right" file may be unknown to the server if we are using - # --defaults-file=... params in here. - unshift(@options,"--no-defaults"); $mysqld_found= 1; # The default $mysqld_found= 0 if (!length($mysqld)); diff --git a/sql/events.cc b/sql/events.cc index 4203ca06d7f..ea935e67bd3 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -412,6 +412,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists))) { Event_queue_element *new_element; + bool dropped= 0; if (!(new_element= new Event_queue_element())) ret= TRUE; // OOM @@ -419,8 +420,9 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, parse_data->name, new_element))) { - db_repository->drop_event(thd, parse_data->dbname, parse_data->name, - TRUE); + if (!db_repository->drop_event(thd, parse_data->dbname, parse_data->name, + TRUE)) + dropped= 1; delete new_element; } else @@ -429,6 +431,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool created; if (event_queue) event_queue->create_event(thd, new_element, &created); + } + /* + binlog the create event unless it's been successfully dropped + */ + if (!dropped) + { /* Binlog the create event. */ DBUG_ASSERT(thd->query && thd->query_length); write_bin_log(thd, TRUE, thd->query, thd->query_length); diff --git a/sql/field.cc b/sql/field.cc index a06021bee3d..d11b509075b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6448,13 +6448,13 @@ int Field_str::store(double nr) calculate the maximum number of significant digits if the 'f'-format would be used (+1 for decimal point if the number has a fractional part). */ - digits= max(0, (int) max_length - fractional); + digits= max(1, (int) max_length - fractional); /* If the exponent is negative, decrease digits by the number of leading zeros after the decimal point that do not count as significant digits. */ if (exp < 0) - digits= max(0, (int) digits + exp); + digits= max(1, (int) digits + exp); /* 'e'-format is used only if the exponent is less than -4 or greater than or equal to the precision. In this case we need to adjust the number of @@ -6462,7 +6462,7 @@ int Field_str::store(double nr) We also have to reserve one additional character if abs(exp) >= 100. */ if (exp >= (int) digits || exp < -4) - digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100))); + digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100))); /* Limit precision to DBL_DIG to avoid garbage past significant digits */ set_if_smaller(digits, DBL_DIG); diff --git a/sql/log.cc b/sql/log.cc index 44296daa939..ed2eff6625d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -845,6 +845,7 @@ void LOGGER::cleanup_base() { table_log_handler->cleanup(); delete table_log_handler; + table_log_handler= NULL; } if (file_log_handler) file_log_handler->cleanup(); @@ -855,7 +856,11 @@ void LOGGER::cleanup_end() { DBUG_ASSERT(inited == 1); if (file_log_handler) + { delete file_log_handler; + file_log_handler=NULL; + } + inited= 0; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 89094da3e94..6e798d9169e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -277,6 +277,47 @@ static void clear_all_errors(THD *thd, Relay_log_info *rli) rli->clear_error(); } +inline int idempotent_error_code(int err_code) +{ + int ret= 0; + + switch (err_code) + { + case 0: + ret= 1; + break; + /* + The following list of "idempotent" errors + means that an error from the list might happen + because of idempotent (more than once) + applying of a binlog file. + Notice, that binlog has a ddl operation its + second applying may cause + + case HA_ERR_TABLE_DEF_CHANGED: + case HA_ERR_CANNOT_ADD_FOREIGN: + + which are not included into to the list. + + Note that HA_ERR_RECORD_DELETED is not in the list since + do_exec_row() should not return that error code. + */ + case HA_ERR_RECORD_CHANGED: + case HA_ERR_KEY_NOT_FOUND: + case HA_ERR_END_OF_FILE: + case HA_ERR_FOUND_DUPP_KEY: + case HA_ERR_FOUND_DUPP_UNIQUE: + case HA_ERR_FOREIGN_DUPLICATE_KEY: + case HA_ERR_NO_REFERENCED_ROW: + case HA_ERR_ROW_IS_REFERENCED: + ret= 1; + break; + default: + ret= 0; + break; + } + return (ret); +} /** Ignore error code specified on command line. @@ -301,14 +342,37 @@ inline int ignored_error_code(int err_code) return ((err_code == ER_SLAVE_IGNORED_TABLE) || (use_slave_mask && bitmap_is_set(&slave_error_mask, err_code))); } -#endif +/* + This function converts an engine's error to a server error. + + If the thread does not have an error already reported, it tries to + define it by calling the engine's method print_error. However, if a + mapping is not found, it uses the ER_UNKNOWN_ERROR and prints out a + warning message. +*/ +int convert_handler_error(int error, THD* thd, TABLE *table) +{ + uint actual_error= (thd->is_error() ? thd->main_da.sql_errno() : + 0); + + if (actual_error == 0) + { + table->file->print_error(error, MYF(0)); + actual_error= (thd->is_error() ? thd->main_da.sql_errno() : + ER_UNKNOWN_ERROR); + if (actual_error == ER_UNKNOWN_ERROR) + if (global_system_variables.log_warnings) + sql_print_warning("Unknown error detected %d in handler", error); + } + + return (actual_error); +} /* pretty_print_str() */ -#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) static char *pretty_print_str(char *packet, const char *str, int len) { const char *end= str + len; @@ -2292,7 +2356,16 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, (thd_arg->is_error() ? thd_arg->main_da.sql_errno() : 0) : ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 : thd_arg->killed_errno()); - + + /* thd_arg->main_da.sql_errno() might be ER_SERVER_SHUTDOWN or + ER_QUERY_INTERRUPTED, So here we need to make sure that + error_code is not set to these errors when specified NOT_KILLED + by the caller + */ + if ((killed_status_arg == THD::NOT_KILLED) && + (error_code == ER_SERVER_SHUTDOWN || error_code == ER_QUERY_INTERRUPTED)) + error_code= 0; + time(&end_time); exec_time = (ulong) (end_time - thd_arg->start_time); /** @@ -7158,7 +7231,9 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) { /* Error reporting borrowed from Query_log_event with many excessive - simplifications (we don't honour --slave-skip-errors) + simplifications. + We should not honour --slave-skip-errors at this point as we are + having severe errors which should not be skiped. */ rli->report(ERROR_LEVEL, actual_error, "Error '%s' on opening tables", @@ -7184,6 +7259,10 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) { if (ptr->m_tabledef.compatible_with(rli, ptr->table)) { + /* + We should not honour --slave-skip-errors at this point as we are + having severe errors which should not be skiped. + */ mysql_unlock_tables(thd, thd->lock); thd->lock= 0; thd->is_slave_error= 1; @@ -7275,7 +7354,6 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) // Do event specific preparations error= do_before_row_operations(rli); - // row processing loop while (error == 0 && m_curr_row < m_rows_end) @@ -7291,48 +7369,27 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) DBUG_ASSERT(error != HA_ERR_RECORD_DELETED); table->in_use = old_thd; - switch (error) + + if (error) { - case 0: - break; - /* - The following list of "idempotent" errors - means that an error from the list might happen - because of idempotent (more than once) - applying of a binlog file. - Notice, that binlog has a ddl operation its - second applying may cause + int actual_error= convert_handler_error(error, thd, table); + bool idempotent_error= (idempotent_error_code(error) && + ((bit_is_set(slave_exec_mode, + SLAVE_EXEC_MODE_IDEMPOTENT)) == 1)); + bool ignored_error= (idempotent_error == 0 ? + ignored_error_code(actual_error) : 0); - case HA_ERR_TABLE_DEF_CHANGED: - case HA_ERR_CANNOT_ADD_FOREIGN: - - which are not included into to the list. - - Note that HA_ERR_RECORD_DELETED is not in the list since - do_exec_row() should not return that error code. - */ - case HA_ERR_RECORD_CHANGED: - case HA_ERR_KEY_NOT_FOUND: - case HA_ERR_END_OF_FILE: - case HA_ERR_FOUND_DUPP_KEY: - case HA_ERR_FOUND_DUPP_UNIQUE: - case HA_ERR_FOREIGN_DUPLICATE_KEY: - case HA_ERR_NO_REFERENCED_ROW: - case HA_ERR_ROW_IS_REFERENCED: - - if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1) + if (idempotent_error || ignored_error) { if (global_system_variables.log_warnings) slave_rows_error_report(WARNING_LEVEL, error, rli, thd, table, get_type_str(), RPL_LOG_NAME, (ulong) log_pos); + clear_all_errors(thd, const_cast(rli)); error= 0; + if (idempotent_error == 0) + break; } - break; - - default: - thd->is_slave_error= 1; - break; } /* @@ -7346,7 +7403,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) (ulong) m_curr_row, (ulong) m_curr_row_end, (ulong) m_rows_end)); if (!m_curr_row_end && !error) - unpack_current_row(rli); + error= unpack_current_row(rli); // at this moment m_curr_row_end should be set DBUG_ASSERT(error || m_curr_row_end != NULL); @@ -7359,7 +7416,19 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event", const_cast(rli)->abort_slave= 1;); - error= do_after_row_operations(rli, error); + + if ((error= do_after_row_operations(rli, error)) && + ignored_error_code(convert_handler_error(error, thd, table))) + { + + if (global_system_variables.log_warnings) + slave_rows_error_report(WARNING_LEVEL, error, rli, thd, table, + get_type_str(), + RPL_LOG_NAME, (ulong) log_pos); + clear_all_errors(thd, const_cast(rli)); + error= 0; + } + if (!cache_stmt) { DBUG_PRINT("info", ("Marked that we need to keep log")); @@ -7374,37 +7443,22 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) if (rli->tables_to_lock && get_flags(STMT_END_F)) const_cast(rli)->clear_tables_to_lock(); - if (error) - { /* error has occured during the transaction */ - slave_rows_error_report(ERROR_LEVEL, error, rli, thd, table, - get_type_str(), RPL_LOG_NAME, (ulong) log_pos); - } if (error) { - /* - If one day we honour --skip-slave-errors in row-based replication, and - the error should be skipped, then we would clear mappings, rollback, - close tables, but the slave SQL thread would not stop and then may - assume the mapping is still available, the tables are still open... - So then we should clear mappings/rollback/close here only if this is a - STMT_END_F. - For now we code, knowing that error is not skippable and so slave SQL - thread is certainly going to stop. - rollback at the caller along with sbr. - */ + slave_rows_error_report(ERROR_LEVEL, error, rli, thd, table, + get_type_str(), + RPL_LOG_NAME, (ulong) log_pos); thd->reset_current_stmt_binlog_row_based(); const_cast(rli)->cleanup_context(thd, error); thd->is_slave_error= 1; - DBUG_RETURN(error); } - /* This code would ideally be placed in do_update_pos() instead, but since we have no access to table there, we do the setting of last_event_start_time here instead. */ - if (table && (table->s->primary_key == MAX_KEY) && - !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS) + else if (table && (table->s->primary_key == MAX_KEY) && + !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS) { /* ------------ Temporary fix until WL#2975 is implemented --------- @@ -7425,7 +7479,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) const_cast(rli)->last_event_start_time= my_time(0); } - DBUG_RETURN(0); + DBUG_RETURN(error); } Log_event::enum_skip_reason diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 07ea434e8e0..f2dbeba1bbf 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -302,6 +302,7 @@ err_w_file: @thd thread handler @param schema name of given schema @param old_name original file name + @param new_db new schema @param new_name new file name @retval @@ -311,14 +312,14 @@ err_w_file: */ my_bool rename_in_schema_file(THD *thd, const char *schema, const char *old_name, - const char *new_name) + const char *new_db, const char *new_name) { char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN]; build_table_filename(old_path, sizeof(old_path) - 1, schema, old_name, reg_ext, 0); build_table_filename(new_path, sizeof(new_path) - 1, - schema, new_name, reg_ext, 0); + new_db, new_name, reg_ext, 0); if (my_rename(old_path, new_path, MYF(MY_WME))) return 1; diff --git a/sql/parse_file.h b/sql/parse_file.h index cfac69cc471..84647e45927 100644 --- a/sql/parse_file.h +++ b/sql/parse_file.h @@ -83,7 +83,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, uchar* base, File_option *parameters); my_bool rename_in_schema_file(THD *thd, const char *schema, const char *old_name, - const char *new_name); + const char *new_db, const char *new_name); class File_parser: public Sql_alloc { diff --git a/sql/slave.cc b/sql/slave.cc index b862c5eff20..a0db9837648 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -371,6 +371,7 @@ void init_slave_skip_errors(const char* arg) if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4)) { bitmap_set_all(&slave_error_mask); + print_slave_skip_errors(); DBUG_VOID_RETURN; } for (p= arg ; *p; ) @@ -2723,7 +2724,8 @@ pthread_handler_t handle_slave_sql(void *arg) */ pthread_cond_broadcast(&rli->start_cond); pthread_mutex_unlock(&rli->run_lock); - sql_print_error("Failed during slave thread initialization"); + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + "Failed during slave thread initialization"); goto err; } thd->init_for_queries(); @@ -2767,9 +2769,9 @@ pthread_handler_t handle_slave_sql(void *arg) rli->group_relay_log_pos, 1 /*need data lock*/, &errmsg, 1 /*look for a description_event*/)) - { - sql_print_error("Error initializing relay log position: %s", - errmsg); + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + "Error initializing relay log position: %s", errmsg); goto err; } THD_CHECK_SENTRY(thd); @@ -2822,8 +2824,8 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave); if (thd->is_slave_error) { - sql_print_error("\ -Slave SQL thread aborted. Can't execute init_slave query"); + rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), + "Slave SQL thread aborted. Can't execute init_slave query"); goto err; } } @@ -2873,10 +2875,20 @@ Slave SQL thread aborted. Can't execute init_slave query"); thd->main_da.sql_errno(), last_errno)); if (last_errno == 0) { + /* + This function is reporting an error which was not reported + while executing exec_relay_log_event(). + */ rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg); } else if (last_errno != thd->main_da.sql_errno()) { + /* + * An error was reported while executing exec_relay_log_event() + * however the error code differs from what is in the thread. + * This function prints out more information to help finding + * what caused the problem. + */ sql_print_error("Slave (additional info): %s Error_code: %d", errmsg, thd->main_da.sql_errno()); } diff --git a/sql/sp.cc b/sql/sp.cc index b2c7c389136..8c8149d0afc 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -940,7 +940,8 @@ sp_create_routine(THD *thd, int type, sp_head *sp) thd->variables.sql_mode= saved_mode; /* Such a statement can always go directly to binlog, no trans cache */ thd->binlog_query(THD::MYSQL_QUERY_TYPE, - log_query.c_ptr(), log_query.length(), FALSE, FALSE); + log_query.c_ptr(), log_query.length(), + FALSE, FALSE, THD::NOT_KILLED); thd->variables.sql_mode= 0; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index bd940608a07..b1dbb7031ce 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1647,7 +1647,8 @@ bool change_password(THD *thd, const char *host, const char *user, acl_user->host.hostname ? acl_user->host.hostname : "", new_password)); thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length, FALSE, FALSE); + thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length, + FALSE, FALSE, THD::NOT_KILLED); } end: close_thread_tables(thd); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4f08aa0c07f..0f0ee7c529e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1541,19 +1541,8 @@ void close_temporary_tables(THD *thd) thd->variables.character_set_client= system_charset_info; Query_log_event qinfo(thd, s_query.ptr(), s_query.length() - 1 /* to remove trailing ',' */, - 0, FALSE); + 0, FALSE, THD::NOT_KILLED); thd->variables.character_set_client= cs_save; - /* - Imagine the thread had created a temp table, then was doing a - SELECT, and the SELECT was killed. Then it's not clever to - mark the statement above as "killed", because it's not really - a statement updating data, and there are 99.99% chances it - will succeed on slave. If a real update (one updating a - persistent table) was killed on the master, then this real - update will be logged with error_code=killed, rightfully - causing the slave to stop. - */ - qinfo.error_code= 0; mysql_bin_log.write(&qinfo); thd->variables.pseudo_thread_id= save_pseudo_thread_id; } @@ -4017,7 +4006,8 @@ retry: end = strxmov(strmov(query, "DELETE FROM `"), share->db.str,"`.`",share->table_name.str,"`", NullS); thd->binlog_query(THD::STMT_QUERY_TYPE, - query, (ulong)(end-query), FALSE, FALSE); + query, (ulong)(end-query), + FALSE, FALSE, THD::NOT_KILLED); my_free(query, MYF(0)); } else diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7f15508caa1..b73822f5a48 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3676,7 +3676,11 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, if (sql_log_bin_toplevel && lex->is_stmt_unsafe() && variables.binlog_format == BINLOG_FORMAT_STMT) { - push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN, + /* + A warning can be elevated a error when STRICT sql mode. + But we don't want to elevate binlog warning to error here. + */ + push_warning(this, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_BINLOG_UNSAFE_STATEMENT, ER(ER_BINLOG_UNSAFE_STATEMENT)); if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED)) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 72ae664bba1..5a266c3fac9 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -181,7 +181,7 @@ uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, static inline void write_to_binlog(THD *thd, char *query, uint q_len, char *db, uint db_len) { - Query_log_event qinfo(thd, query, q_len, 0, 0); + Query_log_event qinfo(thd, query, q_len, 0, 0, THD::NOT_KILLED); qinfo.error_code= 0; qinfo.db= db; qinfo.db_len= db_len; @@ -724,7 +724,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, if (mysql_bin_log.is_open()) { Query_log_event qinfo(thd, query, query_length, 0, - /* suppress_use */ TRUE); + /* suppress_use */ TRUE, THD::NOT_KILLED); /* Write should use the database being created as the "current @@ -812,7 +812,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) if (mysql_bin_log.is_open()) { Query_log_event qinfo(thd, thd->query, thd->query_length, 0, - /* suppress_use */ TRUE); + /* suppress_use */ TRUE, THD::NOT_KILLED); /* Write should use the database being created as the "current @@ -959,7 +959,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) if (mysql_bin_log.is_open()) { Query_log_event qinfo(thd, query, query_length, 0, - /* suppress_use */ TRUE); + /* suppress_use */ TRUE, THD::NOT_KILLED); /* Write should use the database being created as the "current database" and not the threads current database, which is the @@ -1958,7 +1958,8 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) /* Step8: logging */ if (mysql_bin_log.is_open()) { - Query_log_event qinfo(thd, thd->query, thd->query_length, 0, TRUE); + Query_log_event qinfo(thd, thd->query, thd->query_length, + 0, TRUE, THD::NOT_KILLED); thd->clear_error(); mysql_bin_log.write(&qinfo); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e6eb9a8a44e..b96ac91679b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -348,6 +348,7 @@ void lex_start(THD *thd) lex->nest_level=0 ; lex->allow_sum_func= 0; lex->in_sum_func= NULL; + lex->protect_against_global_read_lock= FALSE; /* ok, there must be a better solution for this, long-term I tried "bzero" in the sql_yacc.yy code, but that for @@ -712,6 +713,53 @@ static inline uint int_token(const char *str,uint length) return ((uchar) str[-1] <= (uchar) cmp[-1]) ? smaller : bigger; } + +/** + Given a stream that is advanced to the first contained character in + an open comment, consume the comment. Optionally, if we are allowed, + recurse so that we understand comments within this current comment. + + At this level, we do not support version-condition comments. We might + have been called with having just passed one in the stream, though. In + that case, we probably want to tolerate mundane comments inside. Thus, + the case for recursion. + + @retval Whether EOF reached before comment is closed. +*/ +bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) +{ + reg1 uchar c; + while (! lip->eof()) + { + c= lip->yyGet(); + + if (remaining_recursions_permitted > 0) + { + if ((c == '/') && (lip->yyPeek() == '*')) + { + lip->yySkip(); /* Eat asterisk */ + consume_comment(lip, remaining_recursions_permitted-1); + continue; + } + } + + if (c == '*') + { + if (lip->yyPeek() == '/') + { + lip->yySkip(); /* Eat slash */ + return FALSE; + } + } + + if (c == '\n') + lip->yylineno++; + } + + return TRUE; +} + + /* MYSQLlex remember the following states from the following MYSQLlex() @@ -1204,6 +1252,8 @@ int MYSQLlex(void *arg, void *yythd) /* Reject '/' '*', since we might need to turn off the echo */ lip->yyUnget(); + lip->save_in_comment_state(); + if (lip->yyPeekn(2) == '!') { lip->in_comment= DISCARD_COMMENT; @@ -1246,11 +1296,17 @@ int MYSQLlex(void *arg, void *yythd) /* Expand the content of the special comment as real code */ lip->set_echo(TRUE); state=MY_LEX_START; - break; + break; /* Do not treat contents as a comment. */ + } + else + { + comment_closed= ! consume_comment(lip, 1); + /* version allowed to have one level of comment inside. */ } } else { + /* Not a version comment. */ state=MY_LEX_START; lip->set_echo(TRUE); break; @@ -1261,38 +1317,30 @@ int MYSQLlex(void *arg, void *yythd) lip->in_comment= PRESERVE_COMMENT; lip->yySkip(); // Accept / lip->yySkip(); // Accept * + comment_closed= ! consume_comment(lip, 0); + /* regular comments can have zero comments inside. */ } /* Discard: - regular '/' '*' comments, - special comments '/' '*' '!' for a future version, by scanning until we find a closing '*' '/' marker. - Note: There is no such thing as nesting comments, - the first '*' '/' sequence seen will mark the end. + + Nesting regular comments isn't allowed. The first + '*' '/' returns the parser to the previous state. + + /#!VERSI oned containing /# regular #/ is allowed #/ + + Inside one versioned comment, another versioned comment + is treated as a regular discardable comment. It gets + no special parsing. */ - comment_closed= FALSE; - while (! lip->eof()) - { - c= lip->yyGet(); - if (c == '*') - { - if (lip->yyPeek() == '/') - { - lip->yySkip(); - comment_closed= TRUE; - state = MY_LEX_START; - break; - } - } - else if (c == '\n') - lip->yylineno++; - } + /* Unbalanced comments with a missing '*' '/' are a syntax error */ if (! comment_closed) return (ABORT_SYM); state = MY_LEX_START; // Try again - lip->in_comment= NO_COMMENT; - lip->set_echo(TRUE); + lip->restore_in_comment_state(); break; case MY_LEX_END_LONG_COMMENT: if ((lip->in_comment != NO_COMMENT) && lip->yyPeek() == '/') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index f34a1c7c36f..62106a2500b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1160,6 +1160,18 @@ public: m_echo= echo; } + void save_in_comment_state() + { + m_echo_saved= m_echo; + in_comment_saved= in_comment; + } + + void restore_in_comment_state() + { + m_echo= m_echo_saved; + in_comment= in_comment_saved; + } + /** Skip binary from the input stream. @param n number of bytes to accept. @@ -1417,6 +1429,7 @@ private: /** Echo the parsed stream to the pre-processed buffer. */ bool m_echo; + bool m_echo_saved; /** Pre-processed buffer. */ char *m_cpp_buf; @@ -1479,6 +1492,7 @@ public: /** State of the lexical analyser for comments. */ enum_comment_state in_comment; + enum_comment_state in_comment_saved; /** Starting position of the TEXT_STRING or IDENT in the pre-processed @@ -1745,6 +1759,22 @@ typedef struct st_lex : public Query_tables_list bool escape_used; bool is_lex_started; /* If lex_start() did run. For debugging. */ + /* + Special case for SELECT .. FOR UPDATE and LOCK TABLES .. WRITE. + + Protect from a impending GRL as otherwise the thread might deadlock + if it starts waiting for the GRL in mysql_lock_tables. + + The protection is needed because there is a race between setting + the global read lock and waiting for all open tables to be closed. + The problem is a circular wait where a thread holding "old" open + tables will wait for the global read lock to be released while the + thread holding the global read lock will wait for all "old" open + tables to be closed -- the flush part of flush tables with read + lock. + */ + bool protect_against_global_read_lock; + st_lex(); virtual ~st_lex() diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2974dff9ea9..6dbe4a4fd8d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2200,8 +2200,15 @@ mysql_execute_command(THD *thd) res= check_access(thd, lex->exchange ? SELECT_ACL | FILE_ACL : SELECT_ACL, any_db, 0, 0, 0, 0); - if (!res) - res= execute_sqlcom_select(thd, all_tables); + + if (res) + break; + + if (!thd->locked_tables && lex->protect_against_global_read_lock && + !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) + break; + + res= execute_sqlcom_select(thd, all_tables); break; case SQLCOM_PREPARE: { @@ -3006,6 +3013,9 @@ end_with_restore_list: DBUG_ASSERT(first_table == all_tables && first_table != 0); if (update_precheck(thd, all_tables)) break; + if (!thd->locked_tables && + !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) + goto error; DBUG_ASSERT(select_lex->offset_limit == 0); unit->set_limit(select_lex); res= (up_result= mysql_update(thd, all_tables, @@ -3032,6 +3042,15 @@ end_with_restore_list: else res= 0; + /* + Protection might have already been risen if its a fall through + from the SQLCOM_UPDATE case above. + */ + if (!thd->locked_tables && + lex->sql_command == SQLCOM_UPDATE_MULTI && + !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) + goto error; + res= mysql_multi_update_prepare(thd); #ifdef HAVE_REPLICATION @@ -3229,7 +3248,8 @@ end_with_restore_list: ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); goto error; } - + if (!(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) + goto error; res= mysql_truncate(thd, first_table, 0); break; case SQLCOM_DELETE: @@ -3402,6 +3422,10 @@ end_with_restore_list: if (check_one_table_access(thd, privilege, all_tables)) goto error; + if (!thd->locked_tables && + !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) + goto error; + res= mysql_load(thd, lex->exchange, first_table, lex->field_list, lex->update_list, lex->value_list, lex->duplicates, lex->ignore, (bool) lex->local_file); @@ -3472,6 +3496,9 @@ end_with_restore_list: if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, UINT_MAX, FALSE)) goto error; + if (lex->protect_against_global_read_lock && + !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1))) + goto error; thd->in_lock_tables=1; thd->options|= OPTION_TABLE_LOCK; diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index fc87356e452..d4331b12cd4 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -301,12 +301,17 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, } break; case FRMTYPE_VIEW: - /* change of schema is not allowed */ - if (strcmp(ren_table->db, new_db)) + /* + change of schema is not allowed + except of ALTER ...UPGRADE DATA DIRECTORY NAME command + because a view has valid internal db&table names in this case. + */ + if (thd->lex->sql_command != SQLCOM_ALTER_DB_UPGRADE && + strcmp(ren_table->db, new_db)) my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db, new_db); else - rc= mysql_rename_view(thd, new_alias, ren_table); + rc= mysql_rename_view(thd, new_db, new_alias, ren_table); break; default: DBUG_ASSERT(0); // should never happen diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 842ece1dec4..64fc72ae96f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1463,7 +1463,7 @@ void write_bin_log(THD *thd, bool clear_error, if (clear_error) thd->clear_error(); thd->binlog_query(THD::STMT_QUERY_TYPE, - query, query_length, FALSE, FALSE); + query, query_length, FALSE, FALSE, THD::NOT_KILLED); } } @@ -6165,7 +6165,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (mysql_bin_log.is_open()) { thd->clear_error(); - Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); + Query_log_event qinfo(thd, thd->query, thd->query_length, + 0, FALSE, THD::NOT_KILLED); mysql_bin_log.write(&qinfo); } my_ok(thd); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 65157ae4255..4f207f78688 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -662,7 +662,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, buff.append(views->source.str, views->source.length); thd->binlog_query(THD::STMT_QUERY_TYPE, - buff.ptr(), buff.length(), FALSE, FALSE); + buff.ptr(), buff.length(), FALSE, FALSE, THD::NOT_KILLED); } VOID(pthread_mutex_unlock(&LOCK_open)); @@ -1912,6 +1912,7 @@ int view_checksum(THD *thd, TABLE_LIST *view) Parameters: thd thread handler + new_db new name of database new_name new name of view view view @@ -1921,6 +1922,7 @@ int view_checksum(THD *thd, TABLE_LIST *view) */ bool mysql_rename_view(THD *thd, + const char *new_db, const char *new_name, TABLE_LIST *view) { @@ -1959,16 +1961,16 @@ mysql_rename_view(THD *thd, goto err; /* rename view and it's backups */ - if (rename_in_schema_file(thd, view->db, view->table_name, new_name)) + if (rename_in_schema_file(thd, view->db, view->table_name, new_db, new_name)) goto err; dir.str= dir_buff; dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1, - view->db, "", "", 0); + new_db, "", "", 0); pathstr.str= path_buff; pathstr.length= build_table_filename(path_buff, sizeof(path_buff) - 1, - view->db, new_name, reg_ext, 0); + new_db, new_name, reg_ext, 0); file.str= pathstr.str + dir.length; file.length= pathstr.length - dir.length; @@ -1977,7 +1979,7 @@ mysql_rename_view(THD *thd, (uchar*)&view_def, view_parameters)) { /* restore renamed view in case of error */ - rename_in_schema_file(thd, view->db, new_name, view->table_name); + rename_in_schema_file(thd, new_db, new_name, view->db, view->table_name); goto err; } } else diff --git a/sql/sql_view.h b/sql/sql_view.h index b8138663489..e08c2168e14 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -37,7 +37,8 @@ int view_checksum(THD *thd, TABLE_LIST *view); extern TYPELIB updatable_views_with_limit_typelib; bool check_duplicate_names(List& item_list, bool gen_unique_view_names); -bool mysql_rename_view(THD *thd, const char *new_name, TABLE_LIST *view); +bool mysql_rename_view(THD *thd, const char *new_db, const char *new_name, + TABLE_LIST *view); #define VIEW_ANY_ACL (SELECT_ACL | UPDATE_ACL | INSERT_ACL | DELETE_ACL) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e56ff7c6ad7..7752ccce73d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6538,6 +6538,7 @@ select_lock_type: lex->current_select->set_lock_for_tables(TL_WRITE); lex->current_select->lock_option= TL_WRITE; lex->safe_to_cache_query=0; + lex->protect_against_global_read_lock= TRUE; } | LOCK_SYM IN_SYM SHARE_SYM MODE_SYM { @@ -12182,8 +12183,12 @@ table_lock_list: table_lock: table_ident opt_table_alias lock_option { - if (!Select->add_table_to_list(YYTHD, $1, $2, 0, (thr_lock_type) $3)) + thr_lock_type lock_type= (thr_lock_type) $3; + if (!Select->add_table_to_list(YYTHD, $1, $2, 0, lock_type)) MYSQL_YYABORT; + /* If table is to be write locked, protect from a impending GRL. */ + if (lock_type >= TL_WRITE_ALLOW_WRITE) + Lex->protect_against_global_read_lock= TRUE; } ; diff --git a/storage/ibmdb2i/db2i_collationSupport.cc b/storage/ibmdb2i/db2i_collationSupport.cc index 26ad0c9dee6..a41f211a689 100644 --- a/storage/ibmdb2i/db2i_collationSupport.cc +++ b/storage/ibmdb2i/db2i_collationSupport.cc @@ -111,7 +111,7 @@ static const char* mySQLCollation[MAX_COLLATION] = {"ucs2_slovak"}, {"ucs2_slovenian"}, {"ucs2_spanish"}, - {"ucs2_spanish2"}, + {"ucs2_swedish"}, {"ucs2_turkish"}, {"ucs2_unicode"}, {"ucs2"}, @@ -132,7 +132,7 @@ static const char* mySQLCollation[MAX_COLLATION] = {"utf8_slovak"}, {"utf8_slovenian"}, {"utf8_spanish"}, - {"utf8_spanish2"}, + {"utf8_swedish"}, {"utf8_turkish"}, {"utf8_unicode"}, {"utf8"} @@ -205,7 +205,7 @@ static const char* mySqlSortSequence[MAX_COLLATION] = {"ASK"}, {"ASL"}, {"AES"}, - {"AES__TRADIT"}, + {"ASW"}, {"ATR"}, {"AEN"}, {"*HEX"}, @@ -226,7 +226,7 @@ static const char* mySqlSortSequence[MAX_COLLATION] = {"ASK"}, {"ASL"}, {"AES"}, - {"AES__TRADIT"}, + {"ASW"}, {"ATR"}, {"AEN"}, {"*HEX"} diff --git a/storage/ibmdb2i/db2i_misc.h b/storage/ibmdb2i/db2i_misc.h index 1cc3f962cfc..9e20f01208b 100644 --- a/storage/ibmdb2i/db2i_misc.h +++ b/storage/ibmdb2i/db2i_misc.h @@ -92,11 +92,17 @@ bool convertMySQLNameToDB2Name(const char* input, return (o <= outlen-1); } -bool isUpperOrQuote(const CHARSET_INFO* cs, const char* s) +bool isOrdinaryIdentifier(const char* s) { while (*s) { - if (my_isupper(cs, *s) || (*s == '"')) + if (my_isupper(system_charset_info, *s) || + my_isdigit(system_charset_info, *s) || + (*s == '_') || + (*s == '@') || + (*s == '$') || + (*s == '#') || + (*s == '"')) ++s; else return false; diff --git a/storage/ibmdb2i/ha_ibmdb2i.cc b/storage/ibmdb2i/ha_ibmdb2i.cc index 6c7ce12ded1..ad80a80fc97 100644 --- a/storage/ibmdb2i/ha_ibmdb2i.cc +++ b/storage/ibmdb2i/ha_ibmdb2i.cc @@ -2122,7 +2122,7 @@ int ha_ibmdb2i::create(const char *name, TABLE *table_arg, if (osVersion.v < 6) { if (strlen(libName) > - MAX_DB2_V5R4_LIBNAME_LENGTH + (isUpperOrQuote(system_charset_info, libName) ? 2 : 0)) + MAX_DB2_V5R4_LIBNAME_LENGTH + (isOrdinaryIdentifier(libName) ? 2 : 0)) { getErrTxt(DB2I_ERR_TOO_LONG_SCHEMA,libName, MAX_DB2_V5R4_LIBNAME_LENGTH); DBUG_RETURN(DB2I_ERR_TOO_LONG_SCHEMA); @@ -2323,7 +2323,7 @@ int ha_ibmdb2i::create(const char *name, TABLE *table_arg, if (!rc && !isTemporary) { db2i_table* temp = new db2i_table(table_arg->s, name); - int32 rc = temp->fastInitForCreate(name); + rc = temp->fastInitForCreate(name); delete temp; if (rc) delete_table(name); diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 72e202e6132..dd66c255475 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -315,6 +315,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, t2_keys in Number of keys in second table t2_recs in Number of records in second table strict in Strict check switch + table in handle to the table object DESCRIPTION This function compares two MyISAM definitions. By intention it was done @@ -330,6 +331,10 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, Otherwise 'strict' flag must be set to 1 and it is not required to pass converted dot-frm definition as t1_*. + For compatibility reasons we relax some checks, specifically: + - 4.0 (and earlier versions) always set key_alg to 0. + - 4.0 (and earlier versions) have the same language for all keysegs. + RETURN VALUE 0 - Equal definitions. 1 - Different definitions. @@ -344,10 +349,11 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, uint t1_keys, uint t1_recs, MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, - uint t2_keys, uint t2_recs, bool strict) + uint t2_keys, uint t2_recs, bool strict, TABLE *table_arg) { uint i, j; DBUG_ENTER("check_definition"); + my_bool mysql_40_compat= table_arg && table_arg->s->frm_version < FRM_VER_TRUE_VARCHAR; if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys)) { DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u", @@ -386,8 +392,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, test(t2_keyinfo[i].flag & HA_SPATIAL))); DBUG_RETURN(1); } - if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs || - t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) + if ((mysql_40_compat && + t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) || + t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs) { DBUG_PRINT("error", ("Key %d has different definition", i)); DBUG_PRINT("error", ("t1_keysegs=%d, t1_key_alg=%d", @@ -417,8 +424,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */ } - if (t1_keysegs_j__type != t2_keysegs[j].type || - t1_keysegs[j].language != t2_keysegs[j].language || + if ((mysql_40_compat && + t1_keysegs[j].language != t2_keysegs[j].language) || + t1_keysegs_j__type != t2_keysegs[j].type || t1_keysegs[j].null_bit != t2_keysegs[j].null_bit || t1_keysegs[j].length != t2_keysegs[j].length) { @@ -671,7 +679,8 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) } if (check_definition(keyinfo, recinfo, table->s->keys, recs, file->s->keyinfo, file->s->rec, - file->s->base.keys, file->s->base.fields, true)) + file->s->base.keys, file->s->base.fields, + true, table)) { /* purecov: begin inspected */ my_errno= HA_ERR_CRASHED; diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 07105aea88d..2066d092e1f 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -35,9 +35,6 @@ int mi_close(register MI_INFO *info) if (info->lock_type == F_EXTRA_LCK) info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */ - if (share->reopen == 1 && share->kfile >= 0) - _mi_decrement_open_count(info); - if (info->lock_type != F_UNLCK) { if (mi_lock_database(info,F_UNLCK)) @@ -63,6 +60,8 @@ int mi_close(register MI_INFO *info) my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR)); if (flag) { + DBUG_EXECUTE_IF("crash_before_flush_keys", + if (share->kfile >= 0) abort();); if (share->kfile >= 0 && flush_key_blocks(share->key_cache, share->kfile, share->temporary ? FLUSH_IGNORE_CHANGED : @@ -78,6 +77,8 @@ int mi_close(register MI_INFO *info) */ if (share->mode != O_RDONLY && mi_is_crashed(info)) mi_state_info_write(share->kfile, &share->state, 1); + /* Decrement open count must be last I/O on this file. */ + _mi_decrement_open_count(info); if (my_close(share->kfile,MYF(0))) error = my_errno; } diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 3433c26f98b..d1cbd6955dd 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -66,7 +66,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, my_bool mi_dynmap_file(MI_INFO *info, my_off_t size) { DBUG_ENTER("mi_dynmap_file"); - if (size > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN) + if (size > (my_off_t) (~((size_t) 0))) { DBUG_PRINT("warning", ("File is too large for mmap")); DBUG_RETURN(1); @@ -80,7 +80,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size) upon a write if no physical memory is available. */ info->s->file_map= (uchar*) - my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN), + my_mmap(0, (size_t) size, info->s->mode==O_RDONLY ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, @@ -113,7 +113,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size) if (info->s->file_map) { VOID(my_munmap((char*) info->s->file_map, - (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN)); + (size_t) info->s->mmaped_length)); mi_dynmap_file(info, size); } } diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index 0f3c35235e9..d9abcbce050 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -209,10 +209,17 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) This segment will be reallocated after construction of the tables. */ length=(uint) (elements*2+trees*(1 << myisam_quick_table_bits)); + /* + To keep some algorithms simpler, we accept that they access + bytes beyond the end of the input data. This can affect up to + one byte less than the "word size" size used in this file, + which is BITS_SAVED / 8. To avoid accessing non-allocated + data, we add (BITS_SAVED / 8) - 1 bytes to the buffer size. + */ if (!(share->decode_tables=(uint16*) my_malloc((length + OFFSET_TABLE_SIZE) * sizeof(uint16) + - (uint) (share->pack.header_length - sizeof(header)), - MYF(MY_WME | MY_ZEROFILL)))) + (uint) (share->pack.header_length - sizeof(header) + + (BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL)))) goto err1; tmp_buff=share->decode_tables+length; disk_cache= (uchar*) (tmp_buff+OFFSET_TABLE_SIZE); @@ -1431,31 +1438,6 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff) bit_buff->current_byte=0; return; } - else - { - uint len= 0; - uint i= 0; - /* - Check if the remaining buffer/record to read is less than the word size. - If so read byte by byte - - Note: if this branch becomes a bottleneck it can be removed, assuming - that the second memory segment allocates 7 extra bytes (see - _mi_read_pack_info()). - */ - len= bit_buff->end - bit_buff->pos; - if (len < (BITS_SAVED / 8)) - { - bit_buff->current_byte= 0; - for (i=0 ; i < len ; i++) - { - bit_buff->current_byte+= (((uint) ((uchar) bit_buff->pos[len - i - 1])) - << (8 * i)); - } - bit_buff->pos= bit_buff->end; - return; - } - } #if BITS_SAVED == 64 bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) + @@ -1520,7 +1502,9 @@ my_bool _mi_memmap_file(MI_INFO *info) DBUG_PRINT("warning",("File isn't extended for memmap")); DBUG_RETURN(0); } - if (mi_dynmap_file(info, share->state.state.data_file_length)) + if (mi_dynmap_file(info, + share->state.state.data_file_length + + MEMMAP_EXTRA_MARGIN)) DBUG_RETURN(0); } info->opt_flag|= MEMMAP_USED; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 8165bd191b1..ac0be2f01cc 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1306,7 +1306,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, char * name) share->base.max_key_file_length != HA_OFFSET_ERROR) printf("Max datafile length: %13s Max keyfile length: %13s\n", llstr(share->base.max_data_file_length-1,llbuff), - llstr(share->base.max_key_file_length-1,llbuff2)); + ullstr(share->base.max_key_file_length - 1, llbuff2)); } } diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 061af97d0fb..7e25309ae70 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -137,7 +137,8 @@ extern int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, uint t1_keys, uint t1_recs, MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, - uint t2_keys, uint t2_recs, bool strict); + uint t2_keys, uint t2_recs, bool strict, + TABLE *table_arg); static void split_file_name(const char *file_name, LEX_STRING *db, LEX_STRING *name); @@ -595,7 +596,7 @@ int ha_myisammrg::attach_children(void) if (check_definition(keyinfo, recinfo, keys, recs, u_table->table->s->keyinfo, u_table->table->s->rec, u_table->table->s->base.keys, - u_table->table->s->base.fields, false)) + u_table->table->s->base.fields, false, NULL)) { DBUG_PRINT("error", ("table definition mismatch: '%s'", u_table->table->filename));