diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 13:05:06 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-27 15:14:48 +0200 |
commit | 5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2 (patch) | |
tree | cde569f712505f981e7a43f01e82c600e282c88c | |
parent | ee9a19fb054085fcea006a25ec957e0d5cb01ce8 (diff) | |
parent | 16bce0f6fe6bcad0091dc45a97a8ac7b33fe9d44 (diff) | |
download | mariadb-git-5ab70e7f68ba9659dbdd8c71759cfe99ee90ebf2.tar.gz |
Merge 10.2 into 10.3
60 files changed, 843 insertions, 301 deletions
diff --git a/.clang-format b/.clang-format index 1ad93ead80a..5fc6ab23622 100644 --- a/.clang-format +++ b/.clang-format @@ -90,7 +90,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right ReflowComments: true -SortIncludes: true +SortIncludes: false SortUsingDeclarations: true SpaceAfterCStyleCast: true SpaceAfterLogicalNot: false diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 0c2ec0bed18..ddaed8bd16a 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2683,7 +2683,9 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn, bool last) } } - if (more_data && recv_parse_log_recs(0, STORE_NO, false)) { + store_t store = STORE_NO; + + if (more_data && recv_parse_log_recs(0, &store, 0, false)) { msg("Error: copying the log failed"); diff --git a/mysql-test/include/binlog_parallel_replication_marks.test b/mysql-test/include/binlog_parallel_replication_marks.test index 82fa997822d..3976088ca43 100644 --- a/mysql-test/include/binlog_parallel_replication_marks.test +++ b/mysql-test/include/binlog_parallel_replication_marks.test @@ -80,7 +80,7 @@ while (<F>) { s/table id \d+/table id #/; s/mapped to number \d+/mapped to number #/; s/CRC32 0x[0-9a-f]+/CRC32 0x########/; - print if /GTID|BEGIN|COMMIT|Table_map|Write_rows|Update_rows|Delete_rows|generated by server|40005 TEMPORARY/; + print if /\b(GTID|BEGIN|COMMIT|Table_map|Write_rows|Update_rows|Delete_rows|generated by server|40005 TEMPORARY)\b/; } close F; EOF diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index ea8400f8302..19c4ee81124 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -10568,6 +10568,36 @@ EXPLAIN } DROP TABLE t1; DROP VIEW v1; +# +# MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on +# +CREATE TABLE t1 (a INT, b DATE, c INT); +INSERT INTO t1 VALUES +(1,'2001-01-21',345), +(6,'2001-01-20',315), +(6,'2001-01-20',214); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (2,19), (7,20); +CREATE VIEW v1 AS SELECT a, b, max(c) AS max_c FROM t1 +GROUP BY a,b HAVING max_c < 707; +SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a); +a b max_c a b dayname(v1.b) +1 2001-01-21 345 2 19 Sunday +1 2001-01-21 345 7 20 Sunday +6 2001-01-20 315 7 20 Saturday +SET optimizer_switch='condition_pushdown_for_derived=off'; +SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday'; +a b max_c a b dayname(v1.b) +1 2001-01-21 345 2 19 Sunday +1 2001-01-21 345 7 20 Sunday +SET optimizer_switch='condition_pushdown_for_derived=on'; +SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday'; +a b max_c a b dayname(v1.b) +1 2001-01-21 345 2 19 Sunday +1 2001-01-21 345 7 20 Sunday +DROP VIEW v1; +DROP TABLE t1, t2; +SET optimizer_switch=DEFAULT; # End of 10.2 tests # # MDEV-14579: pushdown conditions into materialized views/derived tables diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index 6ee85df7ea5..e3a7306f7a0 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -2140,6 +2140,34 @@ SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt; DROP TABLE t1; DROP VIEW v1; +--echo # +--echo # MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on +--echo # + +CREATE TABLE t1 (a INT, b DATE, c INT); +INSERT INTO t1 VALUES + (1,'2001-01-21',345), + (6,'2001-01-20',315), + (6,'2001-01-20',214); + +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (2,19), (7,20); +CREATE VIEW v1 AS SELECT a, b, max(c) AS max_c FROM t1 + GROUP BY a,b HAVING max_c < 707; + +SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a); + +SET optimizer_switch='condition_pushdown_for_derived=off'; +SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday'; + +SET optimizer_switch='condition_pushdown_for_derived=on'; +SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday'; + +DROP VIEW v1; +DROP TABLE t1, t2; + +SET optimizer_switch=DEFAULT; + --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index 408183af47b..b8b14e61b46 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -159,7 +159,9 @@ date_format('1999-12-31','%x-%v') date_format('2000-01-01','%x-%v') 1999-52 1999-52 select dayname("1962-03-03"),dayname("1962-03-03")+0; dayname("1962-03-03") dayname("1962-03-03")+0 -Saturday 5 +Saturday 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Saturday' select monthname("1972-03-04"),monthname("1972-03-04")+0; monthname("1972-03-04") monthname("1972-03-04")+0 March 0 @@ -3508,6 +3510,19 @@ v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI DROP VIEW v1,v2,v3; DROP TABLE t1,t2; # +# MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on +# +SELECT DAYNAME('2019-01-05')+0; +DAYNAME('2019-01-05')+0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Saturday' +SELECT CAST(DAYNAME('2019-01-05') AS SIGNED); +CAST(DAYNAME('2019-01-05') AS SIGNED) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'Saturday' +# # End of 10.2 tests # # diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 232cb16939e..719b0ae13b6 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -1970,6 +1970,14 @@ DROP VIEW v1,v2,v3; DROP TABLE t1,t2; --echo # +--echo # MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on +--echo # + +SELECT DAYNAME('2019-01-05')+0; +SELECT CAST(DAYNAME('2019-01-05') AS SIGNED); + + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result index e33a519e897..fc9ddce08b1 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result @@ -4,7 +4,7 @@ # Verbose run \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; @@ -36,7 +36,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -46,7 +46,7 @@ END IF| # Silent run \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; @@ -75,7 +75,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -93,7 +93,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, ; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -105,21 +105,21 @@ END IF| # \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=InnoDB; END IF| \d ; TRUNCATE TABLE time_zone_leap_second; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=MyISAM; END IF| \d ; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -131,7 +131,7 @@ END IF| # \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; @@ -146,7 +146,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; diff --git a/mysql-test/main/type_datetime.result b/mysql-test/main/type_datetime.result index a7a9eece0da..19a2c87b730 100644 --- a/mysql-test/main/type_datetime.result +++ b/mysql-test/main/type_datetime.result @@ -1198,6 +1198,87 @@ Warning 1292 Incorrect datetime value: '2' for column `test`.`t1`.`pk` at row 2 DROP VIEW v1; DROP TABLE t1; # +# MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41 +# +CREATE TABLE t1 +( +id INT NOT NULL PRIMARY KEY, +id2 INT, +k TINYINT, +j INT, +t DATETIME, +KEY k1 (id2,k,j,t) +); +INSERT INTO t1 VALUES +(53,54,1,0,'2019-12-13 10:09:59'), +(54,54,1,0,'2019-12-13 16:28:41'), +(55,54,1,0,'2019-12-13 16:29:10'), +(56,54,1,0,'2019-12-13 16:29:43'), +(57,54,1,0,'2019-12-13 16:30:16'), +(58,54,1,0,'2019-12-13 16:30:49'), +(59,54,1,0,'2019-12-13 16:31:23'), +(60,54,1,0,'2019-12-13 16:31:55'), +(61,54,1,0,'2019-12-13 16:32:28'), +(62,54,1,0,'2019-12-13 16:33:01'), +(63,54,1,0,'2019-12-13 16:33:34'), +(64,54,1,0,'2019-12-13 16:34:07'), +(65,54,1,0,'2019-12-13 16:34:40'), +(66,54,1,0,'2019-12-13 16:35:13'), +(67,54,1,0,'2019-12-13 16:35:46'), +(68,54,1,0,'2019-12-13 16:36:19'); +SELECT t FROM t1 GROUP BY t HAVING t=max(t); +t +2019-12-13 10:09:59 +2019-12-13 16:28:41 +2019-12-13 16:29:10 +2019-12-13 16:29:43 +2019-12-13 16:30:16 +2019-12-13 16:30:49 +2019-12-13 16:31:23 +2019-12-13 16:31:55 +2019-12-13 16:32:28 +2019-12-13 16:33:01 +2019-12-13 16:33:34 +2019-12-13 16:34:07 +2019-12-13 16:34:40 +2019-12-13 16:35:13 +2019-12-13 16:35:46 +2019-12-13 16:36:19 +SELECT t FROM t1 WHERE id2=54 and j=0 and k=1 GROUP BY t HAVING t=max(t); +t +2019-12-13 10:09:59 +2019-12-13 16:28:41 +2019-12-13 16:29:10 +2019-12-13 16:29:43 +2019-12-13 16:30:16 +2019-12-13 16:30:49 +2019-12-13 16:31:23 +2019-12-13 16:31:55 +2019-12-13 16:32:28 +2019-12-13 16:33:01 +2019-12-13 16:33:34 +2019-12-13 16:34:07 +2019-12-13 16:34:40 +2019-12-13 16:35:13 +2019-12-13 16:35:46 +2019-12-13 16:36:19 +DROP TABLE t1; +CREATE TABLE t1 (pk INT); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1); +SELECT pk<DATE'2001-01-01' FROM t1 GROUP BY pk; +pk<DATE'2001-01-01' +1 +Warnings: +Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1 +SELECT pk<DATE'2001-01-01' FROM v1 GROUP BY pk; +pk<DATE'2001-01-01' +1 +Warnings: +Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1 +DROP VIEW v1; +DROP TABLE t1; +# # End of 10.1 tests # # diff --git a/mysql-test/main/type_datetime.test b/mysql-test/main/type_datetime.test index 2445925cb80..60b30121559 100644 --- a/mysql-test/main/type_datetime.test +++ b/mysql-test/main/type_datetime.test @@ -748,6 +748,49 @@ DROP TABLE t1; --echo # +--echo # MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41 +--echo # + +CREATE TABLE t1 +( + id INT NOT NULL PRIMARY KEY, + id2 INT, + k TINYINT, + j INT, + t DATETIME, + KEY k1 (id2,k,j,t) +); +INSERT INTO t1 VALUES +(53,54,1,0,'2019-12-13 10:09:59'), +(54,54,1,0,'2019-12-13 16:28:41'), +(55,54,1,0,'2019-12-13 16:29:10'), +(56,54,1,0,'2019-12-13 16:29:43'), +(57,54,1,0,'2019-12-13 16:30:16'), +(58,54,1,0,'2019-12-13 16:30:49'), +(59,54,1,0,'2019-12-13 16:31:23'), +(60,54,1,0,'2019-12-13 16:31:55'), +(61,54,1,0,'2019-12-13 16:32:28'), +(62,54,1,0,'2019-12-13 16:33:01'), +(63,54,1,0,'2019-12-13 16:33:34'), +(64,54,1,0,'2019-12-13 16:34:07'), +(65,54,1,0,'2019-12-13 16:34:40'), +(66,54,1,0,'2019-12-13 16:35:13'), +(67,54,1,0,'2019-12-13 16:35:46'), +(68,54,1,0,'2019-12-13 16:36:19'); +SELECT t FROM t1 GROUP BY t HAVING t=max(t); +SELECT t FROM t1 WHERE id2=54 and j=0 and k=1 GROUP BY t HAVING t=max(t); +DROP TABLE t1; + +CREATE TABLE t1 (pk INT); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1); +SELECT pk<DATE'2001-01-01' FROM t1 GROUP BY pk; +SELECT pk<DATE'2001-01-01' FROM v1 GROUP BY pk; +DROP VIEW v1; +DROP TABLE t1; + + +--echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/main/type_int.result b/mysql-test/main/type_int.result index 3a1cdf2f24b..45060611f8e 100644 --- a/mysql-test/main/type_int.result +++ b/mysql-test/main/type_int.result @@ -20,6 +20,19 @@ COALESCE(@a) 1 DROP TABLE t1; # +# MDEV-21065 UNIQUE constraint causes a query with string comparison to omit a row in the result set +# +CREATE TABLE t1 (c0 INT UNIQUE); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL), (NULL), (1), (0); +SELECT * FROM t1 WHERE c0 < '\n2'; +c0 +0 +1 +DROP TABLE t1; +SELECT CAST('\n2' AS INT); +CAST('\n2' AS INT) +2 +# # End of 5.5 tests # # diff --git a/mysql-test/main/type_int.test b/mysql-test/main/type_int.test index 008fd014afa..38bd1a0037a 100644 --- a/mysql-test/main/type_int.test +++ b/mysql-test/main/type_int.test @@ -15,6 +15,18 @@ SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); DROP TABLE t1; --echo # +--echo # MDEV-21065 UNIQUE constraint causes a query with string comparison to omit a row in the result set +--echo # + +CREATE TABLE t1 (c0 INT UNIQUE); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL), (NULL), (1), (0); +SELECT * FROM t1 WHERE c0 < '\n2'; +DROP TABLE t1; + +SELECT CAST('\n2' AS INT); + + +--echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result index 44f0d50d94e..de0dd9a03a2 100644 --- a/mysql-test/main/type_time.result +++ b/mysql-test/main/type_time.result @@ -1246,6 +1246,72 @@ drop table t1; SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; set @@old_mode= @save_old_mode; # +# MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41 +# +CREATE OR REPLACE TABLE t1 +( +id INT NOT NULL PRIMARY KEY, +id2 INT, +k TINYINT, +j INT, +t TIME, +KEY k1 (id2,k,j,t) +); +INSERT INTO t1 VALUES +(53,54,1,0,'10:09:59'), +(54,54,1,0,'16:28:41'), +(55,54,1,0,'16:29:10'), +(56,54,1,0,'16:29:43'), +(57,54,1,0,'16:30:16'), +(58,54,1,0,'16:30:49'), +(59,54,1,0,'16:31:23'), +(60,54,1,0,'16:31:55'), +(61,54,1,0,'16:32:28'), +(62,54,1,0,'16:33:01'), +(63,54,1,0,'16:33:34'), +(64,54,1,0,'16:34:07'), +(65,54,1,0,'16:34:40'), +(66,54,1,0,'16:35:13'), +(67,54,1,0,'16:35:46'), +(68,54,1,0,'16:36:19'); +SELECT t FROM t1 GROUP BY t HAVING t=MAX(t); +t +10:09:59 +16:28:41 +16:29:10 +16:29:43 +16:30:16 +16:30:49 +16:31:23 +16:31:55 +16:32:28 +16:33:01 +16:33:34 +16:34:07 +16:34:40 +16:35:13 +16:35:46 +16:36:19 +SELECT t FROM t1 WHERE id2=54 AND j=0 AND k=1 GROUP BY t HAVING t=MAX(t); +t +10:09:59 +16:28:41 +16:29:10 +16:29:43 +16:30:16 +16:30:49 +16:31:23 +16:31:55 +16:32:28 +16:33:01 +16:33:34 +16:34:07 +16:34:40 +16:35:13 +16:35:46 +16:36:19 +DROP TABLE t1; +# # End of 10.1 tests # # diff --git a/mysql-test/main/type_time.test b/mysql-test/main/type_time.test index d8bb66fcd5c..5c998ec0ab0 100644 --- a/mysql-test/main/type_time.test +++ b/mysql-test/main/type_time.test @@ -747,6 +747,40 @@ SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selecti set @@old_mode= @save_old_mode; --echo # +--echo # MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41 +--echo # + +CREATE OR REPLACE TABLE t1 +( + id INT NOT NULL PRIMARY KEY, + id2 INT, + k TINYINT, + j INT, + t TIME, + KEY k1 (id2,k,j,t) +); +INSERT INTO t1 VALUES +(53,54,1,0,'10:09:59'), +(54,54,1,0,'16:28:41'), +(55,54,1,0,'16:29:10'), +(56,54,1,0,'16:29:43'), +(57,54,1,0,'16:30:16'), +(58,54,1,0,'16:30:49'), +(59,54,1,0,'16:31:23'), +(60,54,1,0,'16:31:55'), +(61,54,1,0,'16:32:28'), +(62,54,1,0,'16:33:01'), +(63,54,1,0,'16:33:34'), +(64,54,1,0,'16:34:07'), +(65,54,1,0,'16:34:40'), +(66,54,1,0,'16:35:13'), +(67,54,1,0,'16:35:46'), +(68,54,1,0,'16:36:19'); +SELECT t FROM t1 GROUP BY t HAVING t=MAX(t); +SELECT t FROM t1 WHERE id2=54 AND j=0 AND k=1 GROUP BY t HAVING t=MAX(t); +DROP TABLE t1; + +--echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 9322383437e..0ec459d4bd2 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -3643,6 +3643,87 @@ x foo drop table t1; # +# MDEV-16579: Wrong result of query using DISTINCT COUNT(*) OVER (*) +# +CREATE TABLE t1 (i int) ; +INSERT INTO t1 VALUES (1),(0),(1),(2),(0),(1),(2),(1),(2); +SELECT DISTINCT COUNT(*) OVER (), MOD(MIN(i),2) FROM t1 GROUP BY i ; +COUNT(*) OVER () MOD(MIN(i),2) +3 0 +3 1 +drop table t1; +# +# MDEV-21318: Wrong results with window functions and implicit grouping +# +CREATE TABLE t1 (a INT); +# +# With empty const table +# The expected result here is 1, NULL +# +explain +SELECT row_number() over(), sum(1) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 Const row not found; Using temporary +SELECT row_number() over(), sum(1) FROM t1; +row_number() over() sum(1) +1 NULL +insert into t1 values (2); +# +# Const table has 1 row, but still impossible where +# The expected result here is 1, NULL +# +EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT row_number() over(), sum(1) FROM t1 where a=1; +row_number() over() sum(1) +1 NULL +# +# Impossible HAVING +# Empty result is expected +# +EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0; +row_number() over() sum(1) +# +# const table has 1 row, no impossible where +# The expected result here is 1, 2 +# +EXPLAIN SELECT row_number() over(), sum(a) FROM t1 where a=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary +SELECT row_number() over(), sum(a) FROM t1 where a=2; +row_number() over() sum(a) +1 2 +drop table t1; +# +# Impossible Where +# +create table t1(a int); +insert into t1 values (1); +# +# Expected result is NULL, 0, NULL +# +EXPLAIN SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; +MAX(a) OVER () COUNT(a) abs(a) +NULL 0 NULL +# +# Expected result is 1, 0, NULL +# +EXPLAIN +SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; +MAX(1) OVER () COUNT(a) abs(a) +1 0 NULL +drop table t1; +# # End of 10.2 tests # # diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index a9a67bef575..38da2bde064 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -2352,6 +2352,81 @@ SELECT (SELECT MIN('foo') OVER() FROM t1 LIMIT 1) as x; drop table t1; --echo # +--echo # MDEV-16579: Wrong result of query using DISTINCT COUNT(*) OVER (*) +--echo # + +CREATE TABLE t1 (i int) ; +INSERT INTO t1 VALUES (1),(0),(1),(2),(0),(1),(2),(1),(2); + +SELECT DISTINCT COUNT(*) OVER (), MOD(MIN(i),2) FROM t1 GROUP BY i ; +drop table t1; + +--echo # +--echo # MDEV-21318: Wrong results with window functions and implicit grouping +--echo # + +CREATE TABLE t1 (a INT); + +--echo # +--echo # With empty const table +--echo # The expected result here is 1, NULL +--echo # + +explain +SELECT row_number() over(), sum(1) FROM t1; +SELECT row_number() over(), sum(1) FROM t1; + +insert into t1 values (2); + +--echo # +--echo # Const table has 1 row, but still impossible where +--echo # The expected result here is 1, NULL +--echo # + +EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1; +SELECT row_number() over(), sum(1) FROM t1 where a=1; + +--echo # +--echo # Impossible HAVING +--echo # Empty result is expected +--echo # + +EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0; +SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0; + +--echo # +--echo # const table has 1 row, no impossible where +--echo # The expected result here is 1, 2 +--echo # + +EXPLAIN SELECT row_number() over(), sum(a) FROM t1 where a=2; +SELECT row_number() over(), sum(a) FROM t1 where a=2; +drop table t1; + +--echo # +--echo # Impossible Where +--echo # + +create table t1(a int); +insert into t1 values (1); + +--echo # +--echo # Expected result is NULL, 0, NULL +--echo # +EXPLAIN SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; +SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; + +--echo # +--echo # Expected result is 1, 0, NULL +--echo # + +EXPLAIN +SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; +SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE; + +drop table t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 2967377ad82..566437b2c32 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4636,6 +4636,8 @@ sub extract_warning_lines ($$) { qr/missing DBUG_RETURN/, qr/Attempting backtrace/, qr/Assertion .* failed/, + qr/Sanitizer/, + qr/runtime error:/, ); # These are taken from the include/mtr_warnings.sql global suppression # list. They occur delayed, so they can be parsed during shutdown rather diff --git a/mysql-test/suite/galera/r/galera_partition.result b/mysql-test/suite/galera/r/galera_partition.result index d845de12c45..c21d1005293 100644 --- a/mysql-test/suite/galera/r/galera_partition.result +++ b/mysql-test/suite/galera/r/galera_partition.result @@ -3,7 +3,6 @@ call mtr.add_suppression("WSREP: RSU failed due to pending transactions, schema: call mtr.add_suppression("WSREP: ALTER TABLE isolation failure"); connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4; -connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; connection node_1; CREATE TABLE t1( id bigint unsigned NOT NULL AUTO_INCREMENT, @@ -396,12 +395,13 @@ SELECT COUNT(*) FROM t1; COUNT(*) 350 connection node_2; -call p1(100);; -connection node_1a; +call mtr.add_suppression("WSREP: Sending JOIN failed:.*"); call p1(100);; connection node_3; +call mtr.add_suppression("WSREP: Sending JOIN failed:.*"); call p1(100);; connection node_4; +call mtr.add_suppression("WSREP: Sending JOIN failed:.*"); call p1(100);; connection node_1; SET SESSION wsrep_OSU_method='RSU'; @@ -419,6 +419,6 @@ TOI connection node_2; connection node_3; connection node_4; -connection node_1a; +connection node_1; DROP TABLE t1; DROP PROCEDURE p1; diff --git a/mysql-test/suite/galera/t/galera_partition.test b/mysql-test/suite/galera/t/galera_partition.test index a2044936cd1..66b2a5c10f6 100644 --- a/mysql-test/suite/galera/t/galera_partition.test +++ b/mysql-test/suite/galera/t/galera_partition.test @@ -8,7 +8,6 @@ call mtr.add_suppression("WSREP: ALTER TABLE isolation failure"); --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 --connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 ---connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 --connection node_1 @@ -407,15 +406,15 @@ insert into t1 (id, dt) values (350, '2010-12-17 00:00:00'); SELECT COUNT(*) FROM t1; --connection node_2 ---send call p1(100); - ---connection node_1a +call mtr.add_suppression("WSREP: Sending JOIN failed:.*"); --send call p1(100); --connection node_3 +call mtr.add_suppression("WSREP: Sending JOIN failed:.*"); --send call p1(100); --connection node_4 +call mtr.add_suppression("WSREP: Sending JOIN failed:.*"); --send call p1(100); --connection node_1 @@ -445,9 +444,7 @@ reap; --error 0,ER_LOCK_DEADLOCK reap; ---connection node_1a ---error 0,ER_LOCK_DEADLOCK -reap; +--connection node_1 DROP TABLE t1; DROP PROCEDURE p1; diff --git a/mysql-test/suite/wsrep/disabled.def b/mysql-test/suite/wsrep/disabled.def index 862056bc83b..f4145211680 100644 --- a/mysql-test/suite/wsrep/disabled.def +++ b/mysql-test/suite/wsrep/disabled.def @@ -10,5 +10,4 @@ # ############################################################################## -foreign_key : MENT-535 Galera test failures on wsrep suite -pool_of_threads : MENT-535 Galera test failures on wsrep suite + diff --git a/mysql-test/suite/wsrep/my.cnf b/mysql-test/suite/wsrep/my.cnf index 7e51b0750a1..f65306ffca5 100644 --- a/mysql-test/suite/wsrep/my.cnf +++ b/mysql-test/suite/wsrep/my.cnf @@ -1,10 +1,8 @@ # Use default setting for mysqld processes !include include/default_mysqld.cnf -[mysqld] -wsrep-on=1 - [mysqld.1] +wsrep-on=1 #galera_port=@OPT.port #ist_port=@OPT.port #sst_port=@OPT.port diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result index 9a0abd4460a..1e6ebbbd34d 100644 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result @@ -4,7 +4,7 @@ # Verbose run \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; @@ -36,7 +36,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -46,7 +46,7 @@ END IF| # Silent run \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; @@ -75,7 +75,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -93,7 +93,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, ; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; @@ -105,21 +105,21 @@ END IF| # \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=InnoDB; END IF| \d ; TRUNCATE TABLE time_zone_leap_second; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=MyISAM; END IF| \d ; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; \d | IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on') = 1 THEN +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; ALTER TABLE time_zone_transition ENGINE=MyISAM; diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result index 4ce57c641b3..85c4d858be2 100644 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result +++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result @@ -2,7 +2,7 @@ # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # # Verbose run -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); prepare set_wsrep_write_binlog from @prep1; set @toggle=0; execute set_wsrep_write_binlog using @toggle; TRUNCATE TABLE time_zone; @@ -29,7 +29,7 @@ Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid in ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; # Silent run -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); prepare set_wsrep_write_binlog from @prep1; set @toggle=0; execute set_wsrep_write_binlog using @toggle; TRUNCATE TABLE time_zone; @@ -55,7 +55,7 @@ ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; # # Testing with explicit timezonefile # -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); prepare set_wsrep_write_binlog from @prep1; set @toggle=0; execute set_wsrep_write_binlog using @toggle; INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); @@ -67,7 +67,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, # # Testing --leap # -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); prepare set_wsrep_write_binlog from @prep1; set @toggle=0; execute set_wsrep_write_binlog using @toggle; TRUNCATE TABLE time_zone_leap_second; diff --git a/mysql-test/suite/wsrep/t/alter_table_innodb.cnf b/mysql-test/suite/wsrep/t/alter_table_innodb.cnf new file mode 100644 index 00000000000..d8e27463cc1 --- /dev/null +++ b/mysql-test/suite/wsrep/t/alter_table_innodb.cnf @@ -0,0 +1,12 @@ +!include include/default_mysqld.cnf + +[mysqld] +wsrep-on=0 + +[mysqld.1] +wsrep-on=0 +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M' +wsrep_cluster_address='not empty but invalid' diff --git a/mysql-test/suite/wsrep/t/alter_table_innodb.opt b/mysql-test/suite/wsrep/t/alter_table_innodb.opt deleted file mode 100644 index 1e84570d7f6..00000000000 --- a/mysql-test/suite/wsrep/t/alter_table_innodb.opt +++ /dev/null @@ -1 +0,0 @@ ---wsrep-on=0 diff --git a/mysql-test/suite/wsrep/t/mdev_10186.cnf b/mysql-test/suite/wsrep/t/mdev_10186.cnf new file mode 100644 index 00000000000..284c887648e --- /dev/null +++ b/mysql-test/suite/wsrep/t/mdev_10186.cnf @@ -0,0 +1,15 @@ +!include include/default_mysqld.cnf + +[mysqld] +wsrep-on=0 + +[mysqld.1] +wsrep-on=0 +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M' +wsrep_cluster_address='not empty but invalid' +innodb_autoinc_lock_mode=2 +wsrep-provider=$WSREP_PROVIDER +wsrep-cluster-address=gcomm:// diff --git a/mysql-test/suite/wsrep/t/mdev_10186.opt b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.opt index e2655959c62..864f7342cc7 100644 --- a/mysql-test/suite/wsrep/t/mdev_10186.opt +++ b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.opt @@ -1 +1,3 @@ ---wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=0 +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --binlog_format=ROW + + diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test index 100e09d3afb..87554635666 100644 --- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test @@ -1,6 +1,7 @@ --source include/have_wsrep.inc --source include/have_symlink.inc --source include/not_windows.inc +--source include/have_innodb.inc --echo # --echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.opt b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.opt new file mode 100644 index 00000000000..864f7342cc7 --- /dev/null +++ b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.opt @@ -0,0 +1,3 @@ +--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep-on=1 --binlog_format=ROW + + diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test index bb3009bd432..ab1f94cc1cf 100644 --- a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test +++ b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test @@ -1,6 +1,7 @@ --source include/have_wsrep.inc --source include/have_symlink.inc --source include/not_windows.inc +--source include/have_innodb.inc --echo # --echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above diff --git a/mysql-test/suite/wsrep/t/pool_of_threads.opt b/mysql-test/suite/wsrep/t/pool_of_threads.opt index 6948011b21b..e75bba669e8 100644 --- a/mysql-test/suite/wsrep/t/pool_of_threads.opt +++ b/mysql-test/suite/wsrep/t/pool_of_threads.opt @@ -1 +1 @@ ---innodb_autoinc_lock_mode=2 --wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --thread_handling=pool-of-threads wsrep-on=1 +--innodb_autoinc_lock_mode=2 --wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --thread_handling=pool-of-threads --wsrep-on=1 diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 06d9f7187f3..e7e0c055f8e 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -406,15 +406,18 @@ IF(WIN32 AND TARGET mysqld AND NOT CMAKE_CROSSCOMPILING) ENDIF() MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep - COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} - -DTOP_SRCDIR="${CMAKE_SOURCE_DIR}" - -DBINDIR="${CMAKE_CURRENT_BINARY_DIR}" - -DMYSQLD_EXECUTABLE="$<TARGET_FILE:mysqld>" - -DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}" - -P ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake + OUTPUT initdb.dep + COMMAND ${CMAKE_COMMAND} -E remove_directory data + COMMAND ${CMAKE_COMMAND} -E make_directory data + COMMAND ${CMAKE_COMMAND} -E chdir data ${CMAKE_COMMAND} + ${CONFIG_PARAM} + -DTOP_SRCDIR="${CMAKE_SOURCE_DIR}" + -DBINDIR="${CMAKE_CURRENT_BINARY_DIR}" + -DMYSQLD_EXECUTABLE="$<TARGET_FILE:mysqld>" + -DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}" + -P ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DEPENDS mysqld ) ADD_CUSTOM_TARGET(initial_database diff --git a/sql/item.cc b/sql/item.cc index d1d1c349eed..f8f263037f7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3461,12 +3461,13 @@ bool Item_field::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) bool Item_field::get_date_result(MYSQL_TIME *ltime, ulonglong fuzzydate) { - if (result_field->is_null() || result_field->get_date(ltime,fuzzydate)) + if ((null_value= result_field->is_null()) || + result_field->get_date(ltime, fuzzydate)) { bzero((char*) ltime,sizeof(*ltime)); - return (null_value= 1); + return true; } - return (null_value= 0); + return false; } @@ -8404,7 +8405,7 @@ bool Item_ref::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) longlong Item_ref::val_datetime_packed() { DBUG_ASSERT(fixed); - longlong tmp= (*ref)->val_datetime_packed(); + longlong tmp= (*ref)->val_datetime_packed_result(); null_value= (*ref)->null_value; return tmp; } @@ -8413,7 +8414,7 @@ longlong Item_ref::val_datetime_packed() longlong Item_ref::val_time_packed() { DBUG_ASSERT(fixed); - longlong tmp= (*ref)->val_time_packed(); + longlong tmp= (*ref)->val_time_packed_result(); null_value= (*ref)->null_value; return tmp; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 06214918693..a560dbd7876 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1091,17 +1091,22 @@ longlong Item_func_yearweek::val_int() } -longlong Item_func_weekday::val_int() +static uint weekday_from_item(Item *item, bool *null_value, bool week_starts_on_sunday) { - DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - - if (get_arg0_date(<ime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE)) + if ((*null_value= Datetime(current_thd, item, + TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE). + copy_to_mysql_time(<ime, MYSQL_TIMESTAMP_DATETIME))) return 0; + return calc_weekday(calc_daynr(ltime.year, ltime.month, ltime.day), week_starts_on_sunday) + + MY_TEST(week_starts_on_sunday); +} - return (longlong) calc_weekday(calc_daynr(ltime.year, ltime.month, - ltime.day), - odbc_type) + MY_TEST(odbc_type); + +longlong Item_func_weekday::val_int() +{ + DBUG_ASSERT(fixed == 1); + return (longlong) weekday_from_item(args[0], &null_value, odbc_type); } bool Item_func_dayname::fix_length_and_dec() @@ -1120,7 +1125,7 @@ bool Item_func_dayname::fix_length_and_dec() String* Item_func_dayname::val_str(String* str) { DBUG_ASSERT(fixed == 1); - uint weekday=(uint) val_int(); // Always Item_func_weekday() + uint weekday= weekday_from_item(args[0], &null_value, false); const char *day_name; uint err; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 6373aa517ba..7450a94673d 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -426,20 +426,13 @@ public: }; -class Item_func_weekday :public Item_func +class Item_func_weekday :public Item_int_func { bool odbc_type; public: Item_func_weekday(THD *thd, Item *a, bool type_arg): - Item_func(thd, a), odbc_type(type_arg) { collation.set_numeric(); } + Item_int_func(thd, a), odbc_type(type_arg) { } longlong val_int(); - double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } - String *val_str(String *str) - { - DBUG_ASSERT(fixed == 1); - str->set(val_int(), &my_charset_bin); - return null_value ? 0 : str; - } const char *func_name() const { return (odbc_type ? "dayofweek" : "weekday"); @@ -466,11 +459,11 @@ public: { return get_item_copy<Item_func_weekday>(thd, this); } }; -class Item_func_dayname :public Item_func_weekday +class Item_func_dayname :public Item_str_func { MY_LOCALE *locale; public: - Item_func_dayname(THD *thd, Item *a): Item_func_weekday(thd, a, 0) {} + Item_func_dayname(THD *thd, Item *a): Item_str_func(thd, a) {} const char *func_name() const { return "dayname"; } String *val_str(String *str); const Type_handler *type_handler() const { return &type_handler_varchar; } @@ -480,6 +473,12 @@ class Item_func_dayname :public Item_func_weekday { return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC); } + bool check_valid_arguments_processor(void *int_arg) + { + return !has_date_args(); + } + Item *get_copy(THD *thd) + { return get_item_copy<Item_func_dayname>(thd, this); } }; diff --git a/sql/sql_audit.h b/sql/sql_audit.h index 59cced13b0a..97317203e34 100644 --- a/sql/sql_audit.h +++ b/sql/sql_audit.h @@ -284,7 +284,9 @@ void mysql_audit_notify_connection_change_user(THD *thd) } static inline -void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock) +void mysql_audit_external_lock_ex(THD *thd, my_thread_id thread_id, + const char *user, const char *host, const char *ip, query_id_t query_id, + TABLE_SHARE *share, int lock) { if (lock != F_UNLCK && mysql_audit_table_enabled()) { @@ -293,25 +295,33 @@ void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock) event.event_subclass= MYSQL_AUDIT_TABLE_LOCK; event.read_only= lock == F_RDLCK; - event.thread_id= (unsigned long)thd->thread_id; - event.user= sctx->user; + event.thread_id= (unsigned long)thread_id; + event.user= user; event.priv_user= sctx->priv_user; event.priv_host= sctx->priv_host; event.external_user= sctx->external_user; event.proxy_user= sctx->proxy_user; - event.host= sctx->host; - event.ip= sctx->ip; + event.host= host; + event.ip= ip; event.database= share->db; event.table= share->table_name; event.new_database= null_clex_str; event.new_table= null_clex_str; - event.query_id= thd->query_id; + event.query_id= query_id; mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event); } } static inline +void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock) +{ + mysql_audit_external_lock_ex(thd, thd->thread_id, thd->security_ctx->user, + thd->security_ctx->host, thd->security_ctx->ip, thd->query_id, + share, lock); +} + +static inline void mysql_audit_create_table(TABLE *table) { if (mysql_audit_table_enabled()) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0c01bcd4cb2..bbd639b91d3 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2171,36 +2171,16 @@ public: passed from connection thread to the handler thread. */ MDL_request grl_protection; - my_thread_id orig_thread_id; - void set_default_user() - { - thd.security_ctx->user=(char*) delayed_user; - thd.security_ctx->host=(char*) my_localhost; - thd.security_ctx->ip= NULL; - thd.query_id= 0; - thd.thread_id= orig_thread_id; - } - - void set_user_from_row(const delayed_row *r) - { - if (r) - { - thd.security_ctx->user= r->user; - thd.security_ctx->host= r->host; - thd.security_ctx->ip= r->ip; - thd.query_id= r->query_id; - thd.thread_id= r->thread_id; - } - } - Delayed_insert(SELECT_LEX *current_select) :locks_in_memory(0), thd(next_thread_id()), table(0),tables_in_use(0), stacked_inserts(0), status(0), retry(0), handler_thread_initialized(FALSE), group_count(0) { DBUG_ENTER("Delayed_insert constructor"); - orig_thread_id= thd.thread_id; - set_default_user(); + thd.security_ctx->user=(char*) delayed_user; + thd.security_ctx->host=(char*) my_localhost; + thd.security_ctx->ip= NULL; + thd.query_id= 0; strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user); thd.current_tablenr=0; thd.set_command(COM_DELAYED_INSERT); @@ -3178,7 +3158,6 @@ pthread_handler_t handle_delayed_insert(void *arg) if (di->tables_in_use && ! thd->lock && !thd->killed) { - di->set_user_from_row(di->rows.head()); /* Request for new delayed insert. Lock the table, but avoid to be blocked by a global read lock. @@ -3200,16 +3179,18 @@ pthread_handler_t handle_delayed_insert(void *arg) { delayed_row *row; I_List_iterator<delayed_row> it(di->rows); + my_thread_id cur_thd= di->thd.thread_id; + while ((row= it++)) { - if (di->thd.thread_id != row->thread_id) + if (cur_thd != row->thread_id) { - di->set_user_from_row(row); - mysql_audit_external_lock(&di->thd, di->table->s, F_WRLCK); + mysql_audit_external_lock_ex(&di->thd, row->thread_id, + row->user, row->host, row->ip, row->query_id, + di->table->s, F_WRLCK); + cur_thd= row->thread_id; } } - di->set_default_user(); - if (di->handle_inserts()) { /* Some fatal error */ diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 87eea6c0a8b..ea2ca10a444 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1522,28 +1522,6 @@ public: uint sroutines_list_own_elements; /** - Locking state of tables in this particular statement. - - If we under LOCK TABLES or in prelocked mode we consider tables - for the statement to be "locked" if there was a call to lock_tables() - (which called handler::start_stmt()) for tables of this statement - and there was no matching close_thread_tables() call. - - As result this state may differ significantly from one represented - by Open_tables_state::lock/locked_tables_mode more, which are always - "on" under LOCK TABLES or in prelocked mode. - */ - enum enum_lock_tables_state { - LTS_NOT_LOCKED = 0, - LTS_LOCKED - }; - enum_lock_tables_state lock_tables_state; - bool is_query_tables_locked() - { - return (lock_tables_state == LTS_LOCKED); - } - - /** Number of tables which were open by open_tables() and to be locked by lock_tables(). Note that we set this member only in some cases, when this value diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 275c46141cd..da8dfdd015a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1812,6 +1812,7 @@ JOIN::optimize_inner() zero_result_cause= "Zero limit"; } table_count= top_join_tab_count= 0; + handle_implicit_grouping_with_window_funcs(); error= 0; subq_exit_fl= true; goto setup_subq_exit; @@ -1859,6 +1860,7 @@ JOIN::optimize_inner() table_count= top_join_tab_count= 0; error=0; subq_exit_fl= true; + handle_implicit_grouping_with_window_funcs(); goto setup_subq_exit; } if (res > 1) @@ -1874,6 +1876,7 @@ JOIN::optimize_inner() tables_list= 0; // All tables resolved select_lex->min_max_opt_list.empty(); const_tables= top_join_tab_count= table_count; + handle_implicit_grouping_with_window_funcs(); /* Extract all table-independent conditions and replace the WHERE clause with them. All other conditions were computed by opt_sum_query @@ -2019,6 +2022,7 @@ int JOIN::optimize_stage2() zero_result_cause= "no matching row in const table"; DBUG_PRINT("error",("Error: %s", zero_result_cause)); error= 0; + handle_implicit_grouping_with_window_funcs(); goto setup_subq_exit; } if (!(thd->variables.option_bits & OPTION_BIG_SELECTS) && @@ -2050,6 +2054,7 @@ int JOIN::optimize_stage2() zero_result_cause= "Impossible WHERE noticed after reading const tables"; select_lex->mark_const_derived(zero_result_cause); + handle_implicit_grouping_with_window_funcs(); goto setup_subq_exit; } @@ -2195,6 +2200,7 @@ int JOIN::optimize_stage2() zero_result_cause= "Impossible WHERE noticed after reading const tables"; select_lex->mark_const_derived(zero_result_cause); + handle_implicit_grouping_with_window_funcs(); goto setup_subq_exit; } @@ -15024,7 +15030,7 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab, } } else if (cond->type() == Item::FUNC_ITEM && - ((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) + ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) { item_equal= (Item_equal *) cond; item_equal->sort(&compare_fields_by_table_order, table_join_idx); @@ -18946,7 +18952,8 @@ void set_postjoin_aggr_write_func(JOIN_TAB *tab) } } else if (join->sort_and_group && !tmp_tbl->precomputed_group_by && - !join->sort_and_group_aggr_tab && join->tables_list) + !join->sort_and_group_aggr_tab && join->tables_list && + join->top_join_tab_count) { DBUG_PRINT("info",("Using end_write_group")); aggr->set_write_func(end_write_group); @@ -24359,7 +24366,8 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, for (uint i= 0; (item= it++); i++) { Field *field; - if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) + if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) || + item->with_window_func) item_field= item; else if (item->type() == Item::FIELD_ITEM) { @@ -27751,6 +27759,28 @@ Item *remove_pushed_top_conjuncts(THD *thd, Item *cond) return cond; } +/* + There are 5 cases in which we shortcut the join optimization process as we + conclude that the join would be a degenerate one + 1) IMPOSSIBLE WHERE + 2) MIN/MAX optimization (@see opt_sum_query) + 3) EMPTY CONST TABLE + If a window function is present in any of the above cases then to get the + result of the window function, we need to execute it. So we need to + create a temporary table for its execution. Here we need to take in mind + that aggregate functions and non-aggregate function need not be executed. + +*/ + + +void JOIN::handle_implicit_grouping_with_window_funcs() +{ + if (select_lex->have_window_funcs() && send_row_on_empty_set()) + { + const_tables= top_join_tab_count= table_count= 0; + } +} + /** @} (end of group Query_Optimizer) */ diff --git a/sql/sql_select.h b/sql/sql_select.h index a63ce24bf3b..abcf9764009 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1103,6 +1103,7 @@ protected: Join_plan_state *save_to); /* Choose a subquery plan for a table-less subquery. */ bool choose_tableless_subquery_plan(); + void handle_implicit_grouping_with_window_funcs(); public: void save_query_plan(Join_plan_state *save_to); diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index be320788aa7..6531ce06360 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -1336,7 +1336,7 @@ void wait_begin(thread_group_t *thread_group) DBUG_ASSERT(thread_group->connection_count > 0); if ((thread_group->active_thread_count == 0) && - (is_queue_empty(thread_group) || !thread_group->listener)) + (!is_queue_empty(thread_group) || !thread_group->listener)) { /* Group might stall while this thread waits, thus wake diff --git a/sql/tztime.cc b/sql/tztime.cc index 3307f58818c..af9014d9d42 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2432,7 +2432,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) if (!opt_skip_write_binlog) printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n" "END IF|\n" "\\d ;\n"); @@ -2452,7 +2452,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) if (!opt_skip_write_binlog) printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone_leap_second ENGINE=MyISAM;\n" "END IF|\n" "\\d ;\n"); @@ -2709,7 +2709,7 @@ main(int argc, char **argv) sql_log_bin and wsrep_on to avoid Galera replicating below truncate table clauses. This will allow user to set different time zones to nodes in Galera cluster. */ - printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" + printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" "prepare set_wsrep_write_binlog from @prep1;\n" "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n"); @@ -2725,7 +2725,7 @@ main(int argc, char **argv) // to allow changes to them to replicate with Galera printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone ENGINE=InnoDB;\n" "ALTER TABLE time_zone_name ENGINE=InnoDB;\n" "ALTER TABLE time_zone_transition ENGINE=InnoDB;\n" @@ -2780,7 +2780,7 @@ main(int argc, char **argv) // Fall back to MyISAM printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone ENGINE=MyISAM;\n" "ALTER TABLE time_zone_name ENGINE=MyISAM;\n" "ALTER TABLE time_zone_transition ENGINE=MyISAM;\n" diff --git a/sql/unireg.cc b/sql/unireg.cc index 40fde228f80..5c691116d22 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -398,7 +398,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING *table, pos+= reclength; int2store(pos, create_info->connect_string.length); pos+= 2; - memcpy(pos, create_info->connect_string.str, create_info->connect_string.length); + if (create_info->connect_string.length) + memcpy(pos, create_info->connect_string.str, create_info->connect_string.length); pos+= create_info->connect_string.length; int2store(pos, str_db_type.length); pos+= 2; diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 199a8a3fa8b..17b9d9664c7 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -318,9 +318,6 @@ ENDIF(CONNECT_WITH_MONGO) OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON) IF(CONNECT_WITH_REST) - MESSAGE(STATUS "=====> REST support is ON") - SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h) - add_definitions(-DREST_SUPPORT) FIND_PACKAGE(cpprestsdk QUIET) IF (cpprestsdk_FOUND) IF(UNIX) @@ -334,12 +331,8 @@ IF(CONNECT_WITH_REST) # Comment it out if not needed depending on your cpprestsdk installation. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") ENDIF(UNIX) -# IF(REST_LIBRARY) why this? how about Windows - SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp) - add_definitions(-DREST_SOURCE) -# ENDIF() - ELSE(NOT cpprestsdk_FOUND) -# MESSAGE(STATUS "=====> cpprestsdk package not found") + SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h) + add_definitions(-DREST_SUPPORT) ENDIF (cpprestsdk_FOUND) ENDIF(CONNECT_WITH_REST) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 6b46cc7097b..6fc01a9491f 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -103,6 +103,7 @@ struct set_numa_interleave_t " policy to MPOL_INTERLEAVE: " << strerror(errno); } + numa_bitmask_free(numa_mems_allowed); } } @@ -130,29 +131,6 @@ struct set_numa_interleave_t #include "snappy-c.h" #endif -inline void* aligned_malloc(size_t size, size_t align) { - void *result; -#ifdef _MSC_VER - result = _aligned_malloc(size, align); -#elif defined (HAVE_POSIX_MEMALIGN) - if(posix_memalign(&result, align, size)) { - result = 0; - } -#else - /* Use unaligned malloc as fallback */ - result = malloc(size); -#endif - return result; -} - -inline void aligned_free(void *ptr) { -#ifdef _MSC_VER - _aligned_free(ptr); -#else - free(ptr); -#endif -} - /* IMPLEMENTATION OF THE BUFFER POOL ================================= @@ -1663,6 +1641,7 @@ buf_chunk_init( " buffer pool page frames to MPOL_INTERLEAVE" " (error: " << strerror(errno) << ")."; } + numa_bitmask_free(numa_mems_allowed); } #endif /* HAVE_LIBNUMA */ diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index c8b16c25b68..581be6a85c1 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -2345,49 +2345,6 @@ dict_replace_tablespace_in_dictionary( return(error); } -/** Delete records from SYS_TABLESPACES and SYS_DATAFILES associated -with a particular tablespace ID. -@param[in] space Tablespace ID -@param[in,out] trx Current transaction -@return DB_SUCCESS if OK, dberr_t if the operation failed */ - -dberr_t -dict_delete_tablespace_and_datafiles( - ulint space, - trx_t* trx) -{ - dberr_t err = DB_SUCCESS; - - ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_X)); - ut_ad(mutex_own(&dict_sys->mutex)); - ut_ad(srv_sys_tablespaces_open); - - trx->op_info = "delete tablespace and datafiles from dictionary"; - - pars_info_t* info = pars_info_create(); - ut_a(!is_system_tablespace(space)); - pars_info_add_int4_literal(info, "space", space); - - err = que_eval_sql(info, - "PROCEDURE P () IS\n" - "BEGIN\n" - "DELETE FROM SYS_TABLESPACES\n" - "WHERE SPACE = :space;\n" - "DELETE FROM SYS_DATAFILES\n" - "WHERE SPACE = :space;\n" - "END;\n", - FALSE, trx); - - if (err != DB_SUCCESS) { - ib::warn() << "Could not delete space_id " - << space << " from data dictionary"; - } - - trx->op_info = ""; - - return(err); -} - /** Assign a new table ID and put it into the table cache and the transaction. @param[in,out] table Table that needs an ID @param[in,out] trx Transaction */ diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index f04d3fe038f..c9529ee4b73 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -706,6 +706,27 @@ buf_page_is_corrupted( #endif MY_ATTRIBUTE((warn_unused_result)); +inline void *aligned_malloc(size_t size, size_t align) +{ +#ifdef _MSC_VER + return _aligned_malloc(size, align); +#else + void *result; + if (posix_memalign(&result, align, size)) + result= NULL; + return result; +#endif +} + +inline void aligned_free(void *ptr) +{ +#ifdef _MSC_VER + _aligned_free(ptr); +#else + free(ptr); +#endif +} + #ifndef UNIV_INNOCHECKSUM /**********************************************************************//** Gets the space id, page offset, and byte offset within page of a diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index df364401172..79ec1e5d80b 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -113,7 +113,17 @@ ulint buf_pool_get_n_pages(void) /*======================*/ { - return buf_pool_get_curr_size() >> srv_page_size_shift; + if (!buf_pool_ptr) + return buf_pool_get_curr_size() >> srv_page_size_shift; + + ulint chunk_size= 0; + for (uint i= 0; i < srv_buf_pool_instances; i++) + { + buf_pool_t* buf_pool = buf_pool_from_array(i); + for (uint j= 0; j < buf_pool->n_chunks; j++) + chunk_size+= buf_pool->chunks[j].size; + } + return chunk_size; } /********************************************************************//** diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 2a302dabae8..8ab987cd39a 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -224,16 +224,6 @@ dict_replace_tablespace_in_dictionary( const char* path, trx_t* trx); -/** Delete records from SYS_TABLESPACES and SYS_DATAFILES associated -with a particular tablespace ID. -@param[in] space Tablespace ID -@param[in,out] trx Current transaction -@return DB_SUCCESS if OK, dberr_t if the operation failed */ -dberr_t -dict_delete_tablespace_and_datafiles( - ulint space, - trx_t* trx); - /********************************************************************//** Add a foreign key definition to the data dictionary tables. @return error code or DB_SUCCESS */ diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index a4f8aab4e02..280f7840d50 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -119,14 +119,19 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn); /** Parse log records from a buffer and optionally store them to a hash table to wait merging to file pages. -@param[in] checkpoint_lsn the LSN of the latest checkpoint -@param[in] store whether to store page operations -@param[in] apply whether to apply the records +@param[in] checkpoint_lsn the LSN of the latest checkpoint +@param[in] store whether to store page operations +@param[in] available_memory memory to read the redo logs +@param[in] apply whether to apply the records @return whether MLOG_CHECKPOINT record was seen the first time, or corruption was noticed */ -bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply); +bool recv_parse_log_recs( + lsn_t checkpoint_lsn, + store_t* store, + ulint available_memory, + bool apply); -/** Moves the parsing buffer data left to the buffer start. */ +/** Moves the parsing buffer data left to the buffer start */ void recv_sys_justify_left_parsing_buf(); /** Report optimized DDL operation (without redo log), diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 9ff7327ba66..69582cf4267 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -660,6 +660,7 @@ page_rec_get_next_low( } ut_ad(page_rec_is_infimum(rec) + || (!page_is_leaf(page) && !page_has_prev(page)) || !(rec_get_info_bits(page + offs, comp) & REC_INFO_MIN_REC_FLAG)); diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake index c3698df4c11..8bfca3a614b 100644 --- a/storage/innobase/innodb.cmake +++ b/storage/innobase/innodb.cmake @@ -96,7 +96,8 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion") IF (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "i386") + CMAKE_SYSTEM_PROCESSOR MATCHES "i386" AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) INCLUDE(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-fno-builtin-memcmp" HAVE_NO_BUILTIN_MEMCMP) IF (HAVE_NO_BUILTIN_MEMCMP) @@ -152,11 +153,6 @@ IF(NOT MSVC) SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) ENDIF() - CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) - IF(HAVE_POSIX_MEMALIGN) - ADD_DEFINITIONS(-DHAVE_POSIX_MEMALIGN) - ENDIF() - # Only use futexes on Linux if GCC atomics are available IF(NOT MSVC AND NOT CMAKE_CROSSCOMPILING) CHECK_C_SOURCE_RUNS( diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index e8a890de406..862c5636c53 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -763,7 +763,6 @@ recv_sys_var_init(void) recv_previous_parsed_rec_type = MLOG_SINGLE_REC_FLAG; recv_previous_parsed_rec_offset = 0; recv_previous_parsed_rec_is_multi = 0; - recv_n_pool_free_frames = 256; recv_max_page_lsn = 0; } @@ -843,18 +842,14 @@ recv_sys_init() recv_sys->flush_end = os_event_create(0); } - ulint size = buf_pool_get_curr_size(); - /* Set appropriate value of recv_n_pool_free_frames. */ - if (size >= 10 << 20) { - /* Buffer pool of size greater than 10 MB. */ - recv_n_pool_free_frames = 512; - } + recv_n_pool_free_frames = + buf_pool_get_n_pages() / 3; recv_sys->buf = static_cast<byte*>( ut_malloc_dontdump(RECV_PARSING_BUF_SIZE)); recv_sys->buf_size = RECV_PARSING_BUF_SIZE; - recv_sys->addr_hash = hash_create(size / 512); + recv_sys->addr_hash = hash_create(buf_pool_get_curr_size() / 512); recv_sys->progress_time = time(NULL); recv_max_page_lsn = 0; @@ -2719,14 +2714,40 @@ recv_mlog_index_load(ulint space_id, ulint page_no, lsn_t lsn) } } +/** Check whether read redo log memory exceeds the available memory +of buffer pool. Store last_stored_lsn if it is not in last phase +@param[in] store whether to store page operations +@param[in] available_mem Available memory in buffer pool to + read redo logs. */ +static bool recv_sys_heap_check(store_t* store, ulint available_mem) +{ + if (*store != STORE_NO + && mem_heap_get_size(recv_sys->heap) >= available_mem) + { + if (*store == STORE_YES) + recv_sys->last_stored_lsn= recv_sys->recovered_lsn; + + *store= STORE_NO; + DBUG_PRINT("ib_log",("Ran out of memory and last " + "stored lsn " LSN_PF " last stored offset " + ULINTPF "\n",recv_sys->recovered_lsn, + recv_sys->recovered_offset)); + return true; + } + + return false; +} + /** Parse log records from a buffer and optionally store them to a hash table to wait merging to file pages. -@param[in] checkpoint_lsn the LSN of the latest checkpoint -@param[in] store whether to store page operations -@param[in] apply whether to apply the records +@param[in] checkpoint_lsn the LSN of the latest checkpoint +@param[in] store whether to store page operations +@param[in] available_mem memory to read the redo logs +@param[in] apply whether to apply the records @return whether MLOG_CHECKPOINT record was seen the first time, or corruption was noticed */ -bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply) +bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t* store, + ulint available_mem, bool apply) { byte* ptr; byte* end_ptr; @@ -2738,6 +2759,7 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply) ulint space; ulint page_no; byte* body; + const bool last_phase = (*store == STORE_IF_EXISTS); ut_ad(log_mutex_own()); ut_ad(mutex_own(&recv_sys->mutex)); @@ -2752,6 +2774,12 @@ loop: return(false); } + /* Check for memory overflow and ignore the parsing of remaining + redo log records if InnoDB ran out of memory */ + if (recv_sys_heap_check(store, available_mem) && last_phase) { + return false; + } + switch (*ptr) { case MLOG_CHECKPOINT: #ifdef UNIV_LOG_LSN_DEBUG @@ -2852,7 +2880,7 @@ loop: break; #endif /* UNIV_LOG_LSN_DEBUG */ default: - switch (store) { + switch (*store) { case STORE_NO: break; case STORE_IF_EXISTS: @@ -3036,7 +3064,7 @@ corrupted_log: recv_parse_or_apply_log_rec_body(). */ break; default: - switch (store) { + switch (*store) { case STORE_NO: break; case STORE_IF_EXISTS: @@ -3079,7 +3107,6 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn) if (!recv_sys->parse_start_lsn) { /* Cannot start parsing yet because no start point for it found */ - return(false); } @@ -3100,7 +3127,6 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn) } if (more_len == 0) { - return(false); } @@ -3135,8 +3161,9 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn) /** Moves the parsing buffer data left to the buffer start. */ void recv_sys_justify_left_parsing_buf() { - ut_memmove(recv_sys->buf, recv_sys->buf + recv_sys->recovered_offset, - recv_sys->len - recv_sys->recovered_offset); + memmove(recv_sys->buf, + recv_sys->buf + recv_sys->recovered_offset, + recv_sys->len - recv_sys->recovered_offset); recv_sys->len -= recv_sys->recovered_offset; @@ -3146,26 +3173,30 @@ void recv_sys_justify_left_parsing_buf() /** Scan redo log from a buffer and stores new log data to the parsing buffer. Parse and hash the log records if new data found. Apply log records automatically when the hash table becomes full. +@param[in] available_mem we let the hash table of recs to + grow to this size, at the maximum +@param[in,out] store_to_hash whether the records should be + stored to the hash table; this is + reset if just debug checking is + needed, or when the available_mem + runs out +@param[in] log_block log segment +@param[in] checkpoint_lsn latest checkpoint LSN +@param[in] start_lsn buffer start LSN +@param[in] end_lsn buffer end LSN +@param[in,out] contiguous_lsn it is known that all groups contain + contiguous log data upto this lsn +@param[out] group_scanned_lsn scanning succeeded upto this lsn @return true if not able to scan any more in this log group */ -static -bool -recv_scan_log_recs( -/*===============*/ - ulint available_memory,/*!< in: we let the hash table of recs - to grow to this size, at the maximum */ - store_t* store_to_hash, /*!< in,out: whether the records should be - stored to the hash table; this is reset - if just debug checking is needed, or - when the available_memory runs out */ - const byte* log_block, /*!< in: log segment */ - lsn_t checkpoint_lsn, /*!< in: latest checkpoint LSN */ - lsn_t start_lsn, /*!< in: buffer start LSN */ - lsn_t end_lsn, /*!< in: buffer end LSN */ - lsn_t* contiguous_lsn, /*!< in/out: it is known that all log - groups contain contiguous log data up - to this lsn */ - lsn_t* group_scanned_lsn)/*!< out: scanning succeeded up to - this lsn */ +static bool recv_scan_log_recs( + ulint available_mem, + store_t* store_to_hash, + const byte* log_block, + lsn_t checkpoint_lsn, + lsn_t start_lsn, + lsn_t end_lsn, + lsn_t* contiguous_lsn, + lsn_t* group_scanned_lsn) { lsn_t scanned_lsn = start_lsn; bool finished = false; @@ -3173,14 +3204,13 @@ recv_scan_log_recs( bool more_data = false; bool apply = recv_sys->mlog_checkpoint_lsn != 0; ulint recv_parsing_buf_size = RECV_PARSING_BUF_SIZE; - + const bool last_phase = (*store_to_hash == STORE_IF_EXISTS); ut_ad(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(end_lsn % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(end_lsn >= start_lsn + OS_FILE_LOG_BLOCK_SIZE); const byte* const log_end = log_block + ulint(end_lsn - start_lsn); - do { ut_ad(!finished); @@ -3291,6 +3321,13 @@ recv_scan_log_recs( = log_block_get_checkpoint_no(log_block); } + /* During last phase of scanning, there can be redo logs + left in recv_sys->buf to parse & store it in recv_sys->heap */ + if (last_phase + && recv_sys->recovered_lsn < recv_sys->scanned_lsn) { + more_data = true; + } + if (data_len < OS_FILE_LOG_BLOCK_SIZE) { /* Log data for this group ends here */ finished = true; @@ -3308,7 +3345,8 @@ recv_scan_log_recs( /* Try to parse more log records */ if (recv_parse_log_recs(checkpoint_lsn, - *store_to_hash, apply)) { + store_to_hash, available_mem, + apply)) { ut_ad(recv_sys->found_corrupt_log || recv_sys->found_corrupt_fs || recv_sys->mlog_checkpoint_lsn @@ -3317,22 +3355,18 @@ recv_scan_log_recs( goto func_exit; } - if (*store_to_hash != STORE_NO - && mem_heap_get_size(recv_sys->heap) > available_memory) { - - DBUG_PRINT("ib_log", ("Ran out of memory and last " - "stored lsn " LSN_PF, - recv_sys->recovered_lsn)); - - recv_sys->last_stored_lsn = recv_sys->recovered_lsn; - *store_to_hash = STORE_NO; - } + recv_sys_heap_check(store_to_hash, available_mem); if (recv_sys->recovered_offset > recv_parsing_buf_size / 4) { /* Move parsing buffer data to the buffer start */ - recv_sys_justify_left_parsing_buf(); } + + /* Need to re-parse the redo log which're stored + in recv_sys->buf */ + if (last_phase && *store_to_hash == STORE_NO) { + finished = false; + } } func_exit: @@ -3394,6 +3428,8 @@ recv_group_scan_log_recs( redo log records before we have finished the redo log scan. */ recv_apply_hashed_log_recs(false); + /* Rescan the redo logs from last stored lsn */ + end_lsn = recv_sys->recovered_lsn; } start_lsn = ut_uint64_align_down(end_lsn, diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc index 70f389436fa..60057880c18 100644 --- a/storage/innobase/os/os0proc.cc +++ b/storage/innobase/os/os0proc.cc @@ -157,6 +157,12 @@ os_mem_free_large( { ut_a(os_total_large_mem_allocated >= size); + // We could have manually poisoned that memory for ASAN. + // And we must unpoison it by ourself as specified in documentation + // for __asan_poison_memory_region() in sanitizer/asan_interface.h + // munmap() doesn't do it for us automatically. + UNIV_MEM_ALLOC(ptr, size); + #ifdef HAVE_LINUX_LARGE_PAGES if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) { my_atomic_addlint( diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 9551ad7f343..3a707d8c02b 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -257,7 +257,7 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/myrocks_hotbackup.py INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup COMPONENT rocksdb-engine) IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS -frtti) + SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS "-frtti -Wno-error") ENDIF() IF(MSVC) # RocksDB, the storage engine, overdoes "const" by adding diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index ba50e94c983..2fbc938ae00 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -471,5 +471,5 @@ list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/build_version.cc) ADD_CONVENIENCE_LIBRARY(rocksdblib ${SOURCES}) target_link_libraries(rocksdblib ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set_target_properties(rocksdblib PROPERTIES COMPILE_FLAGS "-fPIC -fno-builtin-memcmp -frtti") + set_target_properties(rocksdblib PROPERTIES COMPILE_FLAGS "-fPIC -fno-builtin-memcmp -frtti -Wno-error") endif() diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 91232a1e31f..17cb51ff8cb 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1598,7 +1598,8 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), int shift= 0, digits= 0, negative, addon; /* Skip leading spaces and tabs */ - for ( ; str < end && (*str == ' ' || *str == '\t') ; str++); + for ( ; str < end && my_isspace(&my_charset_latin1, *str) ; ) + str++; if (str >= end) goto ret_edom; diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 2311b4e5079..183829d7074 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -98,18 +98,25 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error) if (endptr) { end= *endptr; - while (s != end && (*s == ' ' || *s == '\t')) + /* Skip leading spaces */ + for ( ; s < end && my_isspace(&my_charset_latin1, *s) ; ) s++; + if (s == end) goto no_conv; } else { endptr= &dummy; /* Easier end test */ - while (*s == ' ' || *s == '\t') - s++; - if (!*s) - goto no_conv; + /* Skip leading spaces */ + for ( ; ; s++) + { + if (!*s) + goto no_conv; + if (!my_isspace(&my_charset_latin1, *s)) + break; + } + /* This number must be big to guard against a lot of pre-zeros */ end= s+65535; /* Can't be longer than this */ } diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index 1b1c9a5d592..509412c7623 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -126,6 +126,13 @@ UMask=007 # LOAD DATA INFILE you can enable PrivateTmp=true for a little more security. PrivateTmp=false +# Set an explicit Start and Stop timeout of 900 seconds (15 minutes!) +# this is the same value as used in SysV init scripts in the past +# Galera might need a longer timeout, check the KB if you want to change this: +# https://mariadb.com/kb/en/library/systemd/#configuring-the-systemd-service-timeout +TimeoutStartSec=900 +TimeoutStopSec=900 + ## ## Options previously available to be set via [mysqld_safe] ## that now needs to be set by systemd config files as mysqld_safe diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 185157a510d..fce35409db6 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -151,6 +151,13 @@ UMask=007 # LOAD DATA INFILE you can enable PrivateTmp=true for a little more security. PrivateTmp=false +# Set an explicit Start and Stop timeout of 900 seconds (15 minutes!) +# this is the same value as used in SysV init scripts in the past +# if you need a longer timeout, check the KB: +# https://mariadb.com/kb/en/library/systemd/#configuring-the-systemd-service-timeout +TimeoutStartSec=900 +TimeoutStopSec=900 + ## ## Options previously available to be set via [mysqld_safe] ## that now needs to be set by systemd config files as mysqld_safe |