diff --git a/client/mysqldump.c b/client/mysqldump.c index 58959f56a89..c068b2ff16e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2396,8 +2396,15 @@ static uint get_table_structure(char *table, char *db, char *table_type, fprintf(sql_file, ",\n %s %s", quote_name(row[0], name_buff, 0), row[1]); } + + /* + Stand-in tables are always MyISAM tables as the default + engine might have a column-limit that's lower than the + number of columns in the view, and MyISAM support is + guaranteed to be in the server anyway. + */ fprintf(sql_file, - "\n) */;\n" + "\n) ENGINE=MyISAM */;\n" "SET character_set_client = @saved_cs_client;\n"); check_io(sql_file); diff --git a/include/thr_lock.h b/include/thr_lock.h index a4ca6e6ddf2..77d428d1805 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -29,6 +29,14 @@ extern ulong locks_immediate,locks_waited ; enum thr_lock_type { TL_IGNORE=-1, TL_UNLOCK, /* UNLOCK ANY LOCK */ + /* + Parser only! At open_tables() becomes TL_READ or + TL_READ_NO_INSERT depending on the binary log format + (SBR/RBR) and on the table category (log table). + Used for tables that are read by statements which + modify tables. + */ + TL_READ_DEFAULT, TL_READ, /* Read lock */ TL_READ_WITH_SHARED_LOCKS, /* High prior. than TL_WRITE. Allow concurrent insert */ diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result index 44c258d7611..f9563b89b76 100644 --- a/mysql-test/r/compare.result +++ b/mysql-test/r/compare.result @@ -90,4 +90,9 @@ Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`a` AS `a`,(select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat('0',`test`.`t2`.`a`,'01')))) AS `x` from `test`.`t2` order by `test`.`t2`.`a` DROP TABLE t1,t2; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NOW()),(NOW()),(NOW()); +SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00'; +a +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/events_2.result b/mysql-test/r/events_2.result index 64d643505c5..db503f7aa6d 100644 --- a/mysql-test/r/events_2.result +++ b/mysql-test/r/events_2.result @@ -328,4 +328,81 @@ create event очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66 on schedule every 2 year do select 1; ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +create event event_35981 on schedule every 6 month on completion preserve +disable +do +select 1; +The following SELECTs should all give 1 +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and +on_completion = 'PRESERVE'; +count(*) +1 +alter event event_35981 enable; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and +on_completion = 'PRESERVE'; +count(*) +1 +alter event event_35981 on completion not preserve; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and +on_completion = 'NOT PRESERVE'; +count(*) +1 +alter event event_35981 disable; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and +on_completion = 'NOT PRESERVE'; +count(*) +1 +alter event event_35981 on completion preserve; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and +on_completion = 'PRESERVE'; +count(*) +1 +drop event event_35981; +create event event_35981 on schedule every 6 month disable +do +select 1; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and +on_completion = 'NOT PRESERVE'; +count(*) +1 +drop event event_35981; +create event event_35981 on schedule every 1 hour starts current_timestamp +on completion not preserve +do +select 1; +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00'; +ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +drop event event_35981; +create event event_35981 on schedule every 1 hour starts current_timestamp +on completion not preserve +do +select 1; +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion preserve; +Warnings: +Note 1544 Event execution time is in the past. Event has been disabled +drop event event_35981; +create event event_35981 on schedule every 1 hour starts current_timestamp +on completion preserve +do +select 1; +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00'; +Warnings: +Note 1544 Event execution time is in the past. Event has been disabled +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion not preserve; +ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion preserve; +Warnings: +Note 1544 Event execution time is in the past. Event has been disabled +drop event event_35981; drop database events_test; diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 2a4cee9fbbc..c5228538788 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -832,6 +832,35 @@ Execute select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 0 Query set global general_log = off deallocate prepare long_query; set global general_log = @old_general_log_state; +DROP TABLE IF EXISTS log_count; +DROP TABLE IF EXISTS slow_log_copy; +DROP TABLE IF EXISTS general_log_copy; +CREATE TABLE log_count (count BIGINT(21)); +SET @old_general_log_state = @@global.general_log; +SET @old_slow_log_state = @@global.slow_query_log; +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; +SET GLOBAL general_log = @old_general_log_state; +SET GLOBAL slow_query_log = @old_slow_log_state; +DROP TABLE log_count; SET @old_slow_log_state = @@global.slow_query_log; SET SESSION long_query_time = 0; SET GLOBAL slow_query_log = ON; diff --git a/mysql-test/r/mysqldump-max.result b/mysql-test/r/mysqldump-max.result index 2d118092a2c..c1c61cd7fe8 100644 --- a/mysql-test/r/mysqldump-max.result +++ b/mysql-test/r/mysqldump-max.result @@ -277,3 +277,16 @@ drop table t3; drop table t4; drop table t5; drop table t6; +SELECT @@global.storage_engine INTO @old_engine; +SET GLOBAL storage_engine=InnoDB; +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES(); +SELECT COUNT(*) FROM v1; +COUNT(*) +1 +SELECT COUNT(*) FROM v1; +COUNT(*) +1 +DROP VIEW v1; +DROP TABLE t1; +SET GLOBAL storage_engine=@old_engine; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 1e76e85ce64..ec397d8fb89 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2004,7 +2004,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( `a` varchar(30) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; @@ -2101,7 +2101,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( `a` int(11) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; @@ -2175,7 +2175,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( `a` varchar(30) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE `v2`*/; /*!50001 DROP VIEW IF EXISTS `v2`*/; @@ -2291,7 +2291,7 @@ SET character_set_client = utf8; `a` int(11), `b` int(11), `c` varchar(30) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v2`; /*!50001 DROP VIEW IF EXISTS `v2`*/; @@ -2299,7 +2299,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v2` ( `a` int(11) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v3`; /*!50001 DROP VIEW IF EXISTS `v3`*/; @@ -2309,7 +2309,7 @@ SET character_set_client = utf8; `a` int(11), `b` int(11), `c` varchar(30) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; /*!50001 DROP TABLE `v1`*/; /*!50001 DROP VIEW IF EXISTS `v1`*/; @@ -3046,7 +3046,7 @@ SET character_set_client = utf8; `a` int(11), `b` varchar(32), `c` varchar(32) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v1`; /*!50001 DROP VIEW IF EXISTS `v1`*/; @@ -3056,7 +3056,7 @@ SET character_set_client = utf8; `a` int(11), `b` varchar(32), `c` varchar(32) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS `v2`; /*!50001 DROP VIEW IF EXISTS `v2`*/; @@ -3066,7 +3066,7 @@ SET character_set_client = utf8; `a` int(11), `b` varchar(32), `c` varchar(32) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; USE `test`; @@ -3446,7 +3446,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( `id` int(11) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; USE `mysqldump_test_db`; @@ -3506,7 +3506,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `nasishnasifu` ( `id` bigint(20) unsigned -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; USE `mysqldump_tables`; @@ -3964,7 +3964,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `v1` ( `id` int(11) -) */; +) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; USE `mysqldump_test_db`; diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index e4e5a748b0d..23a38ff3885 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -742,3 +742,23 @@ WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 18 Using where DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +defid int(10) unsigned NOT NULL, +day int(10) unsigned NOT NULL, +count int(10) unsigned NOT NULL, +filler char(200), +KEY (defid,day) +) +PARTITION BY RANGE (day) ( +PARTITION p7 VALUES LESS THAN (20070401) , +PARTITION p8 VALUES LESS THAN (20070501)); +insert into t2 select 20, 20070311, 1, 'filler' from t1 A, t1 B; +insert into t2 select 20, 20070411, 1, 'filler' from t1 A, t1 B; +insert into t2 values(52, 20070321, 123, 'filler') ; +insert into t2 values(52, 20070322, 456, 'filler') ; +select sum(count) from t2 ch where ch.defid in (50,52) and ch.day between 20070320 and 20070401 group by defid; +sum(count) +579 +drop table t1, t2; diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 2cd132ce03c..2d91835d723 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -121,8 +121,8 @@ select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; @a+0 @a:=@a+0+count(*) count(*) @a+0 0 1 1 0 -1 3 2 0 -3 6 3 0 +0 2 2 0 +0 3 3 0 set @a=0; select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i; @a @a:="hello" @a @a:=3 @a @a:="hello again" @@ -370,4 +370,33 @@ select @rownum := @rownum + 1 as row, @prev_score := a as score from t1 order by score desc; drop table t1; +create table t1(b bigint); +insert into t1 (b) values (10), (30), (10); +set @var := 0; +select if(b=@var, 999, b) , @var := b from t1 order by b; +if(b=@var, 999, b) @var := b +10 10 +999 10 +30 30 +drop table t1; +create temporary table t1 (id int); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +@lastid != id @lastid @lastid := id +1 -1 2 +1 2 3 +0 3 3 +1 3 4 +drop table t1; +create temporary table t1 (id bigint); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +@lastid != id @lastid @lastid := id +1 -1 2 +1 2 3 +0 3 3 +1 3 4 +drop table t1; End of 5.1 tests diff --git a/mysql-test/suite/binlog/r/binlog_stm_row.result b/mysql-test/suite/binlog/r/binlog_stm_row.result new file mode 100644 index 00000000000..97ec38cfb3e --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_stm_row.result @@ -0,0 +1,71 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +SET GLOBAL BINLOG_FORMAT = STATEMENT; +SET SESSION BINLOG_FORMAT = STATEMENT; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 LIKE t1; +select @@SESSION.BINLOG_FORMAT; +@@SESSION.BINLOG_FORMAT +STATEMENT +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(2); +# +# Ensure that INSERT INTO .. SELECT FROM under SBR takes a read +# lock that will prevent the source table from being modified. +# +# con1 +SELECT GET_LOCK('Bug#34306', 120); +GET_LOCK('Bug#34306', 120) +1 +# con2 +PREPARE stmt FROM "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)"; +EXECUTE stmt;; +# default +INSERT INTO t2 VALUES (3);; +# con1 +SELECT RELEASE_LOCK('Bug#34306'); +RELEASE_LOCK('Bug#34306') +1 +# con2 +SELECT RELEASE_LOCK('Bug#34306'); +RELEASE_LOCK('Bug#34306') +1 +# default +# +# Ensure that INSERT INTO .. SELECT FROM prepared under SBR does +# not prevent the source table from being modified if under RBR. +# +# con2 +SET SESSION BINLOG_FORMAT = ROW; +# con1 +SELECT GET_LOCK('Bug#34306', 120); +GET_LOCK('Bug#34306', 120) +1 +# con2 +EXECUTE stmt;; +# default +# con1 +INSERT INTO t2 VALUES (4); +SELECT RELEASE_LOCK('Bug#34306'); +RELEASE_LOCK('Bug#34306') +1 +# con2 +# default +# Show binlog events +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1 +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT) +master-bin.000001 # Query # # use `test`; CREATE TABLE t2 LIKE t1 +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(1) +master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES(2) +master-bin.000001 # Query # # use `test`; INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120) +master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (3) +master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (4) +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; COMMIT +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/binlog/t/binlog_stm_row.test b/mysql-test/suite/binlog/t/binlog_stm_row.test new file mode 100644 index 00000000000..4944e65c9f3 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_stm_row.test @@ -0,0 +1,107 @@ +--source include/have_log_bin.inc +--source include/have_binlog_format_row_or_statement.inc + +# Get rid of previous tests binlog +--disable_query_log +reset master; +--enable_query_log + +# +# Bug#34306: Can't make copy of log tables when server binary log is enabled +# +# This is an additional test for Bug#34306 in order to ensure that INSERT INTO +# .. SELECT FROM is properly replicated under SBR and RBR and that the proper +# read lock type are acquired. +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +SET GLOBAL BINLOG_FORMAT = STATEMENT; +SET SESSION BINLOG_FORMAT = STATEMENT; + +CREATE TABLE t1 (a INT); +CREATE TABLE t2 LIKE t1; +select @@SESSION.BINLOG_FORMAT; +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(2); + +--connect(con1,localhost,root,,) +--connect(con2,localhost,root,,) + +--echo # +--echo # Ensure that INSERT INTO .. SELECT FROM under SBR takes a read +--echo # lock that will prevent the source table from being modified. +--echo # + +--connection con1 +--echo # con1 +SELECT GET_LOCK('Bug#34306', 120); +--connection con2 +--echo # con2 +PREPARE stmt FROM "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)"; +--send EXECUTE stmt; +--connection default +--echo # default +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE + state = "User lock" AND + info = "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)"; +--source include/wait_condition.inc +--send INSERT INTO t2 VALUES (3); +--connection con1 +--echo # con1 +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE + state = "Locked" and info = "INSERT INTO t2 VALUES (3)"; +--source include/wait_condition.inc +SELECT RELEASE_LOCK('Bug#34306'); +--connection con2 +--echo # con2 +--reap +SELECT RELEASE_LOCK('Bug#34306'); +--connection default +--echo # default +--reap + +--echo # +--echo # Ensure that INSERT INTO .. SELECT FROM prepared under SBR does +--echo # not prevent the source table from being modified if under RBR. +--echo # + +--connection con2 +--echo # con2 +SET SESSION BINLOG_FORMAT = ROW; +--connection con1 +--echo # con1 +SELECT GET_LOCK('Bug#34306', 120); +--connection con2 +--echo # con2 +--send EXECUTE stmt; +--connection default +--echo # default +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE + state = "User lock" AND + info = "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)"; +--source include/wait_condition.inc +--connection con1 +--echo # con1 +INSERT INTO t2 VALUES (4); +SELECT RELEASE_LOCK('Bug#34306'); +--connection con2 +--echo # con2 +--reap + +--disconnect con1 +--disconnect con2 +--connection default +--echo # default + +--echo # Show binlog events +source include/show_binlog_events.inc; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test index 8863ed825c2..103244eb2f7 100644 --- a/mysql-test/t/compare.test +++ b/mysql-test/t/compare.test @@ -76,4 +76,13 @@ FROM t2 ORDER BY a; DROP TABLE t1,t2; +# +# Bug #39353: Multiple conditions on timestamp column crashes server +# + +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NOW()),(NOW()),(NOW()); +SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00'; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/mysql-test/t/events_2.test b/mysql-test/t/events_2.test index 58a6fffe6f5..a50255e9f8b 100644 --- a/mysql-test/t/events_2.test +++ b/mysql-test/t/events_2.test @@ -411,6 +411,108 @@ create event очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66 on schedule every 2 year do select 1; +# +# Bug#35981: ALTER EVENT causes the server to change the PRESERVE option. +# + +create event event_35981 on schedule every 6 month on completion preserve +disable +do + select 1; + +echo The following SELECTs should all give 1; + +# show current ON_COMPLETION +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'PRESERVE'; + +# show ON_COMPLETION remains "PRESERVE" when not given in ALTER EVENT +alter event event_35981 enable; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'PRESERVE'; + +# show we can change ON_COMPLETION +alter event event_35981 on completion not preserve; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'NOT PRESERVE'; + +# show ON_COMPLETION remains "NOT PRESERVE" when not given in ALTER EVENT +alter event event_35981 disable; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'NOT PRESERVE'; + +# show we can change ON_COMPLETION +alter event event_35981 on completion preserve; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'PRESERVE'; + + +drop event event_35981; + +create event event_35981 on schedule every 6 month disable +do + select 1; + +# show that the defaults for CREATE EVENT are still correct (NOT PRESERVE) +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'NOT PRESERVE'; + +drop event event_35981; + + +# show that backdating doesn't break + +create event event_35981 on schedule every 1 hour starts current_timestamp + on completion not preserve +do + select 1; + +# should fail thanks to above's NOT PRESERVE +--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00'; + +drop event event_35981; + +create event event_35981 on schedule every 1 hour starts current_timestamp + on completion not preserve +do + select 1; + +# succeed with warning +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion preserve; + +drop event event_35981; + + + +create event event_35981 on schedule every 1 hour starts current_timestamp + on completion preserve +do + select 1; + +# this should succeed thanks to above PRESERVE! give a warning though. +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00'; + +# this should fail, as the event would have passed already +--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion not preserve; + +# should succeed giving a warning +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion preserve; + +drop event event_35981; + # # End of tests # diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 3047d16d3b6..34086336fa8 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -936,6 +936,52 @@ select command_type, argument from mysql.general_log where thread_id = @thread_i deallocate prepare long_query; set global general_log = @old_general_log_state; +# +# Bug#34306: Can't make copy of log tables when server binary log is enabled +# + +--disable_warnings +DROP TABLE IF EXISTS log_count; +DROP TABLE IF EXISTS slow_log_copy; +DROP TABLE IF EXISTS general_log_copy; +--enable_warnings + +CREATE TABLE log_count (count BIGINT(21)); + +SET @old_general_log_state = @@global.general_log; +SET @old_slow_log_state = @@global.slow_query_log; + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; + +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; + +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; + +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; + +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; + +SET GLOBAL general_log = @old_general_log_state; +SET GLOBAL slow_query_log = @old_slow_log_state; + +DROP TABLE log_count; + # # Bug #31700: thd->examined_row_count not incremented for 'const' type queries # diff --git a/mysql-test/t/mysqldump-max.test b/mysql-test/t/mysqldump-max.test index 359c4ea5793..1e8b9647503 100644 --- a/mysql-test/t/mysqldump-max.test +++ b/mysql-test/t/mysqldump-max.test @@ -66,3 +66,1061 @@ drop table t3; drop table t4; drop table t5; drop table t6; + + +# +# Bug#31434 - mysqldump dumps view as table +# + +# Show that mysqldump's stand-in tables for views are always of MyISAM +# type to avoid Inno's column-number limits (~1000 columns) etc. +# Here because it needs Inno-engine. + +SELECT @@global.storage_engine INTO @old_engine; +SET GLOBAL storage_engine=InnoDB; + +--disable_query_log +CREATE TABLE `t1` ( + `col_0` tinyint(1) default NULL, + `col_1` tinyint(1) default NULL, + `col_2` tinyint(1) default NULL, + `col_3` tinyint(1) default NULL, + `col_4` tinyint(1) default NULL, + `col_5` tinyint(1) default NULL, + `col_6` tinyint(1) default NULL, + `col_7` tinyint(1) default NULL, + `col_8` tinyint(1) default NULL, + `col_9` tinyint(1) default NULL, + `col_10` tinyint(1) default NULL, + `col_11` tinyint(1) default NULL, + `col_12` tinyint(1) default NULL, + `col_13` tinyint(1) default NULL, + `col_14` tinyint(1) default NULL, + `col_15` tinyint(1) default NULL, + `col_16` tinyint(1) default NULL, + `col_17` tinyint(1) default NULL, + `col_18` tinyint(1) default NULL, + `col_19` tinyint(1) default NULL, + `col_20` tinyint(1) default NULL, + `col_21` tinyint(1) default NULL, + `col_22` tinyint(1) default NULL, + `col_23` tinyint(1) default NULL, + `col_24` tinyint(1) default NULL, + `col_25` tinyint(1) default NULL, + `col_26` tinyint(1) default NULL, + `col_27` tinyint(1) default NULL, + `col_28` tinyint(1) default NULL, + `col_29` tinyint(1) default NULL, + `col_30` tinyint(1) default NULL, + `col_31` tinyint(1) default NULL, + `col_32` tinyint(1) default NULL, + `col_33` tinyint(1) default NULL, + `col_34` tinyint(1) default NULL, + `col_35` tinyint(1) default NULL, + `col_36` tinyint(1) default NULL, + `col_37` tinyint(1) default NULL, + `col_38` tinyint(1) default NULL, + `col_39` tinyint(1) default NULL, + `col_40` tinyint(1) default NULL, + `col_41` tinyint(1) default NULL, + `col_42` tinyint(1) default NULL, + `col_43` tinyint(1) default NULL, + `col_44` tinyint(1) default NULL, + `col_45` tinyint(1) default NULL, + `col_46` tinyint(1) default NULL, + `col_47` tinyint(1) default NULL, + `col_48` tinyint(1) default NULL, + `col_49` tinyint(1) default NULL, + `col_50` tinyint(1) default NULL, + `col_51` tinyint(1) default NULL, + `col_52` tinyint(1) default NULL, + `col_53` tinyint(1) default NULL, + `col_54` tinyint(1) default NULL, + `col_55` tinyint(1) default NULL, + `col_56` tinyint(1) default NULL, + `col_57` tinyint(1) default NULL, + `col_58` tinyint(1) default NULL, + `col_59` tinyint(1) default NULL, + `col_60` tinyint(1) default NULL, + `col_61` tinyint(1) default NULL, + `col_62` tinyint(1) default NULL, + `col_63` tinyint(1) default NULL, + `col_64` tinyint(1) default NULL, + `col_65` tinyint(1) default NULL, + `col_66` tinyint(1) default NULL, + `col_67` tinyint(1) default NULL, + `col_68` tinyint(1) default NULL, + `col_69` tinyint(1) default NULL, + `col_70` tinyint(1) default NULL, + `col_71` tinyint(1) default NULL, + `col_72` tinyint(1) default NULL, + `col_73` tinyint(1) default NULL, + `col_74` tinyint(1) default NULL, + `col_75` tinyint(1) default NULL, + `col_76` tinyint(1) default NULL, + `col_77` tinyint(1) default NULL, + `col_78` tinyint(1) default NULL, + `col_79` tinyint(1) default NULL, + `col_80` tinyint(1) default NULL, + `col_81` tinyint(1) default NULL, + `col_82` tinyint(1) default NULL, + `col_83` tinyint(1) default NULL, + `col_84` tinyint(1) default NULL, + `col_85` tinyint(1) default NULL, + `col_86` tinyint(1) default NULL, + `col_87` tinyint(1) default NULL, + `col_88` tinyint(1) default NULL, + `col_89` tinyint(1) default NULL, + `col_90` tinyint(1) default NULL, + `col_91` tinyint(1) default NULL, + `col_92` tinyint(1) default NULL, + `col_93` tinyint(1) default NULL, + `col_94` tinyint(1) default NULL, + `col_95` tinyint(1) default NULL, + `col_96` tinyint(1) default NULL, + `col_97` tinyint(1) default NULL, + `col_98` tinyint(1) default NULL, + `col_99` tinyint(1) default NULL, + `col_100` tinyint(1) default NULL, + `col_101` tinyint(1) default NULL, + `col_102` tinyint(1) default NULL, + `col_103` tinyint(1) default NULL, + `col_104` tinyint(1) default NULL, + `col_105` tinyint(1) default NULL, + `col_106` tinyint(1) default NULL, + `col_107` tinyint(1) default NULL, + `col_108` tinyint(1) default NULL, + `col_109` tinyint(1) default NULL, + `col_110` tinyint(1) default NULL, + `col_111` tinyint(1) default NULL, + `col_112` tinyint(1) default NULL, + `col_113` tinyint(1) default NULL, + `col_114` tinyint(1) default NULL, + `col_115` tinyint(1) default NULL, + `col_116` tinyint(1) default NULL, + `col_117` tinyint(1) default NULL, + `col_118` tinyint(1) default NULL, + `col_119` tinyint(1) default NULL, + `col_120` tinyint(1) default NULL, + `col_121` tinyint(1) default NULL, + `col_122` tinyint(1) default NULL, + `col_123` tinyint(1) default NULL, + `col_124` tinyint(1) default NULL, + `col_125` tinyint(1) default NULL, + `col_126` tinyint(1) default NULL, + `col_127` tinyint(1) default NULL, + `col_128` tinyint(1) default NULL, + `col_129` tinyint(1) default NULL, + `col_130` tinyint(1) default NULL, + `col_131` tinyint(1) default NULL, + `col_132` tinyint(1) default NULL, + `col_133` tinyint(1) default NULL, + `col_134` tinyint(1) default NULL, + `col_135` tinyint(1) default NULL, + `col_136` tinyint(1) default NULL, + `col_137` tinyint(1) default NULL, + `col_138` tinyint(1) default NULL, + `col_139` tinyint(1) default NULL, + `col_140` tinyint(1) default NULL, + `col_141` tinyint(1) default NULL, + `col_142` tinyint(1) default NULL, + `col_143` tinyint(1) default NULL, + `col_144` tinyint(1) default NULL, + `col_145` tinyint(1) default NULL, + `col_146` tinyint(1) default NULL, + `col_147` tinyint(1) default NULL, + `col_148` tinyint(1) default NULL, + `col_149` tinyint(1) default NULL, + `col_150` tinyint(1) default NULL, + `col_151` tinyint(1) default NULL, + `col_152` tinyint(1) default NULL, + `col_153` tinyint(1) default NULL, + `col_154` tinyint(1) default NULL, + `col_155` tinyint(1) default NULL, + `col_156` tinyint(1) default NULL, + `col_157` tinyint(1) default NULL, + `col_158` tinyint(1) default NULL, + `col_159` tinyint(1) default NULL, + `col_160` tinyint(1) default NULL, + `col_161` tinyint(1) default NULL, + `col_162` tinyint(1) default NULL, + `col_163` tinyint(1) default NULL, + `col_164` tinyint(1) default NULL, + `col_165` tinyint(1) default NULL, + `col_166` tinyint(1) default NULL, + `col_167` tinyint(1) default NULL, + `col_168` tinyint(1) default NULL, + `col_169` tinyint(1) default NULL, + `col_170` tinyint(1) default NULL, + `col_171` tinyint(1) default NULL, + `col_172` tinyint(1) default NULL, + `col_173` tinyint(1) default NULL, + `col_174` tinyint(1) default NULL, + `col_175` tinyint(1) default NULL, + `col_176` tinyint(1) default NULL, + `col_177` tinyint(1) default NULL, + `col_178` tinyint(1) default NULL, + `col_179` tinyint(1) default NULL, + `col_180` tinyint(1) default NULL, + `col_181` tinyint(1) default NULL, + `col_182` tinyint(1) default NULL, + `col_183` tinyint(1) default NULL, + `col_184` tinyint(1) default NULL, + `col_185` tinyint(1) default NULL, + `col_186` tinyint(1) default NULL, + `col_187` tinyint(1) default NULL, + `col_188` tinyint(1) default NULL, + `col_189` tinyint(1) default NULL, + `col_190` tinyint(1) default NULL, + `col_191` tinyint(1) default NULL, + `col_192` tinyint(1) default NULL, + `col_193` tinyint(1) default NULL, + `col_194` tinyint(1) default NULL, + `col_195` tinyint(1) default NULL, + `col_196` tinyint(1) default NULL, + `col_197` tinyint(1) default NULL, + `col_198` tinyint(1) default NULL, + `col_199` tinyint(1) default NULL, + `col_200` tinyint(1) default NULL, + `col_201` tinyint(1) default NULL, + `col_202` tinyint(1) default NULL, + `col_203` tinyint(1) default NULL, + `col_204` tinyint(1) default NULL, + `col_205` tinyint(1) default NULL, + `col_206` tinyint(1) default NULL, + `col_207` tinyint(1) default NULL, + `col_208` tinyint(1) default NULL, + `col_209` tinyint(1) default NULL, + `col_210` tinyint(1) default NULL, + `col_211` tinyint(1) default NULL, + `col_212` tinyint(1) default NULL, + `col_213` tinyint(1) default NULL, + `col_214` tinyint(1) default NULL, + `col_215` tinyint(1) default NULL, + `col_216` tinyint(1) default NULL, + `col_217` tinyint(1) default NULL, + `col_218` tinyint(1) default NULL, + `col_219` tinyint(1) default NULL, + `col_220` tinyint(1) default NULL, + `col_221` tinyint(1) default NULL, + `col_222` tinyint(1) default NULL, + `col_223` tinyint(1) default NULL, + `col_224` tinyint(1) default NULL, + `col_225` tinyint(1) default NULL, + `col_226` tinyint(1) default NULL, + `col_227` tinyint(1) default NULL, + `col_228` tinyint(1) default NULL, + `col_229` tinyint(1) default NULL, + `col_230` tinyint(1) default NULL, + `col_231` tinyint(1) default NULL, + `col_232` tinyint(1) default NULL, + `col_233` tinyint(1) default NULL, + `col_234` tinyint(1) default NULL, + `col_235` tinyint(1) default NULL, + `col_236` tinyint(1) default NULL, + `col_237` tinyint(1) default NULL, + `col_238` tinyint(1) default NULL, + `col_239` tinyint(1) default NULL, + `col_240` tinyint(1) default NULL, + `col_241` tinyint(1) default NULL, + `col_242` tinyint(1) default NULL, + `col_243` tinyint(1) default NULL, + `col_244` tinyint(1) default NULL, + `col_245` tinyint(1) default NULL, + `col_246` tinyint(1) default NULL, + `col_247` tinyint(1) default NULL, + `col_248` tinyint(1) default NULL, + `col_249` tinyint(1) default NULL, + `col_250` tinyint(1) default NULL, + `col_251` tinyint(1) default NULL, + `col_252` tinyint(1) default NULL, + `col_253` tinyint(1) default NULL, + `col_254` tinyint(1) default NULL, + `col_255` tinyint(1) default NULL, + `col_256` tinyint(1) default NULL, + `col_257` tinyint(1) default NULL, + `col_258` tinyint(1) default NULL, + `col_259` tinyint(1) default NULL, + `col_260` tinyint(1) default NULL, + `col_261` tinyint(1) default NULL, + `col_262` tinyint(1) default NULL, + `col_263` tinyint(1) default NULL, + `col_264` tinyint(1) default NULL, + `col_265` tinyint(1) default NULL, + `col_266` tinyint(1) default NULL, + `col_267` tinyint(1) default NULL, + `col_268` tinyint(1) default NULL, + `col_269` tinyint(1) default NULL, + `col_270` tinyint(1) default NULL, + `col_271` tinyint(1) default NULL, + `col_272` tinyint(1) default NULL, + `col_273` tinyint(1) default NULL, + `col_274` tinyint(1) default NULL, + `col_275` tinyint(1) default NULL, + `col_276` tinyint(1) default NULL, + `col_277` tinyint(1) default NULL, + `col_278` tinyint(1) default NULL, + `col_279` tinyint(1) default NULL, + `col_280` tinyint(1) default NULL, + `col_281` tinyint(1) default NULL, + `col_282` tinyint(1) default NULL, + `col_283` tinyint(1) default NULL, + `col_284` tinyint(1) default NULL, + `col_285` tinyint(1) default NULL, + `col_286` tinyint(1) default NULL, + `col_287` tinyint(1) default NULL, + `col_288` tinyint(1) default NULL, + `col_289` tinyint(1) default NULL, + `col_290` tinyint(1) default NULL, + `col_291` tinyint(1) default NULL, + `col_292` tinyint(1) default NULL, + `col_293` tinyint(1) default NULL, + `col_294` tinyint(1) default NULL, + `col_295` tinyint(1) default NULL, + `col_296` tinyint(1) default NULL, + `col_297` tinyint(1) default NULL, + `col_298` tinyint(1) default NULL, + `col_299` tinyint(1) default NULL, + `col_300` tinyint(1) default NULL, + `col_301` tinyint(1) default NULL, + `col_302` tinyint(1) default NULL, + `col_303` tinyint(1) default NULL, + `col_304` tinyint(1) default NULL, + `col_305` tinyint(1) default NULL, + `col_306` tinyint(1) default NULL, + `col_307` tinyint(1) default NULL, + `col_308` tinyint(1) default NULL, + `col_309` tinyint(1) default NULL, + `col_310` tinyint(1) default NULL, + `col_311` tinyint(1) default NULL, + `col_312` tinyint(1) default NULL, + `col_313` tinyint(1) default NULL, + `col_314` tinyint(1) default NULL, + `col_315` tinyint(1) default NULL, + `col_316` tinyint(1) default NULL, + `col_317` tinyint(1) default NULL, + `col_318` tinyint(1) default NULL, + `col_319` tinyint(1) default NULL, + `col_320` tinyint(1) default NULL, + `col_321` tinyint(1) default NULL, + `col_322` tinyint(1) default NULL, + `col_323` tinyint(1) default NULL, + `col_324` tinyint(1) default NULL, + `col_325` tinyint(1) default NULL, + `col_326` tinyint(1) default NULL, + `col_327` tinyint(1) default NULL, + `col_328` tinyint(1) default NULL, + `col_329` tinyint(1) default NULL, + `col_330` tinyint(1) default NULL, + `col_331` tinyint(1) default NULL, + `col_332` tinyint(1) default NULL, + `col_333` tinyint(1) default NULL, + `col_334` tinyint(1) default NULL, + `col_335` tinyint(1) default NULL, + `col_336` tinyint(1) default NULL, + `col_337` tinyint(1) default NULL, + `col_338` tinyint(1) default NULL, + `col_339` tinyint(1) default NULL, + `col_340` tinyint(1) default NULL, + `col_341` tinyint(1) default NULL, + `col_342` tinyint(1) default NULL, + `col_343` tinyint(1) default NULL, + `col_344` tinyint(1) default NULL, + `col_345` tinyint(1) default NULL, + `col_346` tinyint(1) default NULL, + `col_347` tinyint(1) default NULL, + `col_348` tinyint(1) default NULL, + `col_349` tinyint(1) default NULL, + `col_350` tinyint(1) default NULL, + `col_351` tinyint(1) default NULL, + `col_352` tinyint(1) default NULL, + `col_353` tinyint(1) default NULL, + `col_354` tinyint(1) default NULL, + `col_355` tinyint(1) default NULL, + `col_356` tinyint(1) default NULL, + `col_357` tinyint(1) default NULL, + `col_358` tinyint(1) default NULL, + `col_359` tinyint(1) default NULL, + `col_360` tinyint(1) default NULL, + `col_361` tinyint(1) default NULL, + `col_362` tinyint(1) default NULL, + `col_363` tinyint(1) default NULL, + `col_364` tinyint(1) default NULL, + `col_365` tinyint(1) default NULL, + `col_366` tinyint(1) default NULL, + `col_367` tinyint(1) default NULL, + `col_368` tinyint(1) default NULL, + `col_369` tinyint(1) default NULL, + `col_370` tinyint(1) default NULL, + `col_371` tinyint(1) default NULL, + `col_372` tinyint(1) default NULL, + `col_373` tinyint(1) default NULL, + `col_374` tinyint(1) default NULL, + `col_375` tinyint(1) default NULL, + `col_376` tinyint(1) default NULL, + `col_377` tinyint(1) default NULL, + `col_378` tinyint(1) default NULL, + `col_379` tinyint(1) default NULL, + `col_380` tinyint(1) default NULL, + `col_381` tinyint(1) default NULL, + `col_382` tinyint(1) default NULL, + `col_383` tinyint(1) default NULL, + `col_384` tinyint(1) default NULL, + `col_385` tinyint(1) default NULL, + `col_386` tinyint(1) default NULL, + `col_387` tinyint(1) default NULL, + `col_388` tinyint(1) default NULL, + `col_389` tinyint(1) default NULL, + `col_390` tinyint(1) default NULL, + `col_391` tinyint(1) default NULL, + `col_392` tinyint(1) default NULL, + `col_393` tinyint(1) default NULL, + `col_394` tinyint(1) default NULL, + `col_395` tinyint(1) default NULL, + `col_396` tinyint(1) default NULL, + `col_397` tinyint(1) default NULL, + `col_398` tinyint(1) default NULL, + `col_399` tinyint(1) default NULL, + `col_400` tinyint(1) default NULL, + `col_401` tinyint(1) default NULL, + `col_402` tinyint(1) default NULL, + `col_403` tinyint(1) default NULL, + `col_404` tinyint(1) default NULL, + `col_405` tinyint(1) default NULL, + `col_406` tinyint(1) default NULL, + `col_407` tinyint(1) default NULL, + `col_408` tinyint(1) default NULL, + `col_409` tinyint(1) default NULL, + `col_410` tinyint(1) default NULL, + `col_411` tinyint(1) default NULL, + `col_412` tinyint(1) default NULL, + `col_413` tinyint(1) default NULL, + `col_414` tinyint(1) default NULL, + `col_415` tinyint(1) default NULL, + `col_416` tinyint(1) default NULL, + `col_417` tinyint(1) default NULL, + `col_418` tinyint(1) default NULL, + `col_419` tinyint(1) default NULL, + `col_420` tinyint(1) default NULL, + `col_421` tinyint(1) default NULL, + `col_422` tinyint(1) default NULL, + `col_423` tinyint(1) default NULL, + `col_424` tinyint(1) default NULL, + `col_425` tinyint(1) default NULL, + `col_426` tinyint(1) default NULL, + `col_427` tinyint(1) default NULL, + `col_428` tinyint(1) default NULL, + `col_429` tinyint(1) default NULL, + `col_430` tinyint(1) default NULL, + `col_431` tinyint(1) default NULL, + `col_432` tinyint(1) default NULL, + `col_433` tinyint(1) default NULL, + `col_434` tinyint(1) default NULL, + `col_435` tinyint(1) default NULL, + `col_436` tinyint(1) default NULL, + `col_437` tinyint(1) default NULL, + `col_438` tinyint(1) default NULL, + `col_439` tinyint(1) default NULL, + `col_440` tinyint(1) default NULL, + `col_441` tinyint(1) default NULL, + `col_442` tinyint(1) default NULL, + `col_443` tinyint(1) default NULL, + `col_444` tinyint(1) default NULL, + `col_445` tinyint(1) default NULL, + `col_446` tinyint(1) default NULL, + `col_447` tinyint(1) default NULL, + `col_448` tinyint(1) default NULL, + `col_449` tinyint(1) default NULL, + `col_450` tinyint(1) default NULL, + `col_451` tinyint(1) default NULL, + `col_452` tinyint(1) default NULL, + `col_453` tinyint(1) default NULL, + `col_454` tinyint(1) default NULL, + `col_455` tinyint(1) default NULL, + `col_456` tinyint(1) default NULL, + `col_457` tinyint(1) default NULL, + `col_458` tinyint(1) default NULL, + `col_459` tinyint(1) default NULL, + `col_460` tinyint(1) default NULL, + `col_461` tinyint(1) default NULL, + `col_462` tinyint(1) default NULL, + `col_463` tinyint(1) default NULL, + `col_464` tinyint(1) default NULL, + `col_465` tinyint(1) default NULL, + `col_466` tinyint(1) default NULL, + `col_467` tinyint(1) default NULL, + `col_468` tinyint(1) default NULL, + `col_469` tinyint(1) default NULL, + `col_470` tinyint(1) default NULL, + `col_471` tinyint(1) default NULL, + `col_472` tinyint(1) default NULL, + `col_473` tinyint(1) default NULL, + `col_474` tinyint(1) default NULL, + `col_475` tinyint(1) default NULL, + `col_476` tinyint(1) default NULL, + `col_477` tinyint(1) default NULL, + `col_478` tinyint(1) default NULL, + `col_479` tinyint(1) default NULL, + `col_480` tinyint(1) default NULL, + `col_481` tinyint(1) default NULL, + `col_482` tinyint(1) default NULL, + `col_483` tinyint(1) default NULL, + `col_484` tinyint(1) default NULL, + `col_485` tinyint(1) default NULL, + `col_486` tinyint(1) default NULL, + `col_487` tinyint(1) default NULL, + `col_488` tinyint(1) default NULL, + `col_489` tinyint(1) default NULL, + `col_490` tinyint(1) default NULL, + `col_491` tinyint(1) default NULL, + `col_492` tinyint(1) default NULL, + `col_493` tinyint(1) default NULL, + `col_494` tinyint(1) default NULL, + `col_495` tinyint(1) default NULL, + `col_496` tinyint(1) default NULL, + `col_497` tinyint(1) default NULL, + `col_498` tinyint(1) default NULL, + `col_499` tinyint(1) default NULL, + `col_500` tinyint(1) default NULL, + `col_501` tinyint(1) default NULL, + `col_502` tinyint(1) default NULL, + `col_503` tinyint(1) default NULL, + `col_504` tinyint(1) default NULL, + `col_505` tinyint(1) default NULL, + `col_506` tinyint(1) default NULL, + `col_507` tinyint(1) default NULL, + `col_508` tinyint(1) default NULL, + `col_509` tinyint(1) default NULL, + `col_510` tinyint(1) default NULL, + `col_511` tinyint(1) default NULL, + `col_512` tinyint(1) default NULL, + `col_513` tinyint(1) default NULL, + `col_514` tinyint(1) default NULL, + `col_515` tinyint(1) default NULL, + `col_516` tinyint(1) default NULL, + `col_517` tinyint(1) default NULL, + `col_518` tinyint(1) default NULL, + `col_519` tinyint(1) default NULL, + `col_520` tinyint(1) default NULL, + `col_521` tinyint(1) default NULL, + `col_522` tinyint(1) default NULL, + `col_523` tinyint(1) default NULL, + `col_524` tinyint(1) default NULL, + `col_525` tinyint(1) default NULL, + `col_526` tinyint(1) default NULL, + `col_527` tinyint(1) default NULL, + `col_528` tinyint(1) default NULL, + `col_529` tinyint(1) default NULL, + `col_530` tinyint(1) default NULL, + `col_531` tinyint(1) default NULL, + `col_532` tinyint(1) default NULL, + `col_533` tinyint(1) default NULL, + `col_534` tinyint(1) default NULL, + `col_535` tinyint(1) default NULL, + `col_536` tinyint(1) default NULL, + `col_537` tinyint(1) default NULL, + `col_538` tinyint(1) default NULL, + `col_539` tinyint(1) default NULL, + `col_540` tinyint(1) default NULL, + `col_541` tinyint(1) default NULL, + `col_542` tinyint(1) default NULL, + `col_543` tinyint(1) default NULL, + `col_544` tinyint(1) default NULL, + `col_545` tinyint(1) default NULL, + `col_546` tinyint(1) default NULL, + `col_547` tinyint(1) default NULL, + `col_548` tinyint(1) default NULL, + `col_549` tinyint(1) default NULL, + `col_550` tinyint(1) default NULL, + `col_551` tinyint(1) default NULL, + `col_552` tinyint(1) default NULL, + `col_553` tinyint(1) default NULL, + `col_554` tinyint(1) default NULL, + `col_555` tinyint(1) default NULL, + `col_556` tinyint(1) default NULL, + `col_557` tinyint(1) default NULL, + `col_558` tinyint(1) default NULL, + `col_559` tinyint(1) default NULL, + `col_560` tinyint(1) default NULL, + `col_561` tinyint(1) default NULL, + `col_562` tinyint(1) default NULL, + `col_563` tinyint(1) default NULL, + `col_564` tinyint(1) default NULL, + `col_565` tinyint(1) default NULL, + `col_566` tinyint(1) default NULL, + `col_567` tinyint(1) default NULL, + `col_568` tinyint(1) default NULL, + `col_569` tinyint(1) default NULL, + `col_570` tinyint(1) default NULL, + `col_571` tinyint(1) default NULL, + `col_572` tinyint(1) default NULL, + `col_573` tinyint(1) default NULL, + `col_574` tinyint(1) default NULL, + `col_575` tinyint(1) default NULL, + `col_576` tinyint(1) default NULL, + `col_577` tinyint(1) default NULL, + `col_578` tinyint(1) default NULL, + `col_579` tinyint(1) default NULL, + `col_580` tinyint(1) default NULL, + `col_581` tinyint(1) default NULL, + `col_582` tinyint(1) default NULL, + `col_583` tinyint(1) default NULL, + `col_584` tinyint(1) default NULL, + `col_585` tinyint(1) default NULL, + `col_586` tinyint(1) default NULL, + `col_587` tinyint(1) default NULL, + `col_588` tinyint(1) default NULL, + `col_589` tinyint(1) default NULL, + `col_590` tinyint(1) default NULL, + `col_591` tinyint(1) default NULL, + `col_592` tinyint(1) default NULL, + `col_593` tinyint(1) default NULL, + `col_594` tinyint(1) default NULL, + `col_595` tinyint(1) default NULL, + `col_596` tinyint(1) default NULL, + `col_597` tinyint(1) default NULL, + `col_598` tinyint(1) default NULL, + `col_599` tinyint(1) default NULL, + `col_600` tinyint(1) default NULL, + `col_601` tinyint(1) default NULL, + `col_602` tinyint(1) default NULL, + `col_603` tinyint(1) default NULL, + `col_604` tinyint(1) default NULL, + `col_605` tinyint(1) default NULL, + `col_606` tinyint(1) default NULL, + `col_607` tinyint(1) default NULL, + `col_608` tinyint(1) default NULL, + `col_609` tinyint(1) default NULL, + `col_610` tinyint(1) default NULL, + `col_611` tinyint(1) default NULL, + `col_612` tinyint(1) default NULL, + `col_613` tinyint(1) default NULL, + `col_614` tinyint(1) default NULL, + `col_615` tinyint(1) default NULL, + `col_616` tinyint(1) default NULL, + `col_617` tinyint(1) default NULL, + `col_618` tinyint(1) default NULL, + `col_619` tinyint(1) default NULL, + `col_620` tinyint(1) default NULL, + `col_621` tinyint(1) default NULL, + `col_622` tinyint(1) default NULL, + `col_623` tinyint(1) default NULL, + `col_624` tinyint(1) default NULL, + `col_625` tinyint(1) default NULL, + `col_626` tinyint(1) default NULL, + `col_627` tinyint(1) default NULL, + `col_628` tinyint(1) default NULL, + `col_629` tinyint(1) default NULL, + `col_630` tinyint(1) default NULL, + `col_631` tinyint(1) default NULL, + `col_632` tinyint(1) default NULL, + `col_633` tinyint(1) default NULL, + `col_634` tinyint(1) default NULL, + `col_635` tinyint(1) default NULL, + `col_636` tinyint(1) default NULL, + `col_637` tinyint(1) default NULL, + `col_638` tinyint(1) default NULL, + `col_639` tinyint(1) default NULL, + `col_640` tinyint(1) default NULL, + `col_641` tinyint(1) default NULL, + `col_642` tinyint(1) default NULL, + `col_643` tinyint(1) default NULL, + `col_644` tinyint(1) default NULL, + `col_645` tinyint(1) default NULL, + `col_646` tinyint(1) default NULL, + `col_647` tinyint(1) default NULL, + `col_648` tinyint(1) default NULL, + `col_649` tinyint(1) default NULL, + `col_650` tinyint(1) default NULL, + `col_651` tinyint(1) default NULL, + `col_652` tinyint(1) default NULL, + `col_653` tinyint(1) default NULL, + `col_654` tinyint(1) default NULL, + `col_655` tinyint(1) default NULL, + `col_656` tinyint(1) default NULL, + `col_657` tinyint(1) default NULL, + `col_658` tinyint(1) default NULL, + `col_659` tinyint(1) default NULL, + `col_660` tinyint(1) default NULL, + `col_661` tinyint(1) default NULL, + `col_662` tinyint(1) default NULL, + `col_663` tinyint(1) default NULL, + `col_664` tinyint(1) default NULL, + `col_665` tinyint(1) default NULL, + `col_666` tinyint(1) default NULL, + `col_667` tinyint(1) default NULL, + `col_668` tinyint(1) default NULL, + `col_669` tinyint(1) default NULL, + `col_670` tinyint(1) default NULL, + `col_671` tinyint(1) default NULL, + `col_672` tinyint(1) default NULL, + `col_673` tinyint(1) default NULL, + `col_674` tinyint(1) default NULL, + `col_675` tinyint(1) default NULL, + `col_676` tinyint(1) default NULL, + `col_677` tinyint(1) default NULL, + `col_678` tinyint(1) default NULL, + `col_679` tinyint(1) default NULL, + `col_680` tinyint(1) default NULL, + `col_681` tinyint(1) default NULL, + `col_682` tinyint(1) default NULL, + `col_683` tinyint(1) default NULL, + `col_684` tinyint(1) default NULL, + `col_685` tinyint(1) default NULL, + `col_686` tinyint(1) default NULL, + `col_687` tinyint(1) default NULL, + `col_688` tinyint(1) default NULL, + `col_689` tinyint(1) default NULL, + `col_690` tinyint(1) default NULL, + `col_691` tinyint(1) default NULL, + `col_692` tinyint(1) default NULL, + `col_693` tinyint(1) default NULL, + `col_694` tinyint(1) default NULL, + `col_695` tinyint(1) default NULL, + `col_696` tinyint(1) default NULL, + `col_697` tinyint(1) default NULL, + `col_698` tinyint(1) default NULL, + `col_699` tinyint(1) default NULL, + `col_700` tinyint(1) default NULL, + `col_701` tinyint(1) default NULL, + `col_702` tinyint(1) default NULL, + `col_703` tinyint(1) default NULL, + `col_704` tinyint(1) default NULL, + `col_705` tinyint(1) default NULL, + `col_706` tinyint(1) default NULL, + `col_707` tinyint(1) default NULL, + `col_708` tinyint(1) default NULL, + `col_709` tinyint(1) default NULL, + `col_710` tinyint(1) default NULL, + `col_711` tinyint(1) default NULL, + `col_712` tinyint(1) default NULL, + `col_713` tinyint(1) default NULL, + `col_714` tinyint(1) default NULL, + `col_715` tinyint(1) default NULL, + `col_716` tinyint(1) default NULL, + `col_717` tinyint(1) default NULL, + `col_718` tinyint(1) default NULL, + `col_719` tinyint(1) default NULL, + `col_720` tinyint(1) default NULL, + `col_721` tinyint(1) default NULL, + `col_722` tinyint(1) default NULL, + `col_723` tinyint(1) default NULL, + `col_724` tinyint(1) default NULL, + `col_725` tinyint(1) default NULL, + `col_726` tinyint(1) default NULL, + `col_727` tinyint(1) default NULL, + `col_728` tinyint(1) default NULL, + `col_729` tinyint(1) default NULL, + `col_730` tinyint(1) default NULL, + `col_731` tinyint(1) default NULL, + `col_732` tinyint(1) default NULL, + `col_733` tinyint(1) default NULL, + `col_734` tinyint(1) default NULL, + `col_735` tinyint(1) default NULL, + `col_736` tinyint(1) default NULL, + `col_737` tinyint(1) default NULL, + `col_738` tinyint(1) default NULL, + `col_739` tinyint(1) default NULL, + `col_740` tinyint(1) default NULL, + `col_741` tinyint(1) default NULL, + `col_742` tinyint(1) default NULL, + `col_743` tinyint(1) default NULL, + `col_744` tinyint(1) default NULL, + `col_745` tinyint(1) default NULL, + `col_746` tinyint(1) default NULL, + `col_747` tinyint(1) default NULL, + `col_748` tinyint(1) default NULL, + `col_749` tinyint(1) default NULL, + `col_750` tinyint(1) default NULL, + `col_751` tinyint(1) default NULL, + `col_752` tinyint(1) default NULL, + `col_753` tinyint(1) default NULL, + `col_754` tinyint(1) default NULL, + `col_755` tinyint(1) default NULL, + `col_756` tinyint(1) default NULL, + `col_757` tinyint(1) default NULL, + `col_758` tinyint(1) default NULL, + `col_759` tinyint(1) default NULL, + `col_760` tinyint(1) default NULL, + `col_761` tinyint(1) default NULL, + `col_762` tinyint(1) default NULL, + `col_763` tinyint(1) default NULL, + `col_764` tinyint(1) default NULL, + `col_765` tinyint(1) default NULL, + `col_766` tinyint(1) default NULL, + `col_767` tinyint(1) default NULL, + `col_768` tinyint(1) default NULL, + `col_769` tinyint(1) default NULL, + `col_770` tinyint(1) default NULL, + `col_771` tinyint(1) default NULL, + `col_772` tinyint(1) default NULL, + `col_773` tinyint(1) default NULL, + `col_774` tinyint(1) default NULL, + `col_775` tinyint(1) default NULL, + `col_776` tinyint(1) default NULL, + `col_777` tinyint(1) default NULL, + `col_778` tinyint(1) default NULL, + `col_779` tinyint(1) default NULL, + `col_780` tinyint(1) default NULL, + `col_781` tinyint(1) default NULL, + `col_782` tinyint(1) default NULL, + `col_783` tinyint(1) default NULL, + `col_784` tinyint(1) default NULL, + `col_785` tinyint(1) default NULL, + `col_786` tinyint(1) default NULL, + `col_787` tinyint(1) default NULL, + `col_788` tinyint(1) default NULL, + `col_789` tinyint(1) default NULL, + `col_790` tinyint(1) default NULL, + `col_791` tinyint(1) default NULL, + `col_792` tinyint(1) default NULL, + `col_793` tinyint(1) default NULL, + `col_794` tinyint(1) default NULL, + `col_795` tinyint(1) default NULL, + `col_796` tinyint(1) default NULL, + `col_797` tinyint(1) default NULL, + `col_798` tinyint(1) default NULL, + `col_799` tinyint(1) default NULL, + `col_800` tinyint(1) default NULL, + `col_801` tinyint(1) default NULL, + `col_802` tinyint(1) default NULL, + `col_803` tinyint(1) default NULL, + `col_804` tinyint(1) default NULL, + `col_805` tinyint(1) default NULL, + `col_806` tinyint(1) default NULL, + `col_807` tinyint(1) default NULL, + `col_808` tinyint(1) default NULL, + `col_809` tinyint(1) default NULL, + `col_810` tinyint(1) default NULL, + `col_811` tinyint(1) default NULL, + `col_812` tinyint(1) default NULL, + `col_813` tinyint(1) default NULL, + `col_814` tinyint(1) default NULL, + `col_815` tinyint(1) default NULL, + `col_816` tinyint(1) default NULL, + `col_817` tinyint(1) default NULL, + `col_818` tinyint(1) default NULL, + `col_819` tinyint(1) default NULL, + `col_820` tinyint(1) default NULL, + `col_821` tinyint(1) default NULL, + `col_822` tinyint(1) default NULL, + `col_823` tinyint(1) default NULL, + `col_824` tinyint(1) default NULL, + `col_825` tinyint(1) default NULL, + `col_826` tinyint(1) default NULL, + `col_827` tinyint(1) default NULL, + `col_828` tinyint(1) default NULL, + `col_829` tinyint(1) default NULL, + `col_830` tinyint(1) default NULL, + `col_831` tinyint(1) default NULL, + `col_832` tinyint(1) default NULL, + `col_833` tinyint(1) default NULL, + `col_834` tinyint(1) default NULL, + `col_835` tinyint(1) default NULL, + `col_836` tinyint(1) default NULL, + `col_837` tinyint(1) default NULL, + `col_838` tinyint(1) default NULL, + `col_839` tinyint(1) default NULL, + `col_840` tinyint(1) default NULL, + `col_841` tinyint(1) default NULL, + `col_842` tinyint(1) default NULL, + `col_843` tinyint(1) default NULL, + `col_844` tinyint(1) default NULL, + `col_845` tinyint(1) default NULL, + `col_846` tinyint(1) default NULL, + `col_847` tinyint(1) default NULL, + `col_848` tinyint(1) default NULL, + `col_849` tinyint(1) default NULL, + `col_850` tinyint(1) default NULL, + `col_851` tinyint(1) default NULL, + `col_852` tinyint(1) default NULL, + `col_853` tinyint(1) default NULL, + `col_854` tinyint(1) default NULL, + `col_855` tinyint(1) default NULL, + `col_856` tinyint(1) default NULL, + `col_857` tinyint(1) default NULL, + `col_858` tinyint(1) default NULL, + `col_859` tinyint(1) default NULL, + `col_860` tinyint(1) default NULL, + `col_861` tinyint(1) default NULL, + `col_862` tinyint(1) default NULL, + `col_863` tinyint(1) default NULL, + `col_864` tinyint(1) default NULL, + `col_865` tinyint(1) default NULL, + `col_866` tinyint(1) default NULL, + `col_867` tinyint(1) default NULL, + `col_868` tinyint(1) default NULL, + `col_869` tinyint(1) default NULL, + `col_870` tinyint(1) default NULL, + `col_871` tinyint(1) default NULL, + `col_872` tinyint(1) default NULL, + `col_873` tinyint(1) default NULL, + `col_874` tinyint(1) default NULL, + `col_875` tinyint(1) default NULL, + `col_876` tinyint(1) default NULL, + `col_877` tinyint(1) default NULL, + `col_878` tinyint(1) default NULL, + `col_879` tinyint(1) default NULL, + `col_880` tinyint(1) default NULL, + `col_881` tinyint(1) default NULL, + `col_882` tinyint(1) default NULL, + `col_883` tinyint(1) default NULL, + `col_884` tinyint(1) default NULL, + `col_885` tinyint(1) default NULL, + `col_886` tinyint(1) default NULL, + `col_887` tinyint(1) default NULL, + `col_888` tinyint(1) default NULL, + `col_889` tinyint(1) default NULL, + `col_890` tinyint(1) default NULL, + `col_891` tinyint(1) default NULL, + `col_892` tinyint(1) default NULL, + `col_893` tinyint(1) default NULL, + `col_894` tinyint(1) default NULL, + `col_895` tinyint(1) default NULL, + `col_896` tinyint(1) default NULL, + `col_897` tinyint(1) default NULL, + `col_898` tinyint(1) default NULL, + `col_899` tinyint(1) default NULL, + `col_900` tinyint(1) default NULL, + `col_901` tinyint(1) default NULL, + `col_902` tinyint(1) default NULL, + `col_903` tinyint(1) default NULL, + `col_904` tinyint(1) default NULL, + `col_905` tinyint(1) default NULL, + `col_906` tinyint(1) default NULL, + `col_907` tinyint(1) default NULL, + `col_908` tinyint(1) default NULL, + `col_909` tinyint(1) default NULL, + `col_910` tinyint(1) default NULL, + `col_911` tinyint(1) default NULL, + `col_912` tinyint(1) default NULL, + `col_913` tinyint(1) default NULL, + `col_914` tinyint(1) default NULL, + `col_915` tinyint(1) default NULL, + `col_916` tinyint(1) default NULL, + `col_917` tinyint(1) default NULL, + `col_918` tinyint(1) default NULL, + `col_919` tinyint(1) default NULL, + `col_920` tinyint(1) default NULL, + `col_921` tinyint(1) default NULL, + `col_922` tinyint(1) default NULL, + `col_923` tinyint(1) default NULL, + `col_924` tinyint(1) default NULL, + `col_925` tinyint(1) default NULL, + `col_926` tinyint(1) default NULL, + `col_927` tinyint(1) default NULL, + `col_928` tinyint(1) default NULL, + `col_929` tinyint(1) default NULL, + `col_930` tinyint(1) default NULL, + `col_931` tinyint(1) default NULL, + `col_932` tinyint(1) default NULL, + `col_933` tinyint(1) default NULL, + `col_934` tinyint(1) default NULL, + `col_935` tinyint(1) default NULL, + `col_936` tinyint(1) default NULL, + `col_937` tinyint(1) default NULL, + `col_938` tinyint(1) default NULL, + `col_939` tinyint(1) default NULL, + `col_940` tinyint(1) default NULL, + `col_941` tinyint(1) default NULL, + `col_942` tinyint(1) default NULL, + `col_943` tinyint(1) default NULL, + `col_944` tinyint(1) default NULL, + `col_945` tinyint(1) default NULL, + `col_946` tinyint(1) default NULL, + `col_947` tinyint(1) default NULL, + `col_948` tinyint(1) default NULL, + `col_949` tinyint(1) default NULL, + `col_950` tinyint(1) default NULL, + `col_951` tinyint(1) default NULL, + `col_952` tinyint(1) default NULL, + `col_953` tinyint(1) default NULL, + `col_954` tinyint(1) default NULL, + `col_955` tinyint(1) default NULL, + `col_956` tinyint(1) default NULL, + `col_957` tinyint(1) default NULL, + `col_958` tinyint(1) default NULL, + `col_959` tinyint(1) default NULL, + `col_960` tinyint(1) default NULL, + `col_961` tinyint(1) default NULL, + `col_962` tinyint(1) default NULL, + `col_963` tinyint(1) default NULL, + `col_964` tinyint(1) default NULL, + `col_965` tinyint(1) default NULL, + `col_966` tinyint(1) default NULL, + `col_967` tinyint(1) default NULL, + `col_968` tinyint(1) default NULL, + `col_969` tinyint(1) default NULL, + `col_970` tinyint(1) default NULL, + `col_971` tinyint(1) default NULL, + `col_972` tinyint(1) default NULL, + `col_973` tinyint(1) default NULL, + `col_974` tinyint(1) default NULL, + `col_975` tinyint(1) default NULL, + `col_976` tinyint(1) default NULL, + `col_977` tinyint(1) default NULL, + `col_978` tinyint(1) default NULL, + `col_979` tinyint(1) default NULL, + `col_980` tinyint(1) default NULL, + `col_981` tinyint(1) default NULL, + `col_982` tinyint(1) default NULL, + `col_983` tinyint(1) default NULL, + `col_984` tinyint(1) default NULL, + `col_985` tinyint(1) default NULL, + `col_986` tinyint(1) default NULL, + `col_987` tinyint(1) default NULL, + `col_988` tinyint(1) default NULL, + `col_989` tinyint(1) default NULL, + `col_990` tinyint(1) default NULL, + `col_991` tinyint(1) default NULL, + `col_992` tinyint(1) default NULL, + `col_993` tinyint(1) default NULL, + `col_994` tinyint(1) default NULL, + `col_995` tinyint(1) default NULL, + `col_996` tinyint(1) default NULL, + `col_997` tinyint(1) default NULL, + `col_998` tinyint(1) default NULL, + `col_999` tinyint(1) default NULL, + `col_1000` tinyint(1) default NULL, + `col_1001` tinyint(1) default NULL, + `col_1002` tinyint(1) default NULL, + `col_1003` tinyint(1) default NULL, + `col_1004` tinyint(1) default NULL, + `col_1005` tinyint(1) default NULL, + `col_1006` tinyint(1) default NULL, + `col_1007` tinyint(1) default NULL, + `col_1008` tinyint(1) default NULL, + `col_1009` tinyint(1) default NULL, + `col_1010` tinyint(1) default NULL, + `col_1011` tinyint(1) default NULL, + `col_1012` tinyint(1) default NULL, + `col_1013` tinyint(1) default NULL, + `col_1014` tinyint(1) default NULL, + `col_1015` tinyint(1) default NULL, + `col_1016` tinyint(1) default NULL, + `col_1017` tinyint(1) default NULL, + `col_1018` tinyint(1) default NULL, + `col_1019` tinyint(1) default NULL, + `col_1020` tinyint(1) default NULL, + `col_1021` tinyint(1) default NULL, + `col_1022` tinyint(1) default NULL, + `col_1023` tinyint(1) default NULL, + `col_1024` tinyint(1) default NULL, + `col_1025` tinyint(1) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +--enable_query_log +CREATE VIEW v1 AS SELECT * FROM t1; + +INSERT INTO t1 VALUES(); +SELECT COUNT(*) FROM v1; + +--exec $MYSQL_DUMP --allow-keywords --single-transaction --quick --verbose test --result-file $MYSQLTEST_VARDIR/tmp/bug31434.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug31434.sql +--remove_file $MYSQLTEST_VARDIR/tmp/bug31434.sql + +SELECT COUNT(*) FROM v1; + +DROP VIEW v1; +DROP TABLE t1; + +SET GLOBAL storage_engine=@old_engine; diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test index bc4231d1d71..c02d9049f2e 100644 --- a/mysql-test/t/partition_range.test +++ b/mysql-test/t/partition_range.test @@ -807,24 +807,24 @@ DROP TABLE t1; # # BUG#30573: get wrong result with "group by" on PARTITIONed table # -#create table t1 (a int); -#insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -#CREATE TABLE t2 ( -# defid int(10) unsigned NOT NULL, -# day int(10) unsigned NOT NULL, -# count int(10) unsigned NOT NULL, -# filler char(200), -# KEY (defid,day) -#) -#PARTITION BY RANGE (day) ( -# PARTITION p7 VALUES LESS THAN (20070401) , -# PARTITION p8 VALUES LESS THAN (20070501)); +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( + defid int(10) unsigned NOT NULL, + day int(10) unsigned NOT NULL, + count int(10) unsigned NOT NULL, + filler char(200), + KEY (defid,day) +) +PARTITION BY RANGE (day) ( + PARTITION p7 VALUES LESS THAN (20070401) , + PARTITION p8 VALUES LESS THAN (20070501)); -#insert into t2 select 20, 20070311, 1, 'filler' from t1 A, t1 B; -#insert into t2 select 20, 20070411, 1, 'filler' from t1 A, t1 B; -#insert into t2 values(52, 20070321, 123, 'filler') ; -#insert into t2 values(52, 20070322, 456, 'filler') ; +insert into t2 select 20, 20070311, 1, 'filler' from t1 A, t1 B; +insert into t2 select 20, 20070411, 1, 'filler' from t1 A, t1 B; +insert into t2 values(52, 20070321, 123, 'filler') ; +insert into t2 values(52, 20070322, 456, 'filler') ; -#select sum(count) from t2 ch where ch.defid in (50,52) and ch.day between 20070320 and 20070401 group by defid; -#drop table t1, t2; +select sum(count) from t2 ch where ch.defid in (50,52) and ch.day between 20070320 and 20070401 group by defid; +drop table t1, t2; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index f2699ab03d3..5d916e410e3 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -263,4 +263,26 @@ from t1 order by score desc; --enable_result_log drop table t1; +# +# Bug#26020: User-Defined Variables are not consistent with columns data types +# + +create table t1(b bigint); +insert into t1 (b) values (10), (30), (10); +set @var := 0; +select if(b=@var, 999, b) , @var := b from t1 order by b; +drop table t1; + +create temporary table t1 (id int); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +drop table t1; + +create temporary table t1 (id bigint); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +drop table t1; + --echo End of 5.1 tests diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 382fd024aa8..68de5962e46 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -185,6 +185,8 @@ mysql_event_fill_row(THD *thd, DBUG_PRINT("info", ("dbname=[%s]", et->dbname.str)); DBUG_PRINT("info", ("name =[%s]", et->name.str)); + DBUG_ASSERT(et->on_completion != Event_parse_data::ON_COMPLETION_DEFAULT); + if (table->s->fields < ET_FIELD_COUNT) { /* @@ -745,6 +747,18 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data, store_record(table,record[1]); + /* + We check whether ALTER EVENT was given dates that are in the past. + However to know how to react, we need the ON COMPLETION type. The + check is deferred to this point because by now we have the previous + setting (from the event-table) to fall back on if nothing was specified + in the ALTER EVENT-statement. + */ + + if (parse_data->check_dates(thd, + table->field[ET_FIELD_ON_COMPLETION]->val_int())) + goto end; + /* Don't update create on row update. */ table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc index e87e4593f8f..df419e92d0d 100644 --- a/sql/event_parse_data.cc +++ b/sql/event_parse_data.cc @@ -45,7 +45,7 @@ Event_parse_data::new_instance(THD *thd) */ Event_parse_data::Event_parse_data() - :on_completion(Event_parse_data::ON_COMPLETION_DROP), + :on_completion(Event_parse_data::ON_COMPLETION_DEFAULT), status(Event_parse_data::ENABLED), do_not_create(FALSE), body_changed(FALSE), @@ -114,6 +114,12 @@ Event_parse_data::check_if_in_the_past(THD *thd, my_time_t ltime_utc) if (ltime_utc >= (my_time_t) thd->query_start()) return; + /* + We'll come back later when we have the real on_completion value + */ + if (on_completion == Event_parse_data::ON_COMPLETION_DEFAULT) + return; + if (on_completion == Event_parse_data::ON_COMPLETION_DROP) { switch (thd->lex->sql_command) { @@ -141,6 +147,42 @@ Event_parse_data::check_if_in_the_past(THD *thd, my_time_t ltime_utc) } +/* + Check time/dates in ALTER EVENT + + We check whether ALTER EVENT was given dates that are in the past. + However to know how to react, we need the ON COMPLETION type. Hence, + the check is deferred until we have the previous ON COMPLETION type + from the event-db to fall back on if nothing was specified in the + ALTER EVENT-statement. + + SYNOPSIS + Event_parse_data::check_dates() + thd Thread + on_completion ON COMPLETION value currently in event-db. + Will be overridden by value in ALTER EVENT if given. + + RETURN VALUE + TRUE an error occurred, do not ALTER + FALSE OK +*/ + +bool +Event_parse_data::check_dates(THD *thd, int previous_on_completion) +{ + if (on_completion == Event_parse_data::ON_COMPLETION_DEFAULT) + { + on_completion= previous_on_completion; + if (!ends_null) + check_if_in_the_past(thd, ends); + if (!execute_at_null) + check_if_in_the_past(thd, execute_at); + } + return do_not_create; +} + + + /* Sets time for execution for one-time event. diff --git a/sql/event_parse_data.h b/sql/event_parse_data.h index 221bf92664f..87a800c2078 100644 --- a/sql/event_parse_data.h +++ b/sql/event_parse_data.h @@ -38,7 +38,12 @@ public: enum enum_on_completion { - ON_COMPLETION_DROP = 1, + /* + On CREATE EVENT, DROP is the DEFAULT as per the docs. + On ALTER EVENT, "no change" is the DEFAULT. + */ + ON_COMPLETION_DEFAULT = 0, + ON_COMPLETION_DROP, ON_COMPLETION_PRESERVE }; @@ -80,6 +85,9 @@ public: bool check_parse_data(THD *thd); + bool + check_dates(THD *thd, int previous_on_completion); + private: void diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 34cd160e7e4..4d521e9d3a0 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3679,10 +3679,12 @@ int ha_partition::index_read_map(uchar *buf, const uchar *key, enum ha_rkey_function find_flag) { DBUG_ENTER("ha_partition::index_read_map"); - end_range= 0; m_index_scan_type= partition_index_read; - DBUG_RETURN(common_index_read(buf, key, keypart_map, find_flag)); + m_start_key.key= key; + m_start_key.keypart_map= keypart_map; + m_start_key.flag= find_flag; + DBUG_RETURN(common_index_read(buf, TRUE)); } @@ -3690,41 +3692,63 @@ int ha_partition::index_read_map(uchar *buf, const uchar *key, Common routine for a number of index_read variants SYNOPSIS - common_index_read - - see index_read for rest + ha_partition::common_index_read() + buf Buffer where the record should be returned + have_start_key TRUE <=> the left endpoint is available, i.e. + we're in index_read call or in read_range_first + call and the range has left endpoint + + FALSE <=> there is no left endpoint (we're in + read_range_first() call and the range has no left + endpoint) + + DESCRIPTION + Start scanning the range (when invoked from read_range_first()) or doing + an index lookup (when invoked from index_read_XXX): + - If possible, perform partition selection + - Find the set of partitions we're going to use + - Depending on whether we need ordering: + NO: Get the first record from first used partition (see + handle_unordered_scan_next_partition) + YES: Fill the priority queue and get the record that is the first in + the ordering + + RETURN + 0 OK + other HA_ERR_END_OF_FILE or other error code. */ -int ha_partition::common_index_read(uchar *buf, const uchar *key, - key_part_map keypart_map, - enum ha_rkey_function find_flag) +int ha_partition::common_index_read(uchar *buf, bool have_start_key) { int error; + uint key_len; bool reverse_order= FALSE; - uint key_len= calculate_key_len(table, active_index, key, keypart_map); DBUG_ENTER("ha_partition::common_index_read"); + LINT_INIT(key_len); /* used if have_start_key==TRUE */ - memcpy((void*)m_start_key.key, key, key_len); - m_start_key.keypart_map= keypart_map; - m_start_key.length= key_len; - m_start_key.flag= find_flag; - - if ((error= partition_scan_set_up(buf, TRUE))) + if (have_start_key) + { + m_start_key.length= key_len= calculate_key_len(table, active_index, + m_start_key.key, + m_start_key.keypart_map); + } + if ((error= partition_scan_set_up(buf, have_start_key))) { DBUG_RETURN(error); } - if (find_flag == HA_READ_PREFIX_LAST || - find_flag == HA_READ_PREFIX_LAST_OR_PREV || - find_flag == HA_READ_BEFORE_KEY) + + if (have_start_key && + (m_start_key.flag == HA_READ_PREFIX_LAST || + m_start_key.flag == HA_READ_PREFIX_LAST_OR_PREV || + m_start_key.flag == HA_READ_BEFORE_KEY)) { reverse_order= TRUE; m_ordered_scan_ongoing= TRUE; } if (!m_ordered_scan_ongoing || - (find_flag == HA_READ_KEY_EXACT && - (key_len >= m_curr_key_info->key_length || - key_len == 0))) - { + (have_start_key && m_start_key.flag == HA_READ_KEY_EXACT && + (key_len >= m_curr_key_info->key_length || key_len == 0))) + { /* We use unordered index scan either when read_range is used and flag is set to not use ordered or when an exact key is used and in this @@ -3815,7 +3839,7 @@ int ha_partition::index_last(uchar * buf) Common routine for index_first/index_last SYNOPSIS - common_index_first_last + ha_partition::common_first_last() see index_first for rest */ @@ -3859,7 +3883,10 @@ int ha_partition::index_read_last_map(uchar *buf, const uchar *key, m_ordered= TRUE; // Safety measure end_range= 0; m_index_scan_type= partition_index_read_last; - DBUG_RETURN(common_index_read(buf, key, keypart_map, HA_READ_PREFIX_LAST)); + m_start_key.key= key; + m_start_key.keypart_map= keypart_map; + m_start_key.flag= HA_READ_PREFIX_LAST; + DBUG_RETURN(common_index_read(buf, TRUE)); } @@ -3990,23 +4017,15 @@ int ha_partition::read_range_first(const key_range *start_key, ((end_key->flag == HA_READ_BEFORE_KEY) ? 1 : (end_key->flag == HA_READ_AFTER_KEY) ? -1 : 0); } - range_key_part= m_curr_key_info->key_part; - if (!start_key) // Read first record - { - if (m_ordered) - m_index_scan_type= partition_index_first; - else - m_index_scan_type= partition_index_first_unordered; - error= common_first_last(m_rec0); - } + range_key_part= m_curr_key_info->key_part; + if (start_key) + m_start_key= *start_key; else - { - m_index_scan_type= partition_index_read; - error= common_index_read(m_rec0, - start_key->key, - start_key->keypart_map, start_key->flag); - } + m_start_key.key= NULL; + + m_index_scan_type= partition_read_range; + error= common_index_read(m_rec0, test(start_key)); DBUG_RETURN(error); } @@ -4028,26 +4047,36 @@ int ha_partition::read_range_next() if (m_ordered) { - DBUG_RETURN(handler::read_range_next()); + DBUG_RETURN(handle_ordered_next(table->record[0], eq_range)); } - DBUG_RETURN(handle_unordered_next(m_rec0, eq_range)); + DBUG_RETURN(handle_unordered_next(table->record[0], eq_range)); } /* - Common routine to set up scans + Common routine to set up index scans SYNOPSIS - buf Buffer to later return record in - idx_read_flag Is it index scan + ha_partition::partition_scan_set_up() + buf Buffer to later return record in (this function + needs it to calculcate partitioning function + values) + + idx_read_flag TRUE <=> m_start_key has range start endpoint which + probably can be used to determine the set of partitions + to scan. + FALSE <=> there is no start endpoint. + + DESCRIPTION + Find out which partitions we'll need to read when scanning the specified + range. + + If we need to scan only one partition, set m_ordered_scan_ongoing=FALSE + as we will not need to do merge ordering. RETURN VALUE >0 Error code 0 Success - - DESCRIPTION - This is where we check which partitions to actually scan if not all - of them */ int ha_partition::partition_scan_set_up(uchar * buf, bool idx_read_flag) @@ -4138,10 +4167,19 @@ int ha_partition::handle_unordered_next(uchar *buf, bool is_next_same) DBUG_ENTER("ha_partition::handle_unordered_next"); /* - We should consider if this should be split into two functions as - next_same is alwas a local constant + We should consider if this should be split into three functions as + partition_read_range is_next_same are always local constants */ - if (is_next_same) + + if (m_index_scan_type == partition_read_range) + { + if (!(error= file->read_range_next())) + { + m_last_part= m_part_spec.start_part; + DBUG_RETURN(0); + } + } + else if (is_next_same) { if (!(error= file->index_next_same(buf, m_start_key.key, m_start_key.length))) @@ -4150,15 +4188,13 @@ int ha_partition::handle_unordered_next(uchar *buf, bool is_next_same) DBUG_RETURN(0); } } - else if (!(error= file->index_next(buf))) + else { - if (!(file->index_flags(active_index, 0, 1) & HA_READ_ORDER) || - compare_key(end_range) <= 0) + if (!(error= file->index_next(buf))) { m_last_part= m_part_spec.start_part; DBUG_RETURN(0); // Row was in range } - error= HA_ERR_END_OF_FILE; } if (error == HA_ERR_END_OF_FILE) @@ -4202,6 +4238,11 @@ int ha_partition::handle_unordered_scan_next_partition(uchar * buf) file= m_file[i]; m_part_spec.start_part= i; switch (m_index_scan_type) { + case partition_read_range: + DBUG_PRINT("info", ("read_range_first on partition %d", i)); + error= file->read_range_first(m_start_key.key? &m_start_key: NULL, + end_range, eq_range, FALSE); + break; case partition_index_read: DBUG_PRINT("info", ("index_read on partition %d", i)); error= file->index_read_map(buf, m_start_key.key, @@ -4230,13 +4271,8 @@ int ha_partition::handle_unordered_scan_next_partition(uchar * buf) } if (!error) { - if (!(file->index_flags(active_index, 0, 1) & HA_READ_ORDER) || - compare_key(end_range) <= 0) - { - m_last_part= i; - DBUG_RETURN(0); - } - error= HA_ERR_END_OF_FILE; + m_last_part= i; + DBUG_RETURN(0); } if ((error != HA_ERR_END_OF_FILE) && (error != HA_ERR_KEY_NOT_FOUND)) DBUG_RETURN(error); @@ -4315,6 +4351,17 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order) m_start_key.keypart_map); reverse_order= TRUE; break; + case partition_read_range: + { + /* + This can only read record to table->record[0], as it was set when + the table was being opened. We have to memcpy data ourselves. + */ + error= file->read_range_first(&m_start_key, end_range, eq_range, TRUE); + memcpy(rec_buf_ptr, table->record[0], m_rec_length); + reverse_order= FALSE; + break; + } default: DBUG_ASSERT(FALSE); DBUG_RETURN(HA_ERR_END_OF_FILE); @@ -4395,8 +4442,13 @@ int ha_partition::handle_ordered_next(uchar *buf, bool is_next_same) uint part_id= m_top_entry; handler *file= m_file[part_id]; DBUG_ENTER("ha_partition::handle_ordered_next"); - - if (!is_next_same) + + if (m_index_scan_type == partition_read_range) + { + error= file->read_range_next(); + memcpy(rec_buf(part_id), table->record[0], m_rec_length); + } + else if (!is_next_same) error= file->index_next(rec_buf(part_id)); else error= file->index_next_same(rec_buf(part_id), m_start_key.key, diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 97f5624608f..459b566b6d8 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -49,7 +49,8 @@ private: partition_index_first_unordered= 2, partition_index_last= 3, partition_index_read_last= 4, - partition_no_index_scan= 5 + partition_read_range = 5, + partition_no_index_scan= 6 }; /* Data for the partition handler */ int m_mode; // Open mode @@ -63,8 +64,6 @@ private: handler **m_reorged_file; // Reorganised partitions handler **m_added_file; // Added parts kept for errors partition_info *m_part_info; // local reference to partition - uchar *m_start_key_ref; // Reference of start key in current - // index scan info Field **m_part_field_array; // Part field array locally to save acc uchar *m_ordered_rec_buffer; // Row and key buffer for ord. idx scan KEY *m_curr_key_info; // Current index @@ -429,9 +428,7 @@ public: virtual int read_range_next(); private: - int common_index_read(uchar * buf, const uchar * key, - key_part_map keypart_map, - enum ha_rkey_function find_flag); + int common_index_read(uchar * buf, bool have_start_key); int common_first_last(uchar * buf); int partition_scan_set_up(uchar * buf, bool idx_read_flag); int handle_unordered_next(uchar * buf, bool next_same); diff --git a/sql/item.cc b/sql/item.cc index 951336cce24..cdb71e86694 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4342,7 +4342,12 @@ Item *Item_field::equal_fields_propagator(uchar *arg) item= this; else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type())) { - if (item && cmp_context != INT_RESULT) + /* + We don't need to zero-fill timestamp columns here because they will be + first converted to a string (in date/time format) and compared as such if + compared with another string. + */ + if (item && field->type() != FIELD_TYPE_TIMESTAMP && cmp_context != INT_RESULT) convert_zerofill_number_to_string(&item, (Field_num *)field); else item= this; diff --git a/sql/item_func.cc b/sql/item_func.cc index 8bb6bb30117..d7e6fc1f8f2 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3805,6 +3805,25 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, return entry; } + +bool Item_func_set_user_var::set_entry(THD *thd, bool create_if_not_exists) +{ + if (thd == entry_thd && entry) + goto end; // update entry->update_query_id for PS + entry_thd= thd; + if (!(entry= get_variable(&thd->user_vars, name, create_if_not_exists))) + return TRUE; + /* + Remember the last query which updated it, this way a query can later know + if this variable is a constant item in the query (it is if update_query_id + is different from query_id). + */ +end: + entry->update_query_id= thd->query_id; + return FALSE; +} + + /* When a user variable is updated (in a SET command or a query like SELECT @a:= ). @@ -3814,15 +3833,8 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); /* fix_fields will call Item_func_set_user_var::fix_length_and_dec */ - if (Item_func::fix_fields(thd, ref) || - !(entry= get_variable(&thd->user_vars, name, 1))) + if (Item_func::fix_fields(thd, ref) || set_entry(thd, TRUE)) return TRUE; - /* - Remember the last query which updated it, this way a query can later know - if this variable is a constant item in the query (it is if update_query_id - is different from query_id). - */ - entry->update_query_id= thd->query_id; /* As it is wrong and confusing to associate any character set with NULL, @a should be latin2 diff --git a/sql/item_func.h b/sql/item_func.h index 02631d7643d..d84abdb6e56 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1294,6 +1294,17 @@ class Item_func_set_user_var :public Item_func { enum Item_result cached_result_type; user_var_entry *entry; + /* + The entry_thd variable is used: + 1) to skip unnecessary updates of the entry field (see above); + 2) to reset the entry field that was initialized in the other thread + (for example, an item tree of a trigger that updates user variables + may be shared between several connections, and the entry_thd field + prevents updates of one connection user variables from a concurrent + connection calling the same trigger that initially updated some + user variable it the first connection context). + */ + THD *entry_thd; char buffer[MAX_FIELD_WIDTH]; String value; my_decimal decimal_buff; @@ -1309,7 +1320,8 @@ class Item_func_set_user_var :public Item_func public: LEX_STRING name; // keep it public Item_func_set_user_var(LEX_STRING a,Item *b) - :Item_func(b), cached_result_type(INT_RESULT), name(a) + :Item_func(b), cached_result_type(INT_RESULT), + entry(NULL), entry_thd(NULL), name(a) {} enum Functype functype() const { return SUSERVAR_FUNC; } double val_real(); @@ -1340,6 +1352,7 @@ public: } void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); } bool register_field_in_read_map(uchar *arg); + bool set_entry(THD *thd, bool create_if_not_exists); }; diff --git a/sql/lock.cc b/sql/lock.cc index 675b94c2175..faddb8c586c 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -854,7 +854,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, if ((table=table_ptr[i])->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE) continue; lock_type= table->reginfo.lock_type; - DBUG_ASSERT (lock_type != TL_WRITE_DEFAULT); + DBUG_ASSERT(lock_type != TL_WRITE_DEFAULT && lock_type != TL_READ_DEFAULT); if (lock_type >= TL_WRITE_ALLOW_WRITE) { *write_lock_used=table; diff --git a/sql/log_event.cc b/sql/log_event.cc index 27e81c8ecd3..fe9eba81f80 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8061,7 +8061,6 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability */ } - m_table->file->ha_start_bulk_insert(0); /* We need TIMESTAMP_NO_AUTO_SET otherwise ha_write_row() will not use fill any TIMESTAMP column with data from the row but instead will use @@ -8200,7 +8199,16 @@ Rows_log_event::write_row(const Relay_log_info *const rli, /* unpack row into table->record[0] */ error= unpack_current_row(rli); // TODO: how to handle errors? - + if (m_curr_row == m_rows_buf) + { + /* this is the first row to be inserted, we estimate the rows with + the size of the first row and use that value to initialize + storage engine for bulk insertion */ + ulong estimated_rows= (m_rows_end - m_curr_row) / (m_curr_row_end - m_curr_row); + m_table->file->ha_start_bulk_insert(estimated_rows); + } + + #ifndef DBUG_OFF DBUG_DUMP("record[0]", table->record[0], table->s->reclength); DBUG_PRINT_BITSET("debug", "write_set = %s", table->write_set); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4e1f2ad6f60..f2b2806ea60 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1265,6 +1265,7 @@ bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last, TABLE_LIST *new_child_list, TABLE_LIST **new_last); bool reopen_table(TABLE *table); bool reopen_tables(THD *thd,bool get_locks,bool in_refresh); +thr_lock_type read_lock_type_for_table(THD *thd, TABLE *table); void close_data_files_and_morph_locks(THD *thd, const char *db, const char *table_name); void close_handle_and_leave_table_as_lock(TABLE *table); @@ -1938,7 +1939,7 @@ extern bool opt_using_transactions; extern bool mysqld_embedded; #endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */ #ifdef MYSQL_SERVER -extern bool using_update_log, opt_large_files, server_id_supplied; +extern bool opt_large_files, server_id_supplied; extern bool opt_update_log, opt_bin_log, opt_error_log; extern my_bool opt_log, opt_slow_log; extern ulong log_output_options; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a3b0123ee4a..b04d4e3cecd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -382,7 +382,7 @@ my_bool opt_character_set_client_handshake= 1; bool server_id_supplied = 0; bool opt_endinfo, using_udf_functions; my_bool locked_in_memory; -bool opt_using_transactions, using_update_log; +bool opt_using_transactions; bool volatile abort_loop; bool volatile shutdown_in_progress; /** @@ -3815,12 +3815,6 @@ server."); { unireg_abort(1); } - - /* - Used to specify which type of lock we need to use for queries of type - INSERT ... SELECT. This will change when we have row level logging. - */ - using_update_log=1; } /* call ha_init_key_cache() on all key caches to init them */ @@ -7431,7 +7425,7 @@ static void mysql_init_variables(void) slave_open_temp_tables= 0; cached_thread_count= 0; opt_endinfo= using_udf_functions= 0; - opt_using_transactions= using_update_log= 0; + opt_using_transactions= 0; abort_loop= select_thread_in_use= signal_thread_in_use= 0; ready_to_exit= shutdown_in_progress= grant_option= 0; aborted_threads= aborted_connects= 0; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 39030462f0b..49efc72ba68 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4355,6 +4355,38 @@ bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last, } +/* + Return a appropriate read lock type given a table object. + + @param thd Thread context + @param table TABLE object for table to be locked + + @remark Due to a statement-based replication limitation, statements such as + INSERT INTO .. SELECT FROM .. and CREATE TABLE .. SELECT FROM need + to grab a TL_READ_NO_INSERT lock on the source table in order to + prevent the replication of a concurrent statement that modifies the + source table. If such a statement gets applied on the slave before + the INSERT .. SELECT statement finishes, data on the master could + differ from data on the slave and end-up with a discrepancy between + the binary log and table state. Furthermore, this does not apply to + I_S and log tables as it's always unsafe to replicate such tables + under statement-based replication as the table on the slave might + contain other data (ie: general_log is enabled on the slave). The + statement will be marked as unsafe for SBR in decide_logging_format(). +*/ + +thr_lock_type read_lock_type_for_table(THD *thd, TABLE *table) +{ + bool log_on= mysql_bin_log.is_open() && (thd->options & OPTION_BIN_LOG); + ulong binlog_format= thd->variables.binlog_format; + if ((log_on == FALSE) || (binlog_format == BINLOG_FORMAT_ROW) || + (table->s->table_category == TABLE_CATEGORY_PERFORMANCE)) + return TL_READ; + else + return TL_READ_NO_INSERT; +} + + /* Open all tables in list @@ -4629,6 +4661,9 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) { if (tables->lock_type == TL_WRITE_DEFAULT) tables->table->reginfo.lock_type= thd->update_lock_default; + else if (tables->lock_type == TL_READ_DEFAULT) + tables->table->reginfo.lock_type= + read_lock_type_for_table(thd, tables->table); else if (tables->table->s->tmp_table == NO_TMP_TABLE) tables->table->reginfo.lock_type= tables->lock_type; } @@ -5036,7 +5071,11 @@ int decide_logging_format(THD *thd, TABLE_LIST *tables) void* prev_ht= NULL; for (TABLE_LIST *table= tables; table; table= table->next_global) { - if (!table->placeholder() && table->lock_type >= TL_WRITE_ALLOW_WRITE) + if (table->placeholder()) + continue; + if (table->table->s->table_category == TABLE_CATEGORY_PERFORMANCE) + thd->lex->set_stmt_unsafe(); + if (table->lock_type >= TL_WRITE_ALLOW_WRITE) { ulonglong const flags= table->table->file->ha_table_flags(); DBUG_PRINT("info", ("table: %s; ha_table_flags: %s%s", @@ -7296,6 +7335,22 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, if (ref_pointer_array) bzero(ref_pointer_array, sizeof(Item *) * fields.elements); + /* + We call set_entry() there (before fix_fields() of the whole list of field + items) because: + 1) the list of field items has same order as in the query, and the + Item_func_get_user_var item may go before the Item_func_set_user_var: + SELECT @a, @a := 10 FROM t; + 2) The entry->update_query_id value controls constantness of + Item_func_get_user_var items, so in presence of Item_func_set_user_var + items we have to refresh their entries before fixing of + Item_func_get_user_var items. + */ + List_iterator li(thd->lex->set_var_list); + Item_func_set_user_var *var; + while ((var= li++)) + var->set_entry(thd, FALSE); + Item **ref= ref_pointer_array; thd->lex->current_select->cur_pos_in_select_list= 0; while ((item= it++)) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f5566acbc6f..81d0d447ac1 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1542,10 +1542,9 @@ void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used) for (; tables_used; tables_used= tables_used->next_local) { thd_proc_info(thd, "invalidating query cache entries (table)"); - if (tables_used->lock_type & (TL_WRITE_LOW_PRIORITY | TL_WRITE) && + if (tables_used->lock_type >= TL_WRITE_ALLOW_WRITE && tables_used->table) { - THD *thd= current_thd; invalidate_table(thd, tables_used->table); } } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 1822176f00a..18c61910e89 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -293,6 +293,7 @@ void lex_start(THD *thd) lex->select_lex.init_query(); lex->value_list.empty(); lex->update_list.empty(); + lex->set_var_list.empty(); lex->param_list.empty(); lex->view_list.empty(); lex->prepared_stmt_params.empty(); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index bb3dc00fc8d..7674b5c7ac2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1549,6 +1549,7 @@ typedef struct st_lex : public Query_tables_list List *insert_list,field_list,value_list,update_list; List many_values; List var_list; + List set_var_list; // in-query assignment list List param_list; List view_list; // view list (list of field names in view) /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9f94893ffe3..30fef9c7ee7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5628,7 +5628,7 @@ void mysql_init_multi_delete(LEX *lex) lex->select_lex.select_limit= 0; lex->unit.select_limit_cnt= HA_POS_ERROR; lex->select_lex.table_list.save_and_clear(&lex->auxiliary_table_list); - lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; + lex->lock_option= TL_READ_DEFAULT; lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index b9ad88ee663..e2ed3371711 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1039,7 +1039,7 @@ reopen_tables: correct order of statements. Otherwise, we use a TL_READ lock to improve performance. */ - tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ; + tl->lock_type= read_lock_type_for_table(thd, table); tl->updating= 0; /* Update TABLE::lock_type accordingly. */ if (!tl->placeholder() && !using_lock_tables) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 04f73cb963b..278fe88c336 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1817,6 +1817,8 @@ event_tail: if (!(lex->event_parse_data= Event_parse_data::new_instance(thd))) MYSQL_YYABORT; lex->event_parse_data->identifier= $3; + lex->event_parse_data->on_completion= + Event_parse_data::ON_COMPLETION_DROP; lex->sql_command= SQLCOM_CREATE_EVENT; /* We need that for disallowing subqueries */ @@ -4299,7 +4301,7 @@ create_select: SELECT_SYM { LEX *lex=Lex; - lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; + lex->lock_option= TL_READ_DEFAULT; if (lex->sql_command == SQLCOM_INSERT) lex->sql_command= SQLCOM_INSERT_SELECT; else if (lex->sql_command == SQLCOM_REPLACE) @@ -8062,11 +8064,13 @@ variable: variable_aux: ident_or_text SET_VAR expr { - $$= new (YYTHD->mem_root) Item_func_set_user_var($1, $3); + Item_func_set_user_var *item; + $$= item= new (YYTHD->mem_root) Item_func_set_user_var($1, $3); if ($$ == NULL) MYSQL_YYABORT; LEX *lex= Lex; lex->uncacheable(UNCACHEABLE_RAND); + lex->set_var_list.push_back(item); } | ident_or_text { @@ -9394,7 +9398,7 @@ insert: lex->duplicates= DUP_ERROR; mysql_init_select(lex); /* for subselects */ - lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ; + lex->lock_option= TL_READ_DEFAULT; } insert_lock_option opt_ignore insert2