Skip to content

Commit 732cd7f

Browse files
committed
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.
1 parent eb38b1f commit 732cd7f

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

mysql-test/suite/innodb/r/truncate.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ TRUNCATE t1;
3939
SELECT * FROM t1;
4040
a
4141
DROP TEMPORARY TABLE t1;
42+
#
43+
# MDEV-23705 Assertion 'table->data_dir_path || !space'
44+
#
45+
CREATE TABLE t(c INT) ENGINE=InnoDB;
46+
ALTER TABLE t DISCARD TABLESPACE;
47+
RENAME TABLE t TO u;
48+
TRUNCATE u;
49+
Warnings:
50+
Warning 1814 Tablespace has been discarded for table `u`
51+
TRUNCATE u;
52+
DROP TABLE u;

mysql-test/suite/innodb/t/truncate.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,13 @@ INSERT INTO t1 VALUES(1);
5050
TRUNCATE t1;
5151
SELECT * FROM t1;
5252
DROP TEMPORARY TABLE t1;
53+
54+
--echo #
55+
--echo # MDEV-23705 Assertion 'table->data_dir_path || !space'
56+
--echo #
57+
CREATE TABLE t(c INT) ENGINE=InnoDB;
58+
ALTER TABLE t DISCARD TABLESPACE;
59+
RENAME TABLE t TO u;
60+
TRUNCATE u;
61+
TRUNCATE u;
62+
DROP TABLE u;

storage/innobase/dict/dict0load.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,8 @@ dict_get_and_save_data_dir_path(
27392739
{
27402740
ut_ad(!dict_table_is_temporary(table));
27412741

2742-
if (!table->data_dir_path && table->space) {
2742+
if (!table->data_dir_path && table->space
2743+
&& !dict_table_is_discarded(table)) {
27432744
char* path = fil_space_get_first_path(table->space);
27442745

27452746
if (!dict_mutex_own) {

0 commit comments

Comments
 (0)