diff --git a/config/ac-macros/character_sets.m4 b/config/ac-macros/character_sets.m4 index a9f7bd73858..24bdd92b083 100644 --- a/config/ac-macros/character_sets.m4 +++ b/config/ac-macros/character_sets.m4 @@ -5,6 +5,9 @@ dnl you must also create strings/ctype-$charset_name.c AC_DIVERT_PUSH(0) +# Any changes to the available character sets must also go into +# include/config-win.h + define(CHARSETS_AVAILABLE0,binary) define(CHARSETS_AVAILABLE1,armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257) define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8) diff --git a/include/config-win.h b/include/config-win.h index c8b9004eb8a..ab0926af864 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -197,11 +197,6 @@ typedef uint rf_SetTimer; #define SIGNAL_WITH_VIO_CLOSE #endif -/* Use all character sets in MySQL */ -#define USE_MB 1 -#define USE_MB_IDENT 1 -#define USE_STRCOLL 1 - /* All windows servers should support .sym files */ #undef USE_SYMDIR #define USE_SYMDIR @@ -371,9 +366,6 @@ inline ulonglong double2ulonglong(double d) #define shared_memory_buffer_length 16000 #define default_shared_memory_base_name "MYSQL" -#define MYSQL_DEFAULT_CHARSET_NAME "latin1" -#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" - #define HAVE_SPATIAL 1 #define HAVE_RTREE_KEYS 1 @@ -383,40 +375,54 @@ inline ulonglong double2ulonglong(double d) #define COMMUNITY_SERVER 1 #define ENABLED_PROFILING 1 -/* Define charsets you want */ -/* #undef HAVE_CHARSET_armscii8 */ -/* #undef HAVE_CHARSET_ascii */ +/* + Our Windows binaries include all character sets which MySQL supports. + Any changes to the available character sets must also go into + config/ac-macros/character_sets.m4 +*/ + +#define MYSQL_DEFAULT_CHARSET_NAME "latin1" +#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" + +#define USE_MB 1 +#define USE_MB_IDENT 1 +#define USE_STRCOLL 1 + +#define HAVE_CHARSET_armscii8 +#define HAVE_CHARSET_ascii #define HAVE_CHARSET_big5 1 #define HAVE_CHARSET_cp1250 1 -/* #undef HAVE_CHARSET_cp1251 */ -/* #undef HAVE_CHARSET_cp1256 */ -/* #undef HAVE_CHARSET_cp1257 */ -/* #undef HAVE_CHARSET_cp850 */ -/* #undef HAVE_CHARSET_cp852 */ -/* #undef HAVE_CHARSET_cp866 */ +#define HAVE_CHARSET_cp1251 +#define HAVE_CHARSET_cp1256 +#define HAVE_CHARSET_cp1257 +#define HAVE_CHARSET_cp850 +#define HAVE_CHARSET_cp852 +#define HAVE_CHARSET_cp866 #define HAVE_CHARSET_cp932 1 -/* #undef HAVE_CHARSET_dec8 */ +#define HAVE_CHARSET_dec8 #define HAVE_CHARSET_eucjpms 1 #define HAVE_CHARSET_euckr 1 #define HAVE_CHARSET_gb2312 1 #define HAVE_CHARSET_gbk 1 -/* #undef HAVE_CHARSET_greek */ -/* #undef HAVE_CHARSET_hebrew */ -/* #undef HAVE_CHARSET_hp8 */ -/* #undef HAVE_CHARSET_keybcs2 */ -/* #undef HAVE_CHARSET_koi8r */ -/* #undef HAVE_CHARSET_koi8u */ +#define HAVE_CHARSET_geostd8 +#define HAVE_CHARSET_greek +#define HAVE_CHARSET_hebrew +#define HAVE_CHARSET_hp8 +#define HAVE_CHARSET_keybcs2 +#define HAVE_CHARSET_koi8r +#define HAVE_CHARSET_koi8u #define HAVE_CHARSET_latin1 1 #define HAVE_CHARSET_latin2 1 -/* #undef HAVE_CHARSET_latin5 */ -/* #undef HAVE_CHARSET_latin7 */ -/* #undef HAVE_CHARSET_macce */ -/* #undef HAVE_CHARSET_macroman */ +#define HAVE_CHARSET_latin5 +#define HAVE_CHARSET_latin7 +#define HAVE_CHARSET_macce +#define HAVE_CHARSET_macroman #define HAVE_CHARSET_sjis 1 -/* #undef HAVE_CHARSET_swe7 */ +#define HAVE_CHARSET_swe7 #define HAVE_CHARSET_tis620 1 #define HAVE_CHARSET_ucs2 1 #define HAVE_CHARSET_ujis 1 #define HAVE_CHARSET_utf8 1 + #define HAVE_UCA_COLLATIONS 1 #define HAVE_BOOL 1 diff --git a/mysql-test/include/rpl_events.inc b/mysql-test/include/rpl_events.inc index 34ceba81a38..0effa8c4e5c 100644 --- a/mysql-test/include/rpl_events.inc +++ b/mysql-test/include/rpl_events.inc @@ -62,7 +62,9 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name DROP EVENT IF EXISTS test.slave_once; --enable_warnings -CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO +# Create an event on slave and check its state. An event shouldn't be executed +# so set start time in 1 hour. +CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once'); --echo "Checking event status on the slave for originator value = slave's server_id" @@ -81,8 +83,11 @@ connection master; DROP EVENT IF EXISTS test.justonce; --enable_warnings +# Create an event on master and check its state on slave. An event shouldn't be executed +# so set start time in 1 hour. Check that changes of event statement replicated to slave + --echo "Creating event test.er on the master" -CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO +CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er'); --echo "Checking event status on the master" @@ -95,7 +100,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND connection master; --echo "Altering event test.er on the master" -ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO +ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er'); --echo "Checking event status on the master" @@ -123,8 +128,11 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; # test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status # on CREATE EVENT +# Create an event on slave and check its status. An event shouldn't be executed +# so set start time in 1 hour. + --echo "Creating event test.slave_terminate on the slave" -CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO +CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate'); --echo "Checking event status on the slave" diff --git a/mysql-test/r/character_set_database_func.result b/mysql-test/r/character_set_database_func.result index 95b65eacfd2..60628c30187 100644 --- a/mysql-test/r/character_set_database_func.result +++ b/mysql-test/r/character_set_database_func.result @@ -2,6 +2,7 @@ SET @global_character_set_database = @@global.character_set_database; SET @session_character_set_database = @@session.character_set_database; SET @session_character_set_server = @@session.character_set_server; +SET @global_character_set_server = @@global.character_set_server; SET @@global.character_set_database = utf8; 'connect (con1,localhost,root,,,,)' 'connection con1' @@ -71,6 +72,15 @@ SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1; count(*) 1 DROP TABLE IF EXISTS t1; +'Bug#27208: If no current database, character_set_database !=character_set_server' +SET GLOBAL character_set_server=latin5; +CREATE DATABASE csdb CHARACTER SET = utf8; +USE csdb; +DROP DATABASE csdb; +SELECT @@character_set_database; +@@character_set_database +latin5 SET @@global.character_set_database = @global_character_set_database; SET @@session.character_set_database = @session_character_set_database; SET @@session.character_set_server = @session_character_set_server; +SET @@global.character_set_server = @global_character_set_server; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 99ae6d85fee..7e185daa668 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -1,14 +1,20 @@ drop table if exists t1; -SHOW GLOBAL VARIABLES LIKE "%e_format"; -Variable_name Value -date_format %d.%m.%Y -datetime_format %Y-%m-%d %H:%i:%s -time_format %H.%i.%s -SHOW SESSION VARIABLES LIKE "%e_format"; -Variable_name Value -date_format %d.%m.%Y -datetime_format %Y-%m-%d %H:%i:%s -time_format %H.%i.%s +SELECT variable_name, variable_value +FROM information_schema.global_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; +variable_name variable_value +DATETIME_FORMAT %Y-%m-%d %H:%i:%s +DATE_FORMAT %d.%m.%Y +TIME_FORMAT %H.%i.%s +SELECT variable_name, variable_value +FROM information_schema.session_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; +variable_name variable_value +DATETIME_FORMAT %Y-%m-%d %H:%i:%s +DATE_FORMAT %d.%m.%Y +TIME_FORMAT %H.%i.%s SET time_format='%H%i%s'; SET time_format='%H:%i:%s.%f'; SET time_format='%h-%i-%s.%f%p'; @@ -26,11 +32,14 @@ set datetime_format= '%H:%i:%s %Y-%m-%d'; set datetime_format= '%H:%i:%s.%f %m-%d-%Y'; set datetime_format= '%h:%i:%s %p %Y-%m-%d'; set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d'; -SHOW SESSION VARIABLES LIKE "%e_format"; -Variable_name Value -date_format %m-%d-%Y -datetime_format %h:%i:%s.%f %p %Y-%m-%d -time_format %h:%i:%s%p +SELECT variable_name, variable_value +FROM information_schema.session_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; +variable_name variable_value +DATETIME_FORMAT %h:%i:%s.%f %p %Y-%m-%d +DATE_FORMAT %m-%d-%Y +TIME_FORMAT %h:%i:%s%p SET time_format='%h:%i:%s'; ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s' SET time_format='%H %i:%s'; diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index a5a96fd4958..9c3cc8fc89e 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -424,3 +424,10 @@ select f1 from t1 group by f1 having max(f1)=f1; f1 set session sql_mode=''; drop table t1; +CREATE TABLE t1 ( a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL); +SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; +b COUNT(DISTINCT a) +NULL 1 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/innodb-semi-consistent.result b/mysql-test/r/innodb-semi-consistent.result index 6173048c320..55e3cb5c7b4 100644 --- a/mysql-test/r/innodb-semi-consistent.result +++ b/mysql-test/r/innodb-semi-consistent.result @@ -1,6 +1,6 @@ drop table if exists t1; set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; insert into t1 values (1),(2),(3),(4),(5),(6),(7); set autocommit=0; @@ -8,11 +8,12 @@ select * from t1 where a=3 lock in share mode; a 3 set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; set autocommit=0; update t1 set a=10 where a=5; ERROR HY000: Lock wait timeout exceeded; try restarting transaction commit; +set session transaction isolation level read committed; update t1 set a=10 where a=5; select * from t1 where a=2 for update; ERROR HY000: Lock wait timeout exceeded; try restarting transaction diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index 7ed9b86d887..50d700ab7a2 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -48,4 +48,9 @@ Table Op Msg_type Msg_text test.t1 optimize error Table 'test.t1' is read only Warnings: Error 1036 Table 't1' is read only +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair error Table 'test.t1' is read only +Warnings: +Error 1036 Table 't1' is read only drop table t1; diff --git a/mysql-test/r/partition_innodb_semi_consistent.result b/mysql-test/r/partition_innodb_semi_consistent.result index 1bb39af043a..471da4c1c2e 100644 --- a/mysql-test/r/partition_innodb_semi_consistent.result +++ b/mysql-test/r/partition_innodb_semi_consistent.result @@ -1,6 +1,6 @@ drop table if exists t1; set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1 @@ -13,11 +13,12 @@ select * from t1 where a=3 lock in share mode; a 3 set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; set autocommit=0; update t1 set a=10 where a=5; ERROR HY000: Lock wait timeout exceeded; try restarting transaction commit; +set session transaction isolation level read committed; update t1 set a=10 where a=5; select * from t1 where a=2 for update; ERROR HY000: Lock wait timeout exceeded; try restarting transaction diff --git a/mysql-test/r/query_cache_notembedded.result b/mysql-test/r/query_cache_notembedded.result index ec78c2267d2..b236320a6dd 100644 --- a/mysql-test/r/query_cache_notembedded.result +++ b/mysql-test/r/query_cache_notembedded.result @@ -346,6 +346,22 @@ id drop table t1; drop function f1; set GLOBAL query_cache_size=0; +DROP TABLE IF EXISTS t1; +FLUSH STATUS; +SET GLOBAL query_cache_size=1048576; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SHOW STATUS LIKE 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +LOCK TABLES t1 WRITE; +SELECT * FROM t1; +UNLOCK TABLES; +SHOW STATUS LIKE 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +DROP TABLE t1; +SET GLOBAL query_cache_size= default; SET GLOBAL log_bin_trust_function_creators = 0; DROP DATABASE IF EXISTS bug30269; FLUSH STATUS; diff --git a/mysql-test/suite/rpl/r/rpl_cross_version.result b/mysql-test/suite/rpl/r/rpl_cross_version.result new file mode 100644 index 00000000000..de5dd134516 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_cross_version.result @@ -0,0 +1,12 @@ +==== Initialize ==== +Setting up fake replication from MYSQL_TEST_DIR/suite/binlog/std_data/binlog_old_version_4_1.000001 +==== Test ==== +start slave sql_thread; +==== a prove that the fake has been processed successfully ==== +SELECT COUNT(*) - 17920 as zero FROM t3; +zero +0 +==== Clean up ==== +stop slave sql_thread; +Cleaning up after setup_fake_relay_log.inc +drop table t1, t3; diff --git a/mysql-test/suite/rpl/r/rpl_events.result b/mysql-test/suite/rpl/r/rpl_events.result index e4a412cb1d5..b797183f9d2 100644 --- a/mysql-test/suite/rpl/r/rpl_events.result +++ b/mysql-test/suite/rpl/r/rpl_events.result @@ -1,10 +1,11 @@ -set global event_scheduler=1; 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; +SET @old_event_scheduler = @@global.event_scheduler; +set global event_scheduler=1; set binlog_format=row; DROP EVENT IF EXISTS test.justonce; drop table if exists t1,t2; @@ -34,7 +35,7 @@ db name status originator test justonce SLAVESIDE_DISABLED 1 "Dropping event test.slave_once on the slave" DROP EVENT IF EXISTS test.slave_once; -CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO +CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once'); "Checking event status on the slave for originator value = slave's server_id" SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once'; @@ -45,7 +46,7 @@ DROP EVENT IF EXISTS test.slave_once; "Dropping event test.justonce on the master" DROP EVENT IF EXISTS test.justonce; "Creating event test.er on the master" -CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO +CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er'); "Checking event status on the master" SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; @@ -56,7 +57,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND db name status originator body test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er') "Altering event test.er on the master" -ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO +ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er'); "Checking event status on the master" SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; @@ -75,7 +76,7 @@ db name status originator SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; db name status originator "Creating event test.slave_terminate on the slave" -CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO +CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate'); "Checking event status on the slave" SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate'; @@ -123,7 +124,7 @@ db name status originator test justonce SLAVESIDE_DISABLED 1 "Dropping event test.slave_once on the slave" DROP EVENT IF EXISTS test.slave_once; -CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO +CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once'); "Checking event status on the slave for originator value = slave's server_id" SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once'; @@ -134,7 +135,7 @@ DROP EVENT IF EXISTS test.slave_once; "Dropping event test.justonce on the master" DROP EVENT IF EXISTS test.justonce; "Creating event test.er on the master" -CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO +CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er'); "Checking event status on the master" SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; @@ -145,7 +146,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND db name status originator body test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er') "Altering event test.er on the master" -ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO +ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er'); "Checking event status on the master" SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; @@ -164,7 +165,7 @@ db name status originator SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; db name status originator "Creating event test.slave_terminate on the slave" -CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO +CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate'); "Checking event status on the slave" SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate'; @@ -190,4 +191,5 @@ select * from t28953; END;| ALTER EVENT event1 RENAME TO event2; DROP EVENT event2; +SET @@global.event_scheduler= @old_event_scheduler; DROP TABLE t28953; diff --git a/mysql-test/suite/rpl/t/rpl_cross_version-master.opt b/mysql-test/suite/rpl/t/rpl_cross_version-master.opt new file mode 100644 index 00000000000..815a8f81d32 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_cross_version-master.opt @@ -0,0 +1 @@ +--replicate-same-server-id --relay-log=slave-relay-bin diff --git a/mysql-test/suite/rpl/t/rpl_cross_version.test b/mysql-test/suite/rpl/t/rpl_cross_version.test new file mode 100644 index 00000000000..bb2ca350152 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_cross_version.test @@ -0,0 +1,36 @@ +# ==== Purpose ==== +# +# Verify cross-version replication from an old master to the up-to-date slave +# +# ==== Implementation ==== +# +# Feed to the slave server a binlog recorded on an old version master +# via setting up slave-to-slave replication. The latter is done by means of +# the opt file and include/setup_fake_relay_log.inc. +# The master's binlog is treated as a relay log that the SQL thread executes. +# + +--source include/have_log_bin.inc + +# +# Bug#31240 load data infile replication between (4.0 or 4.1) and 5.1 fails +# + +--echo ==== Initialize ==== +# the relay log contains create t1, t3 tables and load data infile +--let $fake_relay_log = $MYSQL_TEST_DIR/suite/binlog/std_data/binlog_old_version_4_1.000001 +--source include/setup_fake_relay_log.inc + +--echo ==== Test ==== +start slave sql_thread; +--let $slave_param = Exec_Master_Log_Pos +# end_log_pos of the last event of the relay log +--let $slave_param_value = 149436 +--source include/wait_for_slave_param.inc +--echo ==== a prove that the fake has been processed successfully ==== +SELECT COUNT(*) - 17920 as zero FROM t3; + +--echo ==== Clean up ==== +stop slave sql_thread; +--source include/cleanup_fake_relay_log.inc +drop table t1, t3; diff --git a/mysql-test/suite/rpl/t/rpl_events.test b/mysql-test/suite/rpl/t/rpl_events.test index 2a9cf86fe55..d06a3118389 100644 --- a/mysql-test/suite/rpl/t/rpl_events.test +++ b/mysql-test/suite/rpl/t/rpl_events.test @@ -5,11 +5,12 @@ # in both row based and statement based format # ################################################################## -set global event_scheduler=1; - --source include/not_embedded.inc --source include/master-slave.inc +SET @old_event_scheduler = @@global.event_scheduler; +set global event_scheduler=1; + let $engine_type= MyISAM; set binlog_format=row; @@ -51,5 +52,6 @@ sync_slave_with_master; # that there is no bad timing cauing it to try to access the table. connection master; +SET @@global.event_scheduler= @old_event_scheduler; DROP TABLE t28953; sync_slave_with_master; diff --git a/mysql-test/t/character_set_database_func.test b/mysql-test/t/character_set_database_func.test index b2d2d017d64..5ba8669c816 100644 --- a/mysql-test/t/character_set_database_func.test +++ b/mysql-test/t/character_set_database_func.test @@ -29,6 +29,7 @@ SET @global_character_set_database = @@global.character_set_database; SET @session_character_set_database = @@session.character_set_database; SET @session_character_set_server = @@session.character_set_server; +SET @global_character_set_server = @@global.character_set_server; SET @@global.character_set_database = utf8; --echo 'connect (con1,localhost,root,,,,)' @@ -106,10 +107,30 @@ SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1; DROP TABLE IF EXISTS t1; --enable_warnings + +#============================================================================== +--echo 'Bug#27208: If no current database, character_set_database !=character_set_server' +#============================================================================== + +SET GLOBAL character_set_server=latin5; + +connect (con2, localhost, root,,); +connection con2; + +CREATE DATABASE csdb CHARACTER SET = utf8; +USE csdb; +DROP DATABASE csdb; +SELECT @@character_set_database; + +connection default; +disconnect con2; + + #restore SET @@global.character_set_database = @global_character_set_database; SET @@session.character_set_database = @session_character_set_database; SET @@session.character_set_server = @session_character_set_server; +SET @@global.character_set_server = @global_character_set_server; ############################################################ # End of functionality Testing for character_set_database # ############################################################ diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index e474fac8a2a..e5dc7ffa53e 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -6,10 +6,15 @@ drop table if exists t1; --enable_warnings ---replace_result ROW STATEMENT MIXED -SHOW GLOBAL VARIABLES LIKE "%e_format"; ---replace_result ROW STATEMENT MIXED -SHOW SESSION VARIABLES LIKE "%e_format"; +SELECT variable_name, variable_value +FROM information_schema.global_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; + +SELECT variable_name, variable_value +FROM information_schema.session_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; # # Test setting a lot of different formats to see which formats are accepted and @@ -36,8 +41,10 @@ set datetime_format= '%H:%i:%s.%f %m-%d-%Y'; set datetime_format= '%h:%i:%s %p %Y-%m-%d'; set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d'; ---replace_result ROW STATEMENT MIXED -SHOW SESSION VARIABLES LIKE "%e_format"; +SELECT variable_name, variable_value +FROM information_schema.session_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; --error 1231 SET time_format='%h:%i:%s'; @@ -121,7 +128,7 @@ SET datetime_format=default; # Test of str_to_date # -# PS doesn't support fraction of a seconds +# PS doesn't support fractions of a second --disable_ps_protocol select str_to_date(concat('15-01-2001',' 2:59:58.999'), concat('%d-%m-%Y',' ','%H:%i:%s.%f')); diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 683abfd3783..af9af4fe1fc 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -432,3 +432,14 @@ select f1 from t1 having max(f1)=f1; select f1 from t1 group by f1 having max(f1)=f1; set session sql_mode=''; drop table t1; + + +# +# Bug #38637: COUNT DISTINCT prevents NULL testing in HAVING clause +# +CREATE TABLE t1 ( a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL); +SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/innodb-semi-consistent-master.opt b/mysql-test/t/innodb-semi-consistent-master.opt index 2746e4e184e..e76299453d3 100644 --- a/mysql-test/t/innodb-semi-consistent-master.opt +++ b/mysql-test/t/innodb-semi-consistent-master.opt @@ -1 +1 @@ ---innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=2 +--innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/innodb-semi-consistent.test b/mysql-test/t/innodb-semi-consistent.test index a3496625e95..6d3020bb560 100644 --- a/mysql-test/t/innodb-semi-consistent.test +++ b/mysql-test/t/innodb-semi-consistent.test @@ -11,7 +11,7 @@ connect (a,localhost,root,,); connect (b,localhost,root,,); connection a; set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; insert into t1 values (1),(2),(3),(4),(5),(6),(7); set autocommit=0; @@ -19,13 +19,15 @@ set autocommit=0; select * from t1 where a=3 lock in share mode; connection b; set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; set autocommit=0; -- error ER_LOCK_WAIT_TIMEOUT update t1 set a=10 where a=5; connection a; commit; connection b; +# perform a semi-consisent read (and unlock non-matching rows) +set session transaction isolation level read committed; update t1 set a=10 where a=5; connection a; -- error ER_LOCK_WAIT_TIMEOUT @@ -33,6 +35,7 @@ select * from t1 where a=2 for update; # this should lock the records (1),(2) select * from t1 where a=2 limit 1 for update; connection b; +# semi-consistent read will skip non-matching locked rows a=1, a=2 update t1 set a=11 where a=6; -- error ER_LOCK_WAIT_TIMEOUT update t1 set a=12 where a=2; diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index 3b55154d433..8d4bb83dc01 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -34,6 +34,8 @@ DROP TABLE t1; # # Bug#40949 Debug version of MySQL server crashes when run OPTIMIZE on compressed table. +# expanded with testcase for +# BUG#41574 - REPAIR TABLE: crashes for compressed tables # --disable_warnings drop table if exists t1; @@ -55,4 +57,5 @@ insert into t1 select * from t1; flush tables; --exec $MYISAMPACK $MYSQLTEST_VARDIR/master-data/test/t1 optimize table t1; +repair table t1; drop table t1; diff --git a/mysql-test/t/partition_innodb_semi_consistent.test b/mysql-test/t/partition_innodb_semi_consistent.test index cfa170f575b..6a6a7cf958e 100644 --- a/mysql-test/t/partition_innodb_semi_consistent.test +++ b/mysql-test/t/partition_innodb_semi_consistent.test @@ -14,7 +14,7 @@ connect (a,localhost,root,,); connect (b,localhost,root,,); connection a; set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1 @@ -27,7 +27,7 @@ set autocommit=0; select * from t1 where a=3 lock in share mode; connection b; set binlog_format=mixed; -set session transaction isolation level read committed; +set session transaction isolation level repeatable read; set autocommit=0; -- error ER_LOCK_WAIT_TIMEOUT update t1 set a=10 where a=5; @@ -35,6 +35,8 @@ connection a; #DELETE FROM t1 WHERE a=5; commit; connection b; +# perform a semi-consisent read (and unlock non-matching rows) +set session transaction isolation level read committed; update t1 set a=10 where a=5; connection a; -- error ER_LOCK_WAIT_TIMEOUT @@ -42,6 +44,7 @@ select * from t1 where a=2 for update; # this should lock the records (1),(2) select * from t1 where a=2 limit 1 for update; connection b; +# semi-consistent read will skip non-matching locked rows a=1, a=2 update t1 set a=11 where a=6; -- error ER_LOCK_WAIT_TIMEOUT update t1 set a=12 where a=2; diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test index 929b93e10d5..967b15d3d95 100644 --- a/mysql-test/t/query_cache_notembedded.test +++ b/mysql-test/t/query_cache_notembedded.test @@ -224,6 +224,38 @@ disconnect con2; connection default; set GLOBAL query_cache_size=0; + +# +# Bug#40264: Aborted cached query causes query to hang indefinitely on next cache hit +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +FLUSH STATUS; +SET GLOBAL query_cache_size=1048576; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SHOW STATUS LIKE 'Qcache_queries_in_cache'; +LOCK TABLES t1 WRITE; +connect(con1,localhost,root,,); +--send SELECT * FROM t1 +connection default; +let $show_type= open tables where `table`='t1' and in_use=2; +let $show_pattern= '%t1%2%'; +--source include/wait_show_pattern.inc +dirty_close con1; +UNLOCK TABLES; +let $show_type= open tables where `table`='t1' and in_use=0; +let $show_pattern= '%t1%0%'; +--source include/wait_show_pattern.inc +SHOW STATUS LIKE 'Qcache_queries_in_cache'; +DROP TABLE t1; +SET GLOBAL query_cache_size= default; + +# End of 5.0 tests + SET GLOBAL log_bin_trust_function_creators = 0; # diff --git a/sql/item.cc b/sql/item.cc index d3f933dc13f..2ee6de97ad0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2090,6 +2090,12 @@ bool Item_field::val_bool_result() } +bool Item_field::is_null_result() +{ + return (null_value=result_field->is_null()); +} + + bool Item_field::eq(const Item *item, bool binary_cmp) const { Item *real_item= ((Item *) item)->real_item(); @@ -5800,6 +5806,15 @@ double Item_ref::val_result() } +bool Item_ref::is_null_result() +{ + if (result_field) + return (null_value=result_field->is_null()); + + return is_null(); +} + + longlong Item_ref::val_int_result() { if (result_field) @@ -5905,7 +5920,9 @@ String *Item_ref::val_str(String* tmp) bool Item_ref::is_null() { DBUG_ASSERT(fixed); - return (*ref)->is_null(); + bool tmp=(*ref)->is_null_result(); + null_value=(*ref)->null_value; + return tmp; } diff --git a/sql/item.h b/sql/item.h index 8c58f0cebe9..be9daf672f0 100644 --- a/sql/item.h +++ b/sql/item.h @@ -729,6 +729,7 @@ public: virtual my_decimal *val_decimal_result(my_decimal *val) { return val_decimal(val); } virtual bool val_bool_result() { return val_bool(); } + virtual bool is_null_result() { return is_null(); } /* bit map of tables used by item */ virtual table_map used_tables() const { return (table_map) 0L; } @@ -1436,6 +1437,7 @@ public: String *str_result(String* tmp); my_decimal *val_decimal_result(my_decimal *); bool val_bool_result(); + bool is_null_result(); bool send(Protocol *protocol, String *str_arg); void reset_field(Field *f); bool fix_fields(THD *, Item **); @@ -2178,6 +2180,7 @@ public: String *str_result(String* tmp); my_decimal *val_decimal_result(my_decimal *); bool val_bool_result(); + bool is_null_result(); bool send(Protocol *prot, String *tmp); void make_field(Send_field *field); bool fix_fields(THD *, Item **); diff --git a/sql/item_func.cc b/sql/item_func.cc index 3cf1671bfa7..ff0c22ecfa9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4307,6 +4307,15 @@ my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val) } +bool Item_func_set_user_var::is_null_result() +{ + DBUG_ASSERT(fixed == 1); + check(TRUE); + update(); // Store expression + return is_null(); +} + + void Item_func_set_user_var::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("(@")); diff --git a/sql/item_func.h b/sql/item_func.h index 512da28589a..e2937a4daf8 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1335,6 +1335,7 @@ public: longlong val_int_result(); String *str_result(String *str); my_decimal *val_decimal_result(my_decimal *); + bool is_null_result(); bool update_hash(void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs, Derivation dv, bool unsigned_arg); bool send(Protocol *protocol, String *str_arg); diff --git a/sql/log_event.cc b/sql/log_event.cc index 3a3350a4eb8..be209b6c6c7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5945,8 +5945,15 @@ void Create_file_log_event::pack_info(Protocol *protocol) #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ -/* +/** Create_file_log_event::do_apply_event() + Constructor for Create_file_log_event to intantiate an event + from the relay log on the slave. + + @retval + 0 Success + @retval + 1 Failure */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) @@ -6015,7 +6022,7 @@ err: if (fd >= 0) my_close(fd, MYF(0)); thd_proc_info(thd, 0); - return error == 0; + return error != 0; } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 5e098edbd7f..7c97ee4cf32 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -781,6 +781,9 @@ void query_cache_end_of_result(THD *thd) if (thd->net.query_cache_query == 0) DBUG_VOID_RETURN; + /* Ensure that only complete results are cached. */ + DBUG_ASSERT(thd->main_da.is_eof()); + if (thd->killed) { query_cache_abort(&thd->net); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6358f7ce055..5d895833f42 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -128,7 +128,7 @@ static my_bool innobase_file_per_table = FALSE; static my_bool innobase_locks_unsafe_for_binlog = FALSE; static my_bool innobase_rollback_on_timeout = FALSE; static my_bool innobase_create_status_file = FALSE; -static my_bool innobase_stats_on_metadata = TRUE; +static my_bool innobase_stats_on_metadata = TRUE; static my_bool innobase_adaptive_hash_index = TRUE; static char* internal_innobase_data_file_path = NULL; @@ -461,7 +461,7 @@ innodb_srv_conc_exit_innodb( /*========================*/ trx_t* trx) /* in: transaction handle */ { - if (UNIV_LIKELY(!srv_thread_concurrency)) { + if (UNIV_LIKELY(!trx->declared_to_be_inside_innodb)) { return; } @@ -1713,8 +1713,6 @@ innobase_init( srv_max_n_open_files = (ulint) innobase_open_files; srv_innodb_status = (ibool) innobase_create_status_file; - srv_stats_on_metadata = (ibool) innobase_stats_on_metadata; - srv_use_adaptive_hash_indexes = (ibool) innobase_adaptive_hash_index; @@ -2510,6 +2508,8 @@ retry: prebuilt = row_create_prebuilt(ib_table); prebuilt->mysql_row_len = table->s->reclength; + prebuilt->default_rec = table->s->default_values; + ut_ad(prebuilt->default_rec); /* Looks like MySQL-3.23 sometimes has primary key number != 0 */ @@ -3687,7 +3687,7 @@ no_commit: /* We don't want to mask autoinc overflow errors. */ if (prebuilt->autoinc_error != DB_SUCCESS) { - error = prebuilt->autoinc_error; + error = (int) prebuilt->autoinc_error; goto report_error; } @@ -4129,7 +4129,8 @@ ha_innobase::unlock_row(void) switch (prebuilt->row_read_type) { case ROW_READ_WITH_LOCKS: if (!srv_locks_unsafe_for_binlog - || prebuilt->trx->isolation_level == TRX_ISO_READ_COMMITTED) { + && prebuilt->trx->isolation_level + != TRX_ISO_READ_COMMITTED) { break; } /* fall through */ @@ -5976,7 +5977,7 @@ ha_innobase::info( ib_table = prebuilt->table; if (flag & HA_STATUS_TIME) { - if (srv_stats_on_metadata) { + if (innobase_stats_on_metadata) { /* In sql_show we call with this flag: update then statistics so that they are up-to-date */ @@ -6024,11 +6025,13 @@ ha_innobase::info( n_rows++; } - /* Fix bug#29507: TRUNCATE shows too many rows affected. - Do not show the estimates for TRUNCATE command. */ + /* Fix bug#40386: Not flushing query cache after truncate. + n_rows can not be 0 unless the table is empty, set to 1 + instead. The original problem of bug#29507 is actually + fixed in the server code. */ if (thd_sql_command(user_thd) == SQLCOM_TRUNCATE) { - n_rows = 0; + n_rows = 1; /* We need to reset the prebuilt value too, otherwise checks for values greater than the last value written @@ -8236,7 +8239,7 @@ static MYSQL_SYSVAR_BOOL(status_file, innobase_create_status_file, NULL, NULL, FALSE); static MYSQL_SYSVAR_BOOL(stats_on_metadata, innobase_stats_on_metadata, - PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR, + PLUGIN_VAR_OPCMDARG, "Enable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)", NULL, NULL, TRUE); diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic index b8c24bb074a..ad0f95755d2 100644 --- a/storage/innobase/include/data0type.ic +++ b/storage/innobase/include/data0type.ic @@ -558,5 +558,5 @@ dtype_get_sql_null_size( const dtype_t* type) /* in: type */ { return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len, - type->mbminlen, type->mbmaxlen) > 0); + type->mbminlen, type->mbmaxlen)); } diff --git a/storage/innobase/include/hash0hash.ic b/storage/innobase/include/hash0hash.ic index 49bcc7b31d0..d246d8ee831 100644 --- a/storage/innobase/include/hash0hash.ic +++ b/storage/innobase/include/hash0hash.ic @@ -58,7 +58,8 @@ hash_get_mutex_no( hash_table_t* table, /* in: hash table */ ulint fold) /* in: fold */ { - return(ut_2pow_remainder(fold, table->n_mutexes)); + return(ut_2pow_remainder(hash_calc_hash(fold, table), + table->n_mutexes)); } /**************************************************************** diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 9c3ba558d3c..9b2f3250486 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -594,6 +594,8 @@ struct row_prebuilt_struct { byte* ins_upd_rec_buff;/* buffer for storing data converted to the Innobase format from the MySQL format */ + const byte* default_rec; /* the default values of all columns + (a "default row") in MySQL format */ ulint hint_need_to_fetch_extra_cols; /* normally this is set to 0; if this is set to ROW_RETRIEVE_PRIMARY_KEY, diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 91daa6816b2..2516937565d 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -124,8 +124,6 @@ extern ulint srv_fast_shutdown; /* If this is 1, do not do a transactions). */ extern ibool srv_innodb_status; -extern ibool srv_stats_on_metadata; - extern ibool srv_use_doublewrite_buf; extern ibool srv_use_checksums; diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index d76af54b420..088d944cb91 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -342,7 +342,7 @@ row_mysql_store_col_in_innobase_format( /* In some cases we strip trailing spaces from UTF-8 and other multibyte charsets, from FIXED-length CHAR columns, to save space. UTF-8 would otherwise normally use 3 * the string length - bytes to store a latin1 string! */ + bytes to store an ASCII string! */ /* We assume that this CHAR field is encoded in a variable-length character set where spaces have @@ -620,6 +620,7 @@ row_create_prebuilt( prebuilt->ins_node = NULL; prebuilt->ins_upd_rec_buff = NULL; + prebuilt->default_rec = NULL; prebuilt->upd_node = NULL; prebuilt->ins_graph = NULL; @@ -1485,12 +1486,13 @@ row_unlock_for_mysql( ut_ad(prebuilt && trx); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); - if (!(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED)) { + if (UNIV_UNLIKELY + (!srv_locks_unsafe_for_binlog + && trx->isolation_level != TRX_ISO_READ_COMMITTED)) { fprintf(stderr, "InnoDB: Error: calling row_unlock_for_mysql though\n" - "InnoDB: srv_locks_unsafe_for_binlog is FALSE and\n" + "InnoDB: innodb_locks_unsafe_for_binlog is FALSE and\n" "InnoDB: this session is not using" " READ COMMITTED isolation level.\n"); diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 79f107ce77d..f53dfe8a686 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -2597,6 +2597,7 @@ row_sel_store_mysql_rec( ulint i; ut_ad(prebuilt->mysql_template); + ut_ad(prebuilt->default_rec); ut_ad(rec_offs_validate(rec, NULL, offsets)); if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { @@ -2683,58 +2684,14 @@ row_sel_store_mysql_rec( &= ~(byte) templ->mysql_null_bit_mask; } } else { - /* MySQL seems to assume the field for an SQL NULL - value is set to zero or space. Not taking this into - account caused seg faults with NULL BLOB fields, and - bug number 154 in the MySQL bug database: GROUP BY - and DISTINCT could treat NULL values inequal. */ - int pad_char; + /* MySQL assumes that the field for an SQL + NULL value is set to the default value. */ mysql_rec[templ->mysql_null_byte_offset] |= (byte) templ->mysql_null_bit_mask; - switch (templ->type) { - case DATA_VARCHAR: - case DATA_BINARY: - case DATA_VARMYSQL: - if (templ->mysql_type - == DATA_MYSQL_TRUE_VARCHAR) { - /* This is a >= 5.0.3 type - true VARCHAR. Zero the field. */ - pad_char = 0x00; - break; - } - /* Fall through */ - case DATA_CHAR: - case DATA_FIXBINARY: - case DATA_MYSQL: - /* MySQL pads all string types (except - BLOB, TEXT and true VARCHAR) with space. */ - if (UNIV_UNLIKELY(templ->mbminlen == 2)) { - /* Treat UCS2 as a special case. */ - data = mysql_rec - + templ->mysql_col_offset; - len = templ->mysql_col_len; - /* There are two UCS2 bytes per char, - so the length has to be even. */ - ut_a(!(len & 1)); - /* Pad with 0x0020. */ - while (len) { - *data++ = 0x00; - *data++ = 0x20; - len -= 2; - } - continue; - } - pad_char = 0x20; - break; - default: - pad_char = 0x00; - break; - } - - ut_ad(!pad_char || templ->mbminlen == 1); - memset(mysql_rec + templ->mysql_col_offset, - pad_char, templ->mysql_col_len); + memcpy(mysql_rec + templ->mysql_col_offset, + prebuilt->default_rec + templ->mysql_col_offset, + templ->mysql_col_len); } } diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index e8b7bd4cee2..e2d8bd4c600 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -283,13 +283,16 @@ ulong srv_commit_concurrency = 0; os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data structures */ -lint srv_conc_n_threads = 0; /* number of OS threads currently - inside InnoDB; it is not an error - if this drops temporarily below zero - because we do not demand that every - thread increments this, but a thread - waiting for a lock decrements this - temporarily */ +lint srv_conc_n_threads = 0; /* number of transactions that + have declared_to_be_inside_innodb + set. It used to be a non-error + for this value to drop below + zero temporarily. This is no + longer true. We'll, however, + keep the lint datatype to add + assertions to catch any corner + cases that we may have + missed. */ ulint srv_conc_n_waiting_threads = 0; /* number of OS threads waiting in the FIFO for a permission to enter InnoDB */ @@ -328,8 +331,6 @@ ulint srv_fast_shutdown = 0; /* Generate a innodb_status. file */ ibool srv_innodb_status = FALSE; -ibool srv_stats_on_metadata = TRUE; - ibool srv_use_doublewrite_buf = TRUE; ibool srv_use_checksums = TRUE; @@ -1022,6 +1023,8 @@ retry: return; } + ut_ad(srv_conc_n_threads >= 0); + if (srv_conc_n_threads < (lint)srv_thread_concurrency) { srv_conc_n_threads++; @@ -1148,6 +1151,8 @@ srv_conc_force_enter_innodb( return; } + ut_ad(srv_conc_n_threads >= 0); + os_fast_mutex_lock(&srv_conc_mutex); srv_conc_n_threads++; @@ -1169,11 +1174,6 @@ srv_conc_force_exit_innodb( { srv_conc_slot_t* slot = NULL; - if (UNIV_LIKELY(!srv_thread_concurrency)) { - - return; - } - if (trx->mysql_thd != NULL && thd_is_replication_slave_thread(trx->mysql_thd)) { @@ -1187,6 +1187,7 @@ srv_conc_force_exit_innodb( os_fast_mutex_lock(&srv_conc_mutex); + ut_ad(srv_conc_n_threads > 0); srv_conc_n_threads--; trx->declared_to_be_inside_innodb = FALSE; trx->n_tickets_to_enter_innodb = 0; diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index 69b72451f2b..1fceaa3562c 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -287,6 +287,10 @@ trx_free( "InnoDB: inside InnoDB.\n", stderr); trx_print(stderr, trx, 600); putc('\n', stderr); + + /* This is an error but not a fatal error. We must keep + the counters like srv_conc_n_threads accurate. */ + srv_conc_force_exit_innodb(trx); } if (trx->n_mysql_tables_in_use != 0 diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index 2aa7752d292..b31580d0ce0 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -410,7 +410,7 @@ trx_undo_seg_create( if (slot_no == ULINT_UNDEFINED) { ut_print_timestamp(stderr); fprintf(stderr, - "InnoDB: Warning: cannot find a free slot for" + " InnoDB: Warning: cannot find a free slot for" " an undo log. Do you have too\n" "InnoDB: many active transactions" " running concurrently?\n");