summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-11-06 10:18:51 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-11-06 10:18:51 +0200
commit8688ef22c21b810e7d5d4732a3f73035eb171879 (patch)
treecbcea402e9c8039e5752c71e1193985406777f2d
parentd7a2401750bb29dfdb45929a536539b9f17b347f (diff)
parent4e99e67c4e8a04bd03cb0e7efc2ce0129af60c34 (diff)
downloadmariadb-git-8688ef22c21b810e7d5d4732a3f73035eb171879.tar.gz
Merge 10.1 to 10.2
-rw-r--r--extra/mariabackup/backup_copy.cc2
-rw-r--r--extra/mariabackup/changed_page_bitmap.cc2
-rw-r--r--include/heap.h2
-rw-r--r--mysql-test/r/selectivity.result57
-rw-r--r--mysql-test/r/selectivity_innodb.result57
-rw-r--r--mysql-test/suite/innodb_fts/r/innodb_fts_misc.result21
-rw-r--r--mysql-test/suite/innodb_fts/t/innodb_fts_misc.test24
-rw-r--r--mysql-test/suite/perfschema/r/misc.result16
-rw-r--r--mysql-test/suite/perfschema/t/misc.test48
-rw-r--r--mysql-test/t/selectivity.test29
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_table.cc8
-rw-r--r--storage/heap/_check.c27
-rw-r--r--storage/innobase/dict/dict0dict.cc6
-rw-r--r--storage/innobase/dict/dict0load.cc2
-rw-r--r--storage/xtradb/dict/dict0dict.cc6
-rw-r--r--storage/xtradb/dict/dict0load.cc2
-rw-r--r--support-files/CMakeLists.txt3
18 files changed, 257 insertions, 58 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index 1db5eb16a52..524177d7e33 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -479,7 +479,7 @@ struct datafile_cur_t {
{
memset(rel_path, 0, sizeof rel_path);
if (filename) {
- strncpy(abs_path, filename, sizeof abs_path);
+ strncpy(abs_path, filename, sizeof abs_path - 1);
abs_path[(sizeof abs_path) - 1] = 0;
} else {
abs_path[0] = '\0';
diff --git a/extra/mariabackup/changed_page_bitmap.cc b/extra/mariabackup/changed_page_bitmap.cc
index 373af9451f9..9891f711714 100644
--- a/extra/mariabackup/changed_page_bitmap.cc
+++ b/extra/mariabackup/changed_page_bitmap.cc
@@ -389,7 +389,7 @@ log_online_setup_bitmap_file_range(
bitmap_files->files[array_pos].seq_num = file_seq_num;
strncpy(bitmap_files->files[array_pos].name,
- bitmap_dir_file_info.name, FN_REFLEN);
+ bitmap_dir_file_info.name, FN_REFLEN - 1);
bitmap_files->files[array_pos].name[FN_REFLEN - 1]
= '\0';
bitmap_files->files[array_pos].start_lsn
diff --git a/include/heap.h b/include/heap.h
index d0c907a48b4..ca6efa48f1b 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -246,7 +246,7 @@ int hp_panic(enum ha_panic_function flag);
int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key,
key_part_map keypart_map, enum ha_rkey_function find_flag);
extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key);
-extern int heap_check_heap(HP_INFO *info, my_bool print_status);
+extern int heap_check_heap(const HP_INFO *info, my_bool print_status);
extern uchar *heap_position(HP_INFO *info);
/* The following is for programs that uses the old HEAP interface where
diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result
index 10ab981acc8..60fac392fa8 100644
--- a/mysql-test/r/selectivity.result
+++ b/mysql-test/r/selectivity.result
@@ -1758,5 +1758,62 @@ a
1991
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
+#
+# MDEV-20424: New default value for optimizer_use_condition-selectivity
+# leads to bad plan
+#
+create table t1(a int, b int, c int, d int, key(a,b));
+insert into t1 select 50,seq-1,seq-1,seq from seq_1_to_10;
+insert into t1 select seq-1,seq-1,seq-1,seq from seq_1_to_100 limit 90;
+create table t2(a int, b int, c int, primary key(a));
+insert into t2 select seq-1,seq-1,seq-1 from seq_1_to_100;
+create table t3(a int, b int, c int, primary key(a));
+insert into t3 select seq-1,seq-1,seq-1 from seq_1_to_100 limit 30;
+set optimizer_use_condition_selectivity=1;
+explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 10 NULL 9 100.00 Using index condition; Using where
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100
+select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+b a a b
+0 0 1 1
+1 1 2 2
+2 2 3 3
+3 3 4 4
+4 4 5 5
+5 5 6 6
+6 6 7 7
+7 7 8 8
+8 8 9 9
+9 9 10 10
+set optimizer_use_condition_selectivity=2;
+explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 10 NULL 9 9.00 Using index condition; Using where
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100
+select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+b a a b
+0 0 1 1
+1 1 2 2
+2 2 3 3
+3 3 4 4
+4 4 5 5
+5 5 6 6
+6 6 7 7
+7 7 8 8
+8 8 9 9
+9 9 10 10
+set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+drop table t1,t2,t3;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result
index b9b281c7dc4..0e629ab38c3 100644
--- a/mysql-test/r/selectivity_innodb.result
+++ b/mysql-test/r/selectivity_innodb.result
@@ -1768,6 +1768,63 @@ a
1991
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1;
+#
+# MDEV-20424: New default value for optimizer_use_condition-selectivity
+# leads to bad plan
+#
+create table t1(a int, b int, c int, d int, key(a,b));
+insert into t1 select 50,seq-1,seq-1,seq from seq_1_to_10;
+insert into t1 select seq-1,seq-1,seq-1,seq from seq_1_to_100 limit 90;
+create table t2(a int, b int, c int, primary key(a));
+insert into t2 select seq-1,seq-1,seq-1 from seq_1_to_100;
+create table t3(a int, b int, c int, primary key(a));
+insert into t3 select seq-1,seq-1,seq-1 from seq_1_to_100 limit 30;
+set optimizer_use_condition_selectivity=1;
+explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 10 NULL 11 100.00 Using index condition; Using where
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100
+select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+b a a b
+0 0 1 1
+1 1 2 2
+2 2 3 3
+3 3 4 4
+4 4 5 5
+5 5 6 6
+6 6 7 7
+7 7 8 8
+8 8 9 9
+9 9 10 10
+set optimizer_use_condition_selectivity=2;
+explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 10 NULL 11 11.00 Using index condition; Using where
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`c` and `test`.`t3`.`a` = `test`.`t1`.`d` and `test`.`t1`.`a` = 50 and `test`.`t1`.`b` <= 100
+select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+b a a b
+0 0 1 1
+1 1 2 2
+2 2 3 3
+3 3 4 4
+4 4 5 5
+5 5 6 6
+6 6 7 7
+7 7 8 8
+8 8 9 9
+9 9 10 10
+set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+drop table t1,t2,t3;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result
index 99ead1a5825..8c3c3b5be68 100644
--- a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result
+++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result
@@ -1,4 +1,3 @@
-drop table if exists t1;
CREATE TABLE t1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
a VARCHAR(200),
@@ -415,7 +414,6 @@ AGAINST ('"following database"@10' IN BOOLEAN MODE);
id
105
DROP TABLE t1;
-drop table if exists t50;
set names utf8;
"----------Test1---------"
create table t50 (s1 varchar(60) character set utf8 collate utf8_bin) engine = innodb;
@@ -670,9 +668,6 @@ s1
ŁŁŁŁ
LLLL
ŁŁŁŁ ŁŁŁŁ
-DROP TABLE if EXISTS t2;
-Warnings:
-Note 1051 Unknown table 'test.t2'
CREATE TABLE t2 (s1 VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_POLISH_CI) ENGINE = InnoDB;
CREATE FULLTEXT INDEX i ON t2 ( s1);
Warnings:
@@ -739,7 +734,12 @@ ALTER TABLE t2 DROP a;
SET @@autocommit=0;
CREATE FULLTEXT INDEX i ON t1 (char_column);
INSERT INTO t1 values (1,'aaa');
-"restart server..."
+CREATE TABLE mdev20987_1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB;
+CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100),
+FULLTEXT(f2),
+FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB;
+INSERT INTO mdev20987_1 VALUES(1);
+INSERT INTO mdev20987_2 VALUES(1, 'mariadb');
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
@@ -747,12 +747,8 @@ t2 CREATE TABLE `t2` (
PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
-SET @@autocommit=1;
-DROP TABLE t1, t2;
+DROP TABLE t1, t2, mdev20987_2, mdev20987_1;
"----------Test28---------"
-drop table if exists `fts_test`;
-Warnings:
-Note 1051 Unknown table 'test.fts_test'
create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb;
set session autocommit=0;
insert into `fts_test` values ('');
@@ -942,9 +938,6 @@ id title body
2 How To Use MySQL Well After you went through a ...
3 Optimizing MySQL In this tutorial we will show ...
DROP TABLE articles;
-drop table if exists t1;
-Warnings:
-Note 1051 Unknown table 'test.t1'
create table t1 (FTS_DOC_ID bigint unsigned auto_increment not null primary key,
title varchar(200),body text,fulltext(title,body)) engine=innodb;
insert into t1 set body='test';
diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test
index 90bbe02174f..5b11a418dab 100644
--- a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test
+++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test
@@ -7,10 +7,6 @@
let collation=UTF8_UNICODE_CI;
--source include/have_collation.inc
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
# Create FTS table
CREATE TABLE t1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
@@ -403,10 +399,6 @@ DROP TABLE t1;
#------------------------------------------------------------------------------
# More FTS test from peter's testing
#------------------------------------------------------------------------------
---disable_warnings
-drop table if exists t50;
---enable_warnings
-
set names utf8;
@@ -608,7 +600,6 @@ CREATE FULLTEXT INDEX i ON t1 (s1);
INSERT INTO t1 VALUES
('a'),('b'),('c'),('d'),('ŁŁŁŁ'),('LLLL'),(NULL),('ŁŁŁŁ ŁŁŁŁ'),('LLLLLLLL');
SELECT * FROM t1 WHERE MATCH(s1) AGAINST ('LLLL' COLLATE UTF8_UNICODE_520_CI);
-DROP TABLE if EXISTS t2;
CREATE TABLE t2 (s1 VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_POLISH_CI) ENGINE = InnoDB;
CREATE FULLTEXT INDEX i ON t2 ( s1);
INSERT INTO t2 VALUES
@@ -674,16 +665,19 @@ ALTER TABLE t2 DROP a;
SET @@autocommit=0;
CREATE FULLTEXT INDEX i ON t1 (char_column);
INSERT INTO t1 values (1,'aaa');
-echo "restart server...";
-# Restart the server
+
+CREATE TABLE mdev20987_1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB;
+CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100),
+ FULLTEXT(f2),
+ FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB;
+INSERT INTO mdev20987_1 VALUES(1);
+INSERT INTO mdev20987_2 VALUES(1, 'mariadb');
--source include/restart_mysqld.inc
SHOW CREATE TABLE t2;
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
-SET @@autocommit=1;
-DROP TABLE t1, t2;
+DROP TABLE t1, t2, mdev20987_2, mdev20987_1;
--echo "----------Test28---------"
-drop table if exists `fts_test`;
create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb;
set session autocommit=0;
insert into `fts_test` values ('');
@@ -872,8 +866,6 @@ DROP TABLE articles;
# Test for Bug 13940669 - 64901: INNODB: ASSERTION FAILURE IN
# THREAD 34387022112 IN FILE REM0CMP.CC LINE 5
-drop table if exists t1;
-
create table t1 (FTS_DOC_ID bigint unsigned auto_increment not null primary key,
title varchar(200),body text,fulltext(title,body)) engine=innodb;
diff --git a/mysql-test/suite/perfschema/r/misc.result b/mysql-test/suite/perfschema/r/misc.result
index 4c8fdca8e68..2e4d21d625a 100644
--- a/mysql-test/suite/perfschema/r/misc.result
+++ b/mysql-test/suite/perfschema/r/misc.result
@@ -134,3 +134,19 @@ truncate performance_schema.events_statements_history 0
select * from t1 3
insert into t1 select RAND()*10000 from t1 6
drop table t1;
+#
+# MDEV-17896 Assertion `pfs->get_refcount() > 0' failed
+# in release_table_share
+#
+SELECT COUNT(*)<@@performance_schema_max_table_instances FROM
+performance_schema.objects_summary_global_by_type WHERE OBJECT_TYPE='TABLE';
+COUNT(*)<@@performance_schema_max_table_instances
+1
+CREATE TABLE t0(a INT);
+SELECT * FROM t0;
+a
+DROP TEMPORARY TABLE IF EXISTS t0;
+Warnings:
+Note 1051 Unknown table 'test.t0'
+FLUSH TABLE t0;
+DROP TABLE t0;
diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test
index c9f7dc6bfc0..80ce64f0302 100644
--- a/mysql-test/suite/perfschema/t/misc.test
+++ b/mysql-test/suite/perfschema/t/misc.test
@@ -222,3 +222,51 @@ insert into t1 select RAND()*10000 from t1;
select sql_text, rows_examined from performance_schema.events_statements_history;
drop table t1;
+--echo #
+--echo # MDEV-17896 Assertion `pfs->get_refcount() > 0' failed
+--echo # in release_table_share
+--echo #
+
+# There must be at least one available slot in PFS table_share_array for
+# this test to be meaningful. If there are no free slots we must
+# restart mysqld, it is the only way to reset PFS table_share_array
+let $query= SELECT COUNT(*)<@@performance_schema_max_table_instances FROM
+ performance_schema.objects_summary_global_by_type WHERE OBJECT_TYPE='TABLE';
+
+let $free_slots_available= `$query`;
+
+if (!$free_slots_available)
+{
+ source include/restart_mysqld.inc;
+}
+eval $query;
+
+CREATE TABLE t0(a INT);
+
+# TABLE_SHARE must be cached in the table definition cache.
+SELECT * FROM t0;
+
+# Dropping t0 using DROP TEMPORARY frees up a slot in table_share_array,
+# but the persistent table is not correctly dropped, i.e. TABLE_SHARE::m_psi
+# still points to that slot in table_share_array.
+DROP TEMPORARY TABLE IF EXISTS t0;
+
+# Try re-using each and every slot in PFS table_share_array. If bug is
+# there, we re-use t0 slot.
+# The newly created table that re-uses the t0 slot ends up
+# resetting the PFS_table_share refcount.
+let $i= `SELECT @@performance_schema_max_table_instances`;
+disable_query_log;
+while ($i)
+{
+ # Memory engine is here to reduce disk IO
+ eval CREATE TABLE t$i(a INT) ENGINE=MEMORY;
+ eval DROP TABLE t$i;
+ dec $i;
+}
+enable_query_log;
+
+# FLUSH TABLE crashes the server when PFS_table_share is found with
+# an unexpected refcount.
+FLUSH TABLE t0;
+DROP TABLE t0;
diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test
index d3fafc2ae52..b145cd08d67 100644
--- a/mysql-test/t/selectivity.test
+++ b/mysql-test/t/selectivity.test
@@ -1211,6 +1211,35 @@ set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivit
DROP TABLE t1;
+--echo #
+--echo # MDEV-20424: New default value for optimizer_use_condition-selectivity
+--echo # leads to bad plan
+--echo #
+
+create table t1(a int, b int, c int, d int, key(a,b));
+insert into t1 select 50,seq-1,seq-1,seq from seq_1_to_10;
+insert into t1 select seq-1,seq-1,seq-1,seq from seq_1_to_100 limit 90;
+
+create table t2(a int, b int, c int, primary key(a));
+insert into t2 select seq-1,seq-1,seq-1 from seq_1_to_100;
+
+create table t3(a int, b int, c int, primary key(a));
+insert into t3 select seq-1,seq-1,seq-1 from seq_1_to_100 limit 30;
+
+let $query= select t1.b,t2.a,t3.a,t3.b from t1,t2,t3
+where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100;
+
+set optimizer_use_condition_selectivity=1;
+eval explain extended $query;
+eval $query;
+
+set optimizer_use_condition_selectivity=2;
+eval explain extended $query;
+eval $query;
+set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+
+drop table t1,t2,t3;
+
--echo # End of 10.1 tests
#
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f743e1f4c97..c450572c9bd 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8720,7 +8720,10 @@ prev_record_reads(const POSITION *positions, uint idx, table_map found_ref)
#max_nested_outer_joins=64-1) will not make it any more precise.
*/
if (pos->records_read)
+ {
found= COST_MULT(found, pos->records_read);
+ found*= pos->cond_selectivity;
+ }
}
}
return found;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1d135ca83f8..4ad68d9d03b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2389,6 +2389,13 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
ER_BAD_TABLE_ERROR,
ER_THD(thd, ER_BAD_TABLE_ERROR),
tbl_name.c_ptr_safe());
+
+ /*
+ Our job is done here. This statement was added to avoid executing
+ unnecessary code farther below which in some strange corner cases
+ caused the server to crash (see MDEV-17896).
+ */
+ goto log_query;
}
else
{
@@ -2497,6 +2504,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
mysql_audit_drop_table(thd, table);
}
+log_query:
if (!dont_log_query && !drop_temporary)
{
non_tmp_table_deleted= (if_exists ? TRUE : non_tmp_table_deleted);
diff --git a/storage/heap/_check.c b/storage/heap/_check.c
index 883e67046e7..1a640fa13da 100644
--- a/storage/heap/_check.c
+++ b/storage/heap/_check.c
@@ -18,10 +18,8 @@
#include "heapdef.h"
-static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records,
- ulong blength, my_bool print_status);
-static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records,
- my_bool print_status);
+static int check_one_key(HP_KEYDEF *, uint, ulong, ulong, my_bool);
+static int check_one_rb_key(const HP_INFO *, uint, ulong, my_bool);
/*
@@ -40,13 +38,13 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records,
1 error
*/
-int heap_check_heap(HP_INFO *info, my_bool print_status)
+int heap_check_heap(const HP_INFO *info, my_bool print_status)
{
int error;
uint key;
ulong records=0, deleted=0, pos, next_block;
HP_SHARE *share=info->s;
- HP_INFO save_info= *info; /* Needed because scan_init */
+ uchar *current_ptr= info->current_ptr;
DBUG_ENTER("heap_check_heap");
for (error=key= 0 ; key < share->keys ; key++)
@@ -65,7 +63,7 @@ int heap_check_heap(HP_INFO *info, my_bool print_status)
{
if (pos < next_block)
{
- info->current_ptr+= share->block.recbuffer;
+ current_ptr+= share->block.recbuffer;
}
else
{
@@ -77,9 +75,9 @@ int heap_check_heap(HP_INFO *info, my_bool print_status)
break; /* End of file */
}
}
- hp_find_record(info,pos);
+ current_ptr= hp_find_block(&share->block, pos);
- if (!info->current_ptr[share->visible])
+ if (!current_ptr[share->visible])
deleted++;
else
records++;
@@ -92,7 +90,6 @@ int heap_check_heap(HP_INFO *info, my_bool print_status)
deleted, (ulong) share->deleted));
error= 1;
}
- *info= save_info;
DBUG_RETURN(error);
}
@@ -165,7 +162,7 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records,
return error;
}
-static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records,
+static int check_one_rb_key(const HP_INFO *info, uint keynr, ulong records,
my_bool print_status)
{
HP_KEYDEF *keydef= info->s->keydef + keynr;
@@ -174,9 +171,11 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records,
uchar *key, *recpos;
uint key_length;
uint not_used[2];
+ TREE_ELEMENT **last_pos;
+ TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
- if ((key= tree_search_edge(&keydef->rb_tree, info->parents,
- &info->last_pos, offsetof(TREE_ELEMENT, left))))
+ if ((key= tree_search_edge(&keydef->rb_tree, parents,
+ &last_pos, offsetof(TREE_ELEMENT, left))))
{
do
{
@@ -191,7 +190,7 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records,
}
else
found++;
- key= tree_search_next(&keydef->rb_tree, &info->last_pos,
+ key= tree_search_next(&keydef->rb_tree, &last_pos,
offsetof(TREE_ELEMENT, left),
offsetof(TREE_ELEMENT, right));
} while (key);
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 08afaddcf8b..f9dc00f9dcd 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -1811,8 +1811,7 @@ dict_table_rename_in_cache(
/* The old table name in my_charset_filename is stored
in old_name_cs_filename */
- strncpy(old_name_cs_filename, old_name,
- MAX_FULL_NAME_LEN);
+ strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0';
if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) {
@@ -1834,8 +1833,7 @@ dict_table_rename_in_cache(
} else {
/* Old name already in
my_charset_filename */
- strncpy(old_name_cs_filename, old_name,
- MAX_FULL_NAME_LEN);
+ strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN]
= '\0';
}
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index 06432f091f5..8ed947f04cf 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -3122,7 +3122,7 @@ func_exit:
fts_free(table);
} else if (fts_optimize_wq) {
fts_optimize_add_table(table);
- } else {
+ } else if (table->can_be_evicted) {
/* fts_optimize_thread is not started yet.
So make the table as non-evictable from cache. */
dict_table_move_from_lru_to_non_lru(table);
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 73e4fe6bb5b..2bea154749f 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -1856,8 +1856,7 @@ dict_table_rename_in_cache(
/* The old table name in my_charset_filename is stored
in old_name_cs_filename */
- strncpy(old_name_cs_filename, old_name,
- MAX_FULL_NAME_LEN);
+ strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0';
if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) {
@@ -1879,8 +1878,7 @@ dict_table_rename_in_cache(
} else {
/* Old name already in
my_charset_filename */
- strncpy(old_name_cs_filename, old_name,
- MAX_FULL_NAME_LEN);
+ strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN]
= '\0';
}
diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc
index 750116ac91e..b3a2932109c 100644
--- a/storage/xtradb/dict/dict0load.cc
+++ b/storage/xtradb/dict/dict0load.cc
@@ -2573,7 +2573,7 @@ func_exit:
fts_free(table);
} else if (fts_optimize_wq) {
fts_optimize_add_table(table);
- } else {
+ } else if (table->can_be_evicted) {
/* fts_optimize_thread is not started yet.
So make the table as non-evictable from cache. */
dict_table_move_from_lru_to_non_lru(table);
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
index 9fb045c0657..6ab84b59b29 100644
--- a/support-files/CMakeLists.txt
+++ b/support-files/CMakeLists.txt
@@ -77,11 +77,12 @@ IF(UNIX)
IF(CHECKMODULE AND SEMODULE_PACKAGE)
FOREACH(pol mariadb)
SET(src ${CMAKE_CURRENT_SOURCE_DIR}/policy/selinux/${pol}.te)
- SET(tmp ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod)
+ SET(tmp ${CMAKE_CURRENT_BINARY_DIR}/${pol}.mod)
SET(out ${CMAKE_CURRENT_BINARY_DIR}/${pol}.pp)
ADD_CUSTOM_COMMAND(OUTPUT ${out}
COMMAND ${CHECKMODULE} -M -m ${src} -o ${tmp}
COMMAND ${SEMODULE_PACKAGE} -m ${tmp} -o ${out}
+ COMMAND ${CMAKE_COMMAND} -E remove ${tmp}
DEPENDS ${src})
ADD_CUSTOM_TARGET(${pol}-pp ALL DEPENDS ${out})
INSTALL(FILES ${out} DESTINATION ${inst_location}/policy/selinux COMPONENT SupportFiles)