diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 7c682f402eb..f564ee31fed 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1249,6 +1249,14 @@ int main(int argc, char** argv) fprintf(result_file, "/*!32316 SET @OLD_SQL_LOG_BIN=@@SQL_LOG_BIN, SQL_LOG_BIN=0*/;\n"); + /* + In mysqlbinlog|mysql, don't want mysql to be disconnected after each + transaction (which would be the case with GLOBAL.COMPLETION_TYPE==2). + */ + fprintf(result_file, + "/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE," + "COMPLETION_TYPE=0*/;\n"); + for (save_stop_position= stop_position, stop_position= ~(my_off_t)0 ; (--argc >= 0) && !stop_passed ; ) { @@ -1263,6 +1271,13 @@ int main(int argc, char** argv) start_position= BIN_LOG_HEADER_SIZE; } + /* + Issue a ROLLBACK in case the last printed binlog was crashed and had half + of transaction. + */ + fprintf(result_file, + "ROLLBACK;\n" + "/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;\n"); if (disable_log_bin) fprintf(result_file, "/*!32316 SET SQL_LOG_BIN=@OLD_SQL_LOG_BIN*/;\n"); diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 8cbd4d58192..78672c7fd7b 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -528,6 +528,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 96 User var 1 136 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci master-bin.000001 136 Query 1 226 use `test`; insert into t2 values (@v) /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`; use test; @@ -536,6 +537,8 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t2 values (@v); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; drop table t2; set names latin1; create table t1 (a enum('x','y','z') character set ucs2); diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index df117479814..6fb2f7f2fb4 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -15,6 +15,7 @@ flush logs; --- Local -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1000000000; @@ -36,32 +37,44 @@ LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-0' INTO TABLE `t1` FI LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- Broken LOAD DATA -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; use test; SET TIMESTAMP=1000000000; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values ("Alas"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- --database -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=1; +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- --position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; use test; SET TIMESTAMP=1000000000; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values ("Alas"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- Remote -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1000000000; @@ -83,42 +96,59 @@ LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE `t1` FI LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- Broken LOAD DATA -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; use test; SET TIMESTAMP=1000000000; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values ("Alas"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- --database -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=1; +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- --position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; use test; SET TIMESTAMP=1000000000; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values ("Alas"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- reading stdin -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1108844556; BEGIN; SET TIMESTAMP=1108844555; insert t1 values (1); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; use test; SET TIMESTAMP=1108844556; BEGIN; SET TIMESTAMP=1108844555; insert t1 values (1); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; drop table t1, t2; diff --git a/mysql-test/r/mysqlbinlog2.result b/mysql-test/r/mysqlbinlog2.result index 8fdaa5bed4e..9899fa54301 100644 --- a/mysql-test/r/mysqlbinlog2.result +++ b/mysql-test/r/mysqlbinlog2.result @@ -16,6 +16,7 @@ insert into t1 values(null, "f"); --- Local -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -38,9 +39,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- offset -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=1; use test; @@ -61,9 +65,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; SET INSERT_ID=4; use test; SET TIMESTAMP=1579609946; @@ -74,9 +81,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -93,9 +103,12 @@ insert into t1 values(null, "b"); SET INSERT_ID=3; SET TIMESTAMP=1579609944; insert into t1 values(null, "c"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=3; use test; @@ -110,9 +123,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -126,9 +142,12 @@ insert into t1 values(null, "a"); SET INSERT_ID=2; SET TIMESTAMP=1579609942; insert into t1 values(null, "b"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- Local with 2 binlogs on command line -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -158,9 +177,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- offset -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=1; use test; @@ -188,9 +210,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; SET INSERT_ID=4; use test; SET TIMESTAMP=1579609946; @@ -208,9 +233,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -234,9 +262,12 @@ SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); SET INSERT_ID=6; +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=3; use test; @@ -258,9 +289,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -274,9 +308,12 @@ insert into t1 values(null, "a"); SET INSERT_ID=2; SET TIMESTAMP=1579609942; insert into t1 values(null, "b"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- Remote -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -299,9 +336,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- offset -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=1; use test; @@ -322,9 +362,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; SET INSERT_ID=4; use test; SET TIMESTAMP=1579609946; @@ -335,9 +378,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -354,9 +400,12 @@ insert into t1 values(null, "b"); SET INSERT_ID=3; SET TIMESTAMP=1579609944; insert into t1 values(null, "c"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=3; use test; @@ -371,9 +420,12 @@ insert into t1 values(null, "d"); SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -387,9 +439,12 @@ insert into t1 values(null, "a"); SET INSERT_ID=2; SET TIMESTAMP=1579609942; insert into t1 values(null, "b"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- Remote with 2 binlogs on command line -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -419,9 +474,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- offset -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=1; use test; @@ -449,9 +507,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; SET INSERT_ID=4; use test; SET TIMESTAMP=1579609946; @@ -469,9 +530,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-position -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -495,9 +559,12 @@ SET INSERT_ID=5; SET TIMESTAMP=1579609946; insert into t1 values(null, "e"); SET INSERT_ID=6; +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- start-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET INSERT_ID=3; use test; @@ -519,9 +586,12 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- stop-datetime -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -535,9 +605,12 @@ insert into t1 values(null, "a"); SET INSERT_ID=2; SET TIMESTAMP=1579609942; insert into t1 values(null, "b"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- to-last-log -- /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; use test; SET TIMESTAMP=1579609942; @@ -563,6 +636,8 @@ insert into t1 values(null, "e"); SET INSERT_ID=6; SET TIMESTAMP=1579609943; insert into t1 values(null, "f"); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; --- end of test -- drop table t1; diff --git a/mysql-test/r/rpl_charset.result b/mysql-test/r/rpl_charset.result index 98a8c53d5fd..ce958c15ece 100644 --- a/mysql-test/r/rpl_charset.result +++ b/mysql-test/r/rpl_charset.result @@ -175,6 +175,7 @@ select hex(c1), hex(c2) from t1; hex(c1) hex(c2) CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3 /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET TIMESTAMP=1000000000; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; @@ -245,6 +246,8 @@ CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255)); SET TIMESTAMP=1000000000; SET @@session.character_set_client=7,@@session.collation_connection=51,@@session.collation_server=30; INSERT INTO t1 (c1, c2) VALUES ('Ну, за рыбалку','Ну, за рыбалку'); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; drop table t1; create table `t1` ( `pk` varchar(10) not null default '', diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 8ae1d145227..4bc85a10638 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -184,6 +184,7 @@ master-bin.000001 230 User var 1 272 @`var1`=_latin1 0x273B616161 COLLATE latin1 master-bin.000001 272 User var 1 310 @`var2`=_latin1 0x61 COLLATE latin1_swedish_ci master-bin.000001 310 Query 1 411 use `test`; insert into t1 values (@var1),(@var2) /*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`; use test; @@ -196,6 +197,8 @@ SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`; SET @`var2`:=_latin1 0x61 COLLATE `latin1_swedish_ci`; SET TIMESTAMP=10000; insert into t1 values (@var1),(@var2); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; drop table t1; set @var= NULL ; select FIELD( @var,'1it','Hit') as my_column; diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index a8615ff2113..e38127ffd8e 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -128,15 +128,28 @@ then else MY_BASEDIR_VERSION=@prefix@ DATADIR=@localstatedir@ - if test -z "$MYSQL_HOME" - then - MYSQL_HOME=$DATADIR # Installation in a not common path - fi ledir=@libexecdir@ fi + if test -z "$MYSQL_HOME" then - MYSQL_HOME=$MY_BASEDIR_VERSION + if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf" + then + echo "WARNING: Found two instances of my.cnf -" + echo "$MY_BASEDIR_VERSION/my.cnf and" + echo "$DATADIR/my.cnf" + echo "IGNORING $DATADIR/my.cnf" + echo + MYSQL_HOME=$MY_BASEDIR_VERSION + elif test -r "$DATADIR/my.cnf" + then + echo "WARNING: Found $DATADIR/my.cnf" + echo "Datadir is deprecated place for my.cnf, please move it to $MY_BASEDIR_VERSION" + echo + MYSQL_HOME=$DATADIR + else + MYSQL_HOME=$MY_BASEDIR_VERSION + fi fi export MYSQL_HOME diff --git a/sql/lock.cc b/sql/lock.cc index 2dd12fce802..35b93c79fee 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -730,7 +730,7 @@ static void print_lock_error(int error, const char *table) least the first step above) global_read_lock_blocks_commit count of threads which have the global read lock and block - commits (i.e. have completed the second step above) + commits (i.e. are in or have completed the second step above) waiting_for_read_lock count of threads which want to take a global read lock but cannot protect_against_global_read_lock @@ -902,7 +902,8 @@ void start_waiting_global_read_lock(THD *thd) if (unlikely(thd->global_read_lock)) DBUG_VOID_RETURN; (void) pthread_mutex_lock(&LOCK_open); - tmp= (!--protect_against_global_read_lock && waiting_for_read_lock); + tmp= (!--protect_against_global_read_lock && + (waiting_for_read_lock || global_read_lock_blocks_commit)); (void) pthread_mutex_unlock(&LOCK_open); if (tmp) pthread_cond_broadcast(&COND_refresh); diff --git a/sql/log_event.cc b/sql/log_event.cc index 75d682fa6cd..bbf894c2385 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1029,7 +1029,7 @@ bool Query_log_event::write(IO_CACHE* file) if (sql_mode_inited) { *(start++)= Q_SQL_MODE_CODE; - int8store(start, sql_mode); + int8store(start, (ulonglong)sql_mode); start+= 8; } if (catalog_len >= 0) // i.e. "catalog inited" (false for 4.0 events) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0418225965a..ecf255b091d 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7467,7 +7467,7 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, double quick_prefix_selectivity; double io_cost; double cpu_cost= 0; /* TODO: CPU cost of index_read calls? */ - DBUG_ENTER("TRP_GROUP_MIN_MAX::cost"); + DBUG_ENTER("cost_group_min_max"); table_records= table->file->records; keys_per_block= (table->file->block_size / 2 / @@ -7971,7 +7971,15 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next() { int min_res= 0; int max_res= 0; +#ifdef HPUX11 + /* + volatile is required by a bug in the HP compiler due to which the + last test of result fails. + */ + volatile int result; +#else int result; +#endif int is_last_prefix; DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::get_next"); diff --git a/sql/set_var.cc b/sql/set_var.cc index 50094bb7f00..6ea1747ec07 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2089,7 +2089,7 @@ bool sys_var_character_set_server::check(THD *thd, set_var *var) (mysql_bin_log.is_open() || active_mi->slave_running || active_mi->rli.slave_running)) { - my_error(ER_LOGING_PROHIBIT_CHANGING_OF, MYF(0), + my_error(ER_LOGGING_PROHIBIT_CHANGING_OF, MYF(0), "character set, collation"); return 1; } @@ -2196,7 +2196,7 @@ bool sys_var_collation_server::check(THD *thd, set_var *var) (mysql_bin_log.is_open() || active_mi->slave_running || active_mi->rli.slave_running)) { - my_error(ER_LOGING_PROHIBIT_CHANGING_OF, MYF(0), + my_error(ER_LOGGING_PROHIBIT_CHANGING_OF, MYF(0), "character set, collation"); return 1; } @@ -2546,7 +2546,7 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var) (mysql_bin_log.is_open() || active_mi->slave_running || active_mi->rli.slave_running)) { - my_error(ER_LOGING_PROHIBIT_CHANGING_OF, MYF(0), "time zone"); + my_error(ER_LOGGING_PROHIBIT_CHANGING_OF, MYF(0), "time zone"); return 1; } #endif diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index fa20e52f7e7..5757510bfb4 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5276,7 +5276,7 @@ ER_NO_GROUP_FOR_PROC eng "Select must have a group with this procedure" ER_ORDER_WITH_PROC eng "Can't use ORDER clause with this procedure" -ER_LOGING_PROHIBIT_CHANGING_OF +ER_LOGGING_PROHIBIT_CHANGING_OF eng "Binary logging and replication forbid changing the global server %s" ER_NO_FILE_MAPPING eng "Can't map file: %-.64s, errno: %d"