summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-09-22 11:13:51 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-09-22 11:13:51 +0300
commit732cd7fd5346885ae41293d7ebe44110188155d4 (patch)
tree52a161540ede1190904eabeea00f6caa44dd1f2f
parenteb38b1f703fb84299680f9c5a75ea970be7aee1d (diff)
downloadmariadb-git-732cd7fd5346885ae41293d7ebe44110188155d4.tar.gz
MDEV-23705 Assertion 'table->data_dir_path || !space'
After DISCARD TABLESPACE, the tablespace of a table will no longer exist, and dict_get_and_save_data_dir_path() would invoke dict_get_first_path() to read an entry from SYS_DATAFILES. For some reason, DISCARD TABLESPACE would not to remove the entry from there. dict_get_and_save_data_dir_path(): If the tablespace has been discarded, do not bother trying to read the name. Side note: The tables SYS_TABLESPACES and SYS_DATAFILES are redundant and subject to removal in MDEV-22343.
-rw-r--r--mysql-test/suite/innodb/r/truncate.result11
-rw-r--r--mysql-test/suite/innodb/t/truncate.test10
-rw-r--r--storage/innobase/dict/dict0load.cc3
3 files changed, 23 insertions, 1 deletions
diff --git a/mysql-test/suite/innodb/r/truncate.result b/mysql-test/suite/innodb/r/truncate.result
index 5e9fd60d4fe..571aa2da1c5 100644
--- a/mysql-test/suite/innodb/r/truncate.result
+++ b/mysql-test/suite/innodb/r/truncate.result
@@ -39,3 +39,14 @@ TRUNCATE t1;
SELECT * FROM t1;
a
DROP TEMPORARY TABLE t1;
+#
+# MDEV-23705 Assertion 'table->data_dir_path || !space'
+#
+CREATE TABLE t(c INT) ENGINE=InnoDB;
+ALTER TABLE t DISCARD TABLESPACE;
+RENAME TABLE t TO u;
+TRUNCATE u;
+Warnings:
+Warning 1814 Tablespace has been discarded for table `u`
+TRUNCATE u;
+DROP TABLE u;
diff --git a/mysql-test/suite/innodb/t/truncate.test b/mysql-test/suite/innodb/t/truncate.test
index cd1d827e157..ca9ccb677e9 100644
--- a/mysql-test/suite/innodb/t/truncate.test
+++ b/mysql-test/suite/innodb/t/truncate.test
@@ -50,3 +50,13 @@ INSERT INTO t1 VALUES(1);
TRUNCATE t1;
SELECT * FROM t1;
DROP TEMPORARY TABLE t1;
+
+--echo #
+--echo # MDEV-23705 Assertion 'table->data_dir_path || !space'
+--echo #
+CREATE TABLE t(c INT) ENGINE=InnoDB;
+ALTER TABLE t DISCARD TABLESPACE;
+RENAME TABLE t TO u;
+TRUNCATE u;
+TRUNCATE u;
+DROP TABLE u;
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index 4014d28c2fb..af14c6a4770 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -2739,7 +2739,8 @@ dict_get_and_save_data_dir_path(
{
ut_ad(!dict_table_is_temporary(table));
- if (!table->data_dir_path && table->space) {
+ if (!table->data_dir_path && table->space
+ && !dict_table_is_discarded(table)) {
char* path = fil_space_get_first_path(table->space);
if (!dict_mutex_own) {