3919 kevin.lewis@stripped 2012-06-29 [merge]
Merge from mysql-5.6
modified:
mysql-test/suite/innodb/r/innodb-multiple-tablespaces.result
mysql-test/suite/innodb/r/innodb-wl5980-discard.result
mysql-test/suite/innodb/t/innodb-multiple-tablespaces.test
mysql-test/suite/innodb/t/innodb-wl5980-discard.test
storage/innobase/dict/dict0load.cc
storage/innobase/fil/fil0fil.cc
storage/innobase/handler/ha_innodb.cc
storage/innobase/row/row0merge.cc
storage/innobase/row/row0mysql.cc
3918 Yasufumi Kinoshita 2012-06-29 [merge]
Bug#14106082 : INNODB.INNODB_BUFFER_POOL_LOAD HANGS AT SHUTDOWN
rb#1115 approved by Inaam
Bug#14251529 : FIX FOR BUG 13704145 CREATES POSSIBLE RACE CONDITION
make buf_read_page_low() to treat DB_TABLESPACE_DELETED error correctly
rb#1129 approved by Inaam
modified:
storage/innobase/buf/buf0buf.cc
storage/innobase/buf/buf0lru.cc
storage/innobase/buf/buf0rea.cc
storage/innobase/include/buf0buf.h
=== modified file 'mysql-test/suite/innodb/r/innodb-multiple-tablespaces.result'
--- a/mysql-test/suite/innodb/r/innodb-multiple-tablespaces.result revid:yasufumi.kinoshita@stripped
+++ b/mysql-test/suite/innodb/r/innodb-multiple-tablespaces.result revid:kevin.lewis@stripped
@@ -349,7 +349,6 @@ wny.ibd
www.ibd
wyn.ibd
yny.ibd
-ywn.isl
yyn.ibd
yyy.ibd
---- MYSQL_TMP_DIR/alt_dir/test
@@ -367,7 +366,7 @@ ynw.ibd
yny.ibd
yyy.ibd
#
-# List of files after removing unused files
+# List of files after removing leftover files
#
---- MYSQLD_DATADIR/test
---- MYSQL_TMP_DIR/alt_dir/test
@@ -655,8 +654,6 @@ DROP TABLE wy;
# List of files after DROP TABLES
#
---- MYSQLD_DATADIR/test
-yn.isl
-yw.isl
---- MYSQL_TMP_DIR/alt_dir/test
aa.ibd.bak
#
=== modified file 'mysql-test/suite/innodb/r/innodb-wl5980-discard.result'
--- a/mysql-test/suite/innodb/r/innodb-wl5980-discard.result revid:yasufumi.kinoshita@stripped
+++ b/mysql-test/suite/innodb/r/innodb-wl5980-discard.result revid:kevin.lewis@stripped
@@ -119,7 +119,6 @@ SELECT * FROM t5980;
ERROR HY000: Tablespace has been discarded for table 't5980'
### files in MYSQL_DATA_DIR/test
t5980.frm
-t5980.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t5980.cfg.bak
t5980.cfg.bak2
@@ -310,7 +309,6 @@ SELECT * FROM t5980;
ERROR HY000: Tablespace has been discarded for table 't5980'
### files in MYSQL_DATA_DIR/test
t5980.frm
-t5980.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t5980.cfg.bak
t5980.cfg.bak2
@@ -321,7 +319,6 @@ t5980.ibd.bak2
#
### files in MYSQL_DATA_DIR/test
t5980.frm
-t5980.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t5980.cfg
t5980.cfg.bak
@@ -361,7 +358,6 @@ SELECT * FROM t5980;
ERROR HY000: Tablespace has been discarded for table 't5980'
### files in MYSQL_DATA_DIR/test
t5980.frm
-t5980.isl
### files in MYSQL_TMP_DIR/alt_dir/test
t5980.cfg.bak
t5980.cfg.bak2
@@ -463,9 +459,450 @@ SELECT path FROM information_schema.inno
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alt_dir/test/t5980.ibd
+DROP TABLE t5980;
#
-# Cleanup
+# Create a local and remote tablespaces, discard two and make
+# the other two missing upon restart, and try some DDL and DML
+# on these discarded and missing tablespaces.
#
-DROP TABLE t5980;
+SET GLOBAL innodb_file_per_table=ON;
+CREATE TABLE t5980a (a int, b text) engine=InnoDB;
+CREATE TABLE t5980b (a int, b text) engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir';
+CREATE TABLE t5980c (a int, b text) engine=InnoDB;
+CREATE TABLE t5980d (a int, b text) engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir';
+INSERT INTO t5980a VALUES (1, "Default location, discarded.");
+INSERT INTO t5980b VALUES (1, "Remote location, discarded");
+INSERT INTO t5980c VALUES (1, "Default location, missing");
+INSERT INTO t5980d VALUES (1, "Remote location, missing");
+SELECT * FROM t5980a;
+a b
+1 Default location, discarded.
+SELECT * FROM t5980b;
+a b
+1 Remote location, discarded
+SELECT * FROM t5980c;
+a b
+1 Default location, missing
+SELECT * FROM t5980d;
+a b
+1 Remote location, missing
+SHOW CREATE TABLE t5980a;
+Table Create Table
+t5980a CREATE TABLE `t5980a` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t5980b;
+Table Create Table
+t5980b CREATE TABLE `t5980b` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
+SHOW CREATE TABLE t5980c;
+Table Create Table
+t5980c CREATE TABLE `t5980c` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t5980d;
+Table Create Table
+t5980d CREATE TABLE `t5980d` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test%' ORDER BY name;
+name n_cols file_format row_format
+test/t5980a 5 Antelope Compact
+test/t5980b 5 Antelope Compact
+test/t5980c 5 Antelope Compact
+test/t5980d 5 Antelope Compact
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+WHERE name LIKE 'test%' ORDER BY space;
+name file_format row_format
+test/t5980a Antelope Compact or Redundant
+test/t5980b Antelope Compact or Redundant
+test/t5980c Antelope Compact or Redundant
+test/t5980d Antelope Compact or Redundant
+SELECT path FROM information_schema.innodb_sys_datafiles
+WHERE path LIKE '%test%' ORDER BY space;
+path
+MYSQL_DATA_DIR/test/t5980a.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980b.ibd
+MYSQL_DATA_DIR/test/t5980c.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980d.ibd
+### files in MYSQL_DATA_DIR/test
+t5980a.frm
+t5980a.ibd
+t5980b.frm
+t5980b.isl
+t5980c.frm
+t5980c.ibd
+t5980d.frm
+t5980d.isl
+### files in MYSQL_TMP_DIR/alt_dir/test
+t5980b.ibd
+t5980d.ibd
+#
+# Shutdown the server, remove two tablespaces, restart server.
+#
+FLUSH TABLES t5980a, t5980b FOR EXPORT;
+UNLOCK TABLES;
+ALTER TABLE t5980a DISCARD TABLESPACE;
+ALTER TABLE t5980b DISCARD TABLESPACE;
+### files in MYSQL_DATA_DIR/test
+t5980a.frm
+t5980b.frm
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+SELECT * FROM t5980a;
+ERROR HY000: Tablespace has been discarded for table 't5980a'
+SELECT * FROM t5980b;
+ERROR HY000: Tablespace has been discarded for table 't5980b'
+SELECT * FROM t5980c;
+ERROR 42S02: Table 'test.t5980c' doesn't exist
+SELECT * FROM t5980d;
+ERROR 42S02: Table 'test.t5980d' doesn't exist
+SHOW CREATE TABLE t5980a;
+Table Create Table
+t5980a CREATE TABLE `t5980a` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t5980b;
+Table Create Table
+t5980b CREATE TABLE `t5980b` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
+SHOW CREATE TABLE t5980c;
+ERROR 42S02: Table 'test.t5980c' doesn't exist
+SHOW CREATE TABLE t5980d;
+ERROR 42S02: Table 'test.t5980d' doesn't exist
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test%' ORDER BY name;
+name n_cols file_format row_format
+test/t5980a 5 Antelope Compact
+test/t5980b 5 Antelope Compact
+test/t5980c 5 Antelope Compact
+test/t5980d 5 Antelope Compact
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+WHERE name LIKE 'test%' ORDER BY space;
+name file_format row_format
+test/t5980a Antelope Compact or Redundant
+test/t5980b Antelope Compact or Redundant
+test/t5980c Antelope Compact or Redundant
+test/t5980d Antelope Compact or Redundant
+SELECT path FROM information_schema.innodb_sys_datafiles
+WHERE path LIKE '%test%' ORDER BY space;
+path
+MYSQL_DATA_DIR/test/t5980a.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980b.ibd
+MYSQL_DATA_DIR/test/t5980c.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980d.ibd
+### files in MYSQL_DATA_DIR/test
+t5980a.frm
+t5980b.frm
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+#
+# Discarded and missing tablespaces cannot be TRUNCATED
+#
+TRUNCATE TABLE t5980a;
+ERROR HY000: Tablespace has been discarded for table 't5980a'
+TRUNCATE TABLE t5980b;
+ERROR HY000: Tablespace has been discarded for table 't5980b'
+TRUNCATE TABLE t5980c;
+ERROR 42S02: Table 'test.t5980c' doesn't exist
+TRUNCATE TABLE t5980d;
+ERROR 42S02: Table 'test.t5980d' doesn't exist
+#
+# Discarded tablespaces can be RENAMED but they remain discarded
+#
+RENAME TABLE t5980a TO t5980aa;
+RENAME TABLE t5980b TO t5980bb;
+#
+# Missing tablespaces cannot be RENAMED
+#
+RENAME TABLE t5980c TO t5980cc;
+ERROR HY000: Error on rename of './test/t5980c' to './test/t5980cc' (errno: 155 - The table does not exist in engine)
+RENAME TABLE t5980d TO t5980dd;
+ERROR HY000: Error on rename of './test/t5980d' to './test/t5980dd' (errno: 155 - The table does not exist in engine)
+SELECT * FROM t5980a;
+ERROR 42S02: Table 'test.t5980a' doesn't exist
+SELECT * FROM t5980b;
+ERROR 42S02: Table 'test.t5980b' doesn't exist
+SELECT * FROM t5980aa;
+ERROR HY000: Tablespace has been discarded for table 't5980aa'
+SELECT * FROM t5980bb;
+ERROR HY000: Tablespace has been discarded for table 't5980bb'
+SELECT * FROM t5980c;
+ERROR 42S02: Table 'test.t5980c' doesn't exist
+SELECT * FROM t5980d;
+ERROR 42S02: Table 'test.t5980d' doesn't exist
+SHOW CREATE TABLE t5980aa;
+Table Create Table
+t5980aa CREATE TABLE `t5980aa` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t5980bb;
+Table Create Table
+t5980bb CREATE TABLE `t5980bb` (
+ `a` int(11) DEFAULT NULL,
+ `b` text
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
+SHOW CREATE TABLE t5980c;
+ERROR 42S02: Table 'test.t5980c' doesn't exist
+SHOW CREATE TABLE t5980d;
+ERROR 42S02: Table 'test.t5980d' doesn't exist
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test%' ORDER BY name;
+name n_cols file_format row_format
+test/t5980aa 5 Antelope Compact
+test/t5980bb 5 Antelope Compact
+test/t5980c 5 Antelope Compact
+test/t5980d 5 Antelope Compact
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+WHERE name LIKE 'test%' ORDER BY space;
+name file_format row_format
+test/t5980a Antelope Compact or Redundant
+test/t5980b Antelope Compact or Redundant
+test/t5980c Antelope Compact or Redundant
+test/t5980d Antelope Compact or Redundant
+SELECT path FROM information_schema.innodb_sys_datafiles
+WHERE path LIKE '%test%' ORDER BY space;
+path
+MYSQL_DATA_DIR/test/t5980a.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980b.ibd
+MYSQL_DATA_DIR/test/t5980c.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980d.ibd
+#
+# Discarded tablespaces cannot be ALTERED with ALGORITHM=COPY.
+#
+ALTER TABLE t5980aa ADD PRIMARY KEY(a), ALGORITHM=COPY;
+ERROR HY000: Tablespace has been discarded for table 't5980aa'
+ALTER TABLE t5980bb ADD PRIMARY KEY(a), ALGORITHM=COPY;
+ERROR HY000: Tablespace has been discarded for table 't5980bb'
+#
+# Discarded tablespaces can be ALTERED with ALGORITHM=INPLACE.
+#
+ALTER TABLE t5980aa ADD PRIMARY KEY(a), ALGORITHM=INPLACE;
+ALTER TABLE t5980bb ADD PRIMARY KEY(a), ALGORITHM=INPLACE;
+### files in MYSQL_DATA_DIR/test
+t5980aa.frm
+t5980aa.ibd
+t5980bb.frm
+t5980bb.isl
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+t5980bb.ibd
+#
+# Missing tablespaces cannot be ALTERED.
+#
+ALTER TABLE t5980c ADD PRIMARY KEY(a);
+ERROR 42S02: Table 'test.t5980c' doesn't exist
+ALTER TABLE t5980d ADD PRIMARY KEY(a);
+ERROR 42S02: Table 'test.t5980d' doesn't exist
+SELECT * FROM t5980aa;
+a b
+SELECT * FROM t5980bb;
+a b
+SHOW CREATE TABLE t5980aa;
+Table Create Table
+t5980aa CREATE TABLE `t5980aa` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` text,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t5980bb;
+Table Create Table
+t5980bb CREATE TABLE `t5980bb` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` text,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test%' ORDER BY name;
+name n_cols file_format row_format
+test/t5980aa 5 Antelope Compact
+test/t5980bb 5 Antelope Compact
+test/t5980c 5 Antelope Compact
+test/t5980d 5 Antelope Compact
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+WHERE name LIKE 'test%' ORDER BY space;
+name file_format row_format
+test/t5980c Antelope Compact or Redundant
+test/t5980d Antelope Compact or Redundant
+test/t5980aa Antelope Compact or Redundant
+test/t5980bb Antelope Compact or Redundant
+SELECT path FROM information_schema.innodb_sys_datafiles
+WHERE path LIKE '%test%' ORDER BY space;
+path
+MYSQL_DATA_DIR/test/t5980c.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980d.ibd
+MYSQL_DATA_DIR/test/t5980aa.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980bb.ibd
+### files in MYSQL_DATA_DIR/test
+t5980aa.frm
+t5980aa.ibd
+t5980bb.frm
+t5980bb.isl
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+t5980bb.ibd
+#
+# Discarded tablespaces that were ALTERED IN_PLACE are no longer discarded.
+#
+INSERT INTO t5980aa VALUES (1, "Inserted into Discarded Local tablespace after ALTER ADD PRIMARY KEY, ALGORITHM=INPLACE");
+INSERT INTO t5980bb VALUES (1, "Inserted into Discarded Local tablespace after ALTER ADD PRIMARY KEY, ALGORITHM=INPLACE");
+SELECT * FROM t5980aa;
+a b
+1 Inserted into Discarded Local tablespace after ALTER ADD PRIMARY KEY, ALGORITHM=INPLACE
+SELECT * FROM t5980bb;
+a b
+1 Inserted into Discarded Local tablespace after ALTER ADD PRIMARY KEY, ALGORITHM=INPLACE
+RENAME TABLE t5980aa TO t5980a;
+RENAME TABLE t5980bb TO t5980b;
+SHOW CREATE TABLE t5980a;
+Table Create Table
+t5980a CREATE TABLE `t5980a` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` text,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t5980b;
+Table Create Table
+t5980b CREATE TABLE `t5980b` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` text,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alt_dir/'
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test%' ORDER BY name;
+name n_cols file_format row_format
+test/t5980a 5 Antelope Compact
+test/t5980b 5 Antelope Compact
+test/t5980c 5 Antelope Compact
+test/t5980d 5 Antelope Compact
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+WHERE name LIKE 'test%' ORDER BY space;
+name file_format row_format
+test/t5980c Antelope Compact or Redundant
+test/t5980d Antelope Compact or Redundant
+test/t5980a Antelope Compact or Redundant
+test/t5980b Antelope Compact or Redundant
+SELECT path FROM information_schema.innodb_sys_datafiles
+WHERE path LIKE '%test%' ORDER BY space;
+path
+MYSQL_DATA_DIR/test/t5980c.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980d.ibd
+MYSQL_DATA_DIR/test/t5980a.ibd
+MYSQL_TMP_DIR/alt_dir/test/t5980b.ibd
+### files in MYSQL_DATA_DIR/test
+t5980a.frm
+t5980a.ibd
+t5980b.frm
+t5980b.isl
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+t5980b.ibd
+#
+# Discard tablespaces again and try another ALTER TABLE ROW_FORMAT.
+#
+ALTER TABLE t5980a DISCARD TABLESPACE;
+ALTER TABLE t5980b DISCARD TABLESPACE;
+SELECT * FROM t5980a;
+ERROR HY000: Tablespace has been discarded for table 't5980a'
+SELECT * FROM t5980b;
+ERROR HY000: Tablespace has been discarded for table 't5980b'
+#
+# ALTER TABLE ALGORITHM=COPY cannot use a discarded tablespace.
+#
+ALTER TABLE t5980a ROW_FORMAT=REDUNDANT, ALGORITHM=COPY;
+ERROR HY000: Tablespace has been discarded for table 't5980a'
+ALTER TABLE t5980b ROW_FORMAT=REDUNDANT, ALGORITHM=COPY;
+ERROR HY000: Tablespace has been discarded for table 't5980b'
+#
+# ALTER TABLE ALGORITHM=INPLACE can use a discarded tablespace.
+#
+ALTER TABLE t5980a ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
+ALTER TABLE t5980b ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
+INSERT INTO t5980a VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE");
+INSERT INTO t5980b VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE");
+SELECT * FROM t5980a;
+a b
+1 Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE
+SELECT * FROM t5980b;
+a b
+1 Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE
+### files in MYSQL_DATA_DIR/test
+t5980a.frm
+t5980a.ibd
+t5980b.frm
+t5980b.isl
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+t5980b.ibd
+#
+# Discard tablespaces again and try ALTER TABLE ADD COLUMN.
+#
+ALTER TABLE t5980a DISCARD TABLESPACE;
+ALTER TABLE t5980b DISCARD TABLESPACE;
+SELECT * FROM t5980a;
+ERROR HY000: Tablespace has been discarded for table 't5980a'
+SELECT * FROM t5980b;
+ERROR HY000: Tablespace has been discarded for table 't5980b'
+#
+# ALTER TABLE ALGORITHM=COPY cannot use a discarded tablespace.
+#
+ALTER TABLE t5980a ADD COLUMN c CHAR(20), ALGORITHM=COPY;
+ERROR HY000: Tablespace has been discarded for table 't5980a'
+ALTER TABLE t5980b ADD COLUMN c CHAR(20), ALGORITHM=COPY;
+ERROR HY000: Tablespace has been discarded for table 't5980b'
+#
+# ALTER TABLE ALGORITHM=INPLACE can use a discarded tablespace.
+#
+ALTER TABLE t5980a ADD COLUMN c CHAR(20), ALGORITHM=INPLACE;
+ALTER TABLE t5980b ADD COLUMN c CHAR(20), ALGORITHM=INPLACE;
+INSERT INTO t5980a VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE", "new column");
+INSERT INTO t5980b VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE", "new column");
+SELECT * FROM t5980a;
+a b c
+1 Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE new column
+SELECT * FROM t5980b;
+a b c
+1 Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE new column
+### files in MYSQL_DATA_DIR/test
+t5980a.frm
+t5980a.ibd
+t5980b.frm
+t5980b.isl
+t5980c.frm
+t5980d.frm
+### files in MYSQL_TMP_DIR/alt_dir/test
+t5980b.ibd
+DROP TABLE t5980a;
+DROP TABLE t5980b;
+DROP TABLE t5980c;
+DROP TABLE t5980d;
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+WHERE name LIKE 'test%' ORDER BY name;
+name n_cols file_format row_format
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+WHERE name LIKE 'test%' ORDER BY space;
+name file_format row_format
+SELECT path FROM information_schema.innodb_sys_datafiles
+WHERE path LIKE '%test%' ORDER BY space;
+path
### files in MYSQL_DATA_DIR/test
### files in MYSQL_TMP_DIR/alt_dir/test
+#
+# Cleanup
+#
=== modified file 'mysql-test/suite/innodb/t/innodb-multiple-tablespaces.test'
--- a/mysql-test/suite/innodb/t/innodb-multiple-tablespaces.test revid:yasufumi.kinoshita@stripped
+++ b/mysql-test/suite/innodb/t/innodb-multiple-tablespaces.test revid:kevin.lewis@stripped
@@ -130,13 +130,10 @@ INSERT INTO nolink VALUES (1, 'no link f
--source include/shutdown_mysqld.inc
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo ---- MYSQL_TMP_DIR/new_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/new_dir/test
--echo # YYY; Tablespace found in 3 places
@@ -198,13 +195,10 @@ INSERT INTO nolink VALUES (1, 'no link f
--remove_file $MYSQLD_DATADIR/test/nolink.isl
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo ---- MYSQL_TMP_DIR/new_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/new_dir/test
--echo #
@@ -265,13 +259,10 @@ SHOW CREATE TABLE nolink;
--echo # List of files before DROP TABLES
--echo #
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo ---- MYSQL_TMP_DIR/new_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/new_dir/test
--echo #
@@ -296,20 +287,16 @@ DROP TABLE nolink;
--echo # List of files not deleted by the DROP TABLES
--echo #
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo ---- MYSQL_TMP_DIR/new_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/new_dir/test
--remove_file $MYSQLD_DATADIR/test/www.ibd
--remove_file $MYSQLD_DATADIR/test/wny.ibd
--remove_file $MYSQLD_DATADIR/test/wyn.ibd
--remove_file $MYSQLD_DATADIR/test/yny.ibd
---remove_file $MYSQLD_DATADIR/test/ywn.isl
--remove_file $MYSQLD_DATADIR/test/yyn.ibd
--remove_file $MYSQLD_DATADIR/test/yyy.ibd
--remove_file $MYSQL_TMP_DIR/alt_dir/test/nwy.ibd
@@ -326,16 +313,13 @@ DROP TABLE nolink;
--remove_file $MYSQL_TMP_DIR/new_dir/test/yyy.ibd
--echo #
---echo # List of files after removing unused files
+--echo # List of files after removing leftover files
--echo #
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo ---- MYSQL_TMP_DIR/new_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/new_dir/test
--echo #
@@ -421,10 +405,8 @@ COMMIT;
--exec echo $MYSQLD_DATADIR/test/aa.ibd > $MYSQLD_DATADIR/test/aa.isl
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo #
@@ -467,10 +449,8 @@ COMMIT;
--copy_file $MYSQL_TMP_DIR/alt_dir/test/aa.ibd.bak $MYSQLD_DATADIR/test/wy.ibd
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo #
@@ -488,10 +468,8 @@ COMMIT;
--copy_file $MYSQL_TMP_DIR/alt_dir/test/aa.ibd.bak $MYSQL_TMP_DIR/alt_dir/test/yw.ibd
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo #
@@ -510,10 +488,8 @@ COMMIT;
--echo # NY; Tablespace found in alt_dir but not the default directory.
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo #
@@ -553,10 +529,8 @@ SHOW CREATE TABLE wy;
--echo # List of files before DROP TABLES
--echo #
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
DROP TABLE aa;
@@ -570,24 +544,18 @@ DROP TABLE wy;
--echo # List of files after DROP TABLES
--echo #
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
---remove_file $MYSQLD_DATADIR/test/yn.isl
---remove_file $MYSQLD_DATADIR/test/yw.isl
--remove_file $MYSQL_TMP_DIR/alt_dir/test/aa.ibd.bak
--echo #
--echo # List of files after deleting unknown files
--echo #
--echo ---- MYSQLD_DATADIR/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir/test
---replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir/test
--echo #
=== modified file 'mysql-test/suite/innodb/t/innodb-wl5980-discard.test'
--- a/mysql-test/suite/innodb/t/innodb-wl5980-discard.test revid:yasufumi.kinoshita@stripped
+++ b/mysql-test/suite/innodb/t/innodb-wl5980-discard.test revid:kevin.lewis@stripped
@@ -305,7 +305,6 @@ CHECK TABLE t5980;
--echo #
--copy_file $MYSQL_TMP_DIR/alt_dir/test/t5980.ibd.bak $MYSQL_DATA_DIR/test/t5980.ibd
--copy_file $MYSQL_TMP_DIR/alt_dir/test/t5980.cfg.bak $MYSQL_DATA_DIR/test/t5980.cfg
---remove_file $MYSQL_DATA_DIR/test/t5980.isl
--echo ### files in MYSQL_DATA_DIR/test
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
@@ -365,23 +364,345 @@ SELECT name,file_format,row_format
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
---echo #
---echo # Cleanup
---echo #
-
DROP TABLE t5980;
--remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980.cfg.bak
---remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980.ibd.bak
+--remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980.ibd.bak
--remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980.cfg.bak2
---remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980.ibd.bak2
+--remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980.ibd.bak2
+
+--echo #
+--echo # Create a local and remote tablespaces, discard two and make
+--echo # the other two missing upon restart, and try some DDL and DML
+--echo # on these discarded and missing tablespaces.
+--echo #
+
+SET GLOBAL innodb_file_per_table=ON;
+CREATE TABLE t5980a (a int, b text) engine=InnoDB;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE TABLE t5980b (a int, b text) engine=InnoDB $data_directory_clause;
+CREATE TABLE t5980c (a int, b text) engine=InnoDB;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE TABLE t5980d (a int, b text) engine=InnoDB $data_directory_clause;
+
+INSERT INTO t5980a VALUES (1, "Default location, discarded.");
+INSERT INTO t5980b VALUES (1, "Remote location, discarded");
+INSERT INTO t5980c VALUES (1, "Default location, missing");
+INSERT INTO t5980d VALUES (1, "Remote location, missing");
+
+SELECT * FROM t5980a;
+SELECT * FROM t5980b;
+SELECT * FROM t5980c;
+SELECT * FROM t5980d;
+
+SHOW CREATE TABLE t5980a;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t5980b;
+SHOW CREATE TABLE t5980c;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t5980d;
+
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+ WHERE name LIKE 'test%' ORDER BY name;
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+ WHERE name LIKE 'test%' ORDER BY space;
+--replace_result ./ MYSQL_DATA_DIR/ $MYSQL_DATA_DIR MYSQL_DATA_DIR $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles
+ WHERE path LIKE '%test%' ORDER BY space;
+
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Shutdown the server, remove two tablespaces, restart server.
+--echo #
+--source include/shutdown_mysqld.inc
+--remove_file $MYSQL_DATA_DIR/test/t5980c.ibd
+--remove_file $MYSQL_DATA_DIR/test/t5980d.isl
+--remove_file $MYSQL_TMP_DIR/alt_dir/test/t5980d.ibd
+--source include/start_mysqld.inc
+
+FLUSH TABLES t5980a, t5980b FOR EXPORT;
+UNLOCK TABLES;
+
+ALTER TABLE t5980a DISCARD TABLESPACE;
+ALTER TABLE t5980b DISCARD TABLESPACE;
+
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980a;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980b;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t5980c;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t5980d;
+
+SHOW CREATE TABLE t5980a;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t5980b;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t5980c;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t5980d;
+
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+ WHERE name LIKE 'test%' ORDER BY name;
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+ WHERE name LIKE 'test%' ORDER BY space;
+--replace_result ./ MYSQL_DATA_DIR/ $MYSQL_DATA_DIR MYSQL_DATA_DIR $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles
+ WHERE path LIKE '%test%' ORDER BY space;
+
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Discarded and missing tablespaces cannot be TRUNCATED
+--echo #
+
+--error ER_TABLESPACE_DISCARDED
+TRUNCATE TABLE t5980a;
+--error ER_TABLESPACE_DISCARDED
+TRUNCATE TABLE t5980b;
+--error ER_NO_SUCH_TABLE
+TRUNCATE TABLE t5980c;
+--error ER_NO_SUCH_TABLE
+TRUNCATE TABLE t5980d;
+
+--echo #
+--echo # Discarded tablespaces can be RENAMED but they remain discarded
+--echo #
+
+RENAME TABLE t5980a TO t5980aa;
+RENAME TABLE t5980b TO t5980bb;
+
+--echo #
+--echo # Missing tablespaces cannot be RENAMED
+--echo #
+
+--error ER_ERROR_ON_RENAME
+RENAME TABLE t5980c TO t5980cc;
+--error ER_ERROR_ON_RENAME
+RENAME TABLE t5980d TO t5980dd;
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t5980a;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t5980b;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980aa;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980bb;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t5980c;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t5980d;
+
+SHOW CREATE TABLE t5980aa;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t5980bb;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t5980c;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t5980d;
+
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+ WHERE name LIKE 'test%' ORDER BY name;
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+ WHERE name LIKE 'test%' ORDER BY space;
+--replace_result ./ MYSQL_DATA_DIR/ $MYSQL_DATA_DIR MYSQL_DATA_DIR $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles
+ WHERE path LIKE '%test%' ORDER BY space;
+
+--echo #
+--echo # Discarded tablespaces cannot be ALTERED with ALGORITHM=COPY.
+--echo #
+
+--error ER_TABLESPACE_DISCARDED
+ALTER TABLE t5980aa ADD PRIMARY KEY(a), ALGORITHM=COPY;
+--error ER_TABLESPACE_DISCARDED
+ALTER TABLE t5980bb ADD PRIMARY KEY(a), ALGORITHM=COPY;
+
+--echo #
+--echo # Discarded tablespaces can be ALTERED with ALGORITHM=INPLACE.
+--echo #
+
+ALTER TABLE t5980aa ADD PRIMARY KEY(a), ALGORITHM=INPLACE;
+ALTER TABLE t5980bb ADD PRIMARY KEY(a), ALGORITHM=INPLACE;
+
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Missing tablespaces cannot be ALTERED.
+--echo #
+
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t5980c ADD PRIMARY KEY(a);
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t5980d ADD PRIMARY KEY(a);
+
+SELECT * FROM t5980aa;
+SELECT * FROM t5980bb;
+
+SHOW CREATE TABLE t5980aa;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t5980bb;
+
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+ WHERE name LIKE 'test%' ORDER BY name;
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+ WHERE name LIKE 'test%' ORDER BY space;
+--replace_result ./ MYSQL_DATA_DIR/ $MYSQL_DATA_DIR MYSQL_DATA_DIR $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles
+ WHERE path LIKE '%test%' ORDER BY space;
+
--echo ### files in MYSQL_DATA_DIR/test
--list_files $MYSQL_DATA_DIR/test
--echo ### files in MYSQL_TMP_DIR/alt_dir/test
--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Discarded tablespaces that were ALTERED IN_PLACE are no longer discarded.
+--echo #
+
+INSERT INTO t5980aa VALUES (1, "Inserted into Discarded Local tablespace after ALTER ADD PRIMARY KEY, ALGORITHM=INPLACE");
+INSERT INTO t5980bb VALUES (1, "Inserted into Discarded Local tablespace after ALTER ADD PRIMARY KEY, ALGORITHM=INPLACE");
+
+SELECT * FROM t5980aa;
+SELECT * FROM t5980bb;
+
+RENAME TABLE t5980aa TO t5980a;
+RENAME TABLE t5980bb TO t5980b;
+
+SHOW CREATE TABLE t5980a;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t5980b;
+
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+ WHERE name LIKE 'test%' ORDER BY name;
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+ WHERE name LIKE 'test%' ORDER BY space;
+--replace_result ./ MYSQL_DATA_DIR/ $MYSQL_DATA_DIR MYSQL_DATA_DIR $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles
+ WHERE path LIKE '%test%' ORDER BY space;
+
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Discard tablespaces again and try another ALTER TABLE ROW_FORMAT.
+--echo #
+
+ALTER TABLE t5980a DISCARD TABLESPACE;
+ALTER TABLE t5980b DISCARD TABLESPACE;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980a;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980b;
+
+--echo #
+--echo # ALTER TABLE ALGORITHM=COPY cannot use a discarded tablespace.
+--echo #
+
+--error ER_TABLESPACE_DISCARDED
+ALTER TABLE t5980a ROW_FORMAT=REDUNDANT, ALGORITHM=COPY;
+--error ER_TABLESPACE_DISCARDED
+ALTER TABLE t5980b ROW_FORMAT=REDUNDANT, ALGORITHM=COPY;
+
+--echo #
+--echo # ALTER TABLE ALGORITHM=INPLACE can use a discarded tablespace.
+--echo #
+
+ALTER TABLE t5980a ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
+ALTER TABLE t5980b ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE;
+INSERT INTO t5980a VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE");
+INSERT INTO t5980b VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE");
+SELECT * FROM t5980a;
+SELECT * FROM t5980b;
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Discard tablespaces again and try ALTER TABLE ADD COLUMN.
+--echo #
+
+ALTER TABLE t5980a DISCARD TABLESPACE;
+ALTER TABLE t5980b DISCARD TABLESPACE;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980a;
+--error ER_TABLESPACE_DISCARDED
+SELECT * FROM t5980b;
+
+--echo #
+--echo # ALTER TABLE ALGORITHM=COPY cannot use a discarded tablespace.
+--echo #
+
+--error ER_TABLESPACE_DISCARDED
+ALTER TABLE t5980a ADD COLUMN c CHAR(20), ALGORITHM=COPY;
+--error ER_TABLESPACE_DISCARDED
+ALTER TABLE t5980b ADD COLUMN c CHAR(20), ALGORITHM=COPY;
+
+--echo #
+--echo # ALTER TABLE ALGORITHM=INPLACE can use a discarded tablespace.
+--echo #
+
+ALTER TABLE t5980a ADD COLUMN c CHAR(20), ALGORITHM=INPLACE;
+ALTER TABLE t5980b ADD COLUMN c CHAR(20), ALGORITHM=INPLACE;
+INSERT INTO t5980a VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE", "new column");
+INSERT INTO t5980b VALUES (1, "Inserted into discarded local tablespace after ALTER ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE", "new column");
+SELECT * FROM t5980a;
+SELECT * FROM t5980b;
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+DROP TABLE t5980a;
+DROP TABLE t5980b;
+DROP TABLE t5980c;
+DROP TABLE t5980d;
+
+SELECT name,n_cols,file_format,row_format FROM information_schema.innodb_sys_tables
+ WHERE name LIKE 'test%' ORDER BY name;
+SELECT name,file_format,row_format FROM information_schema.innodb_sys_tablespaces
+ WHERE name LIKE 'test%' ORDER BY space;
+--replace_result ./ MYSQL_DATA_DIR/ $MYSQL_DATA_DIR MYSQL_DATA_DIR $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles
+ WHERE path LIKE '%test%' ORDER BY space;
+
+--echo ### files in MYSQL_DATA_DIR/test
+--list_files $MYSQL_DATA_DIR/test
+--echo ### files in MYSQL_TMP_DIR/alt_dir/test
+--list_files $MYSQL_TMP_DIR/alt_dir/test
+
+--echo #
+--echo # Cleanup
+--echo #
+
--rmdir $MYSQL_TMP_DIR/alt_dir/test
--rmdir $MYSQL_TMP_DIR/alt_dir
-- disable_query_log
eval set global innodb_file_per_table=$innodb_file_per_table_orig;
+
+call mtr.add_suppression("InnoDB: Could not find a valid tablespace file for");
+call mtr.add_suppression("InnoDB: Tablespace open failed for");
+call mtr.add_suppression("InnoDB: Failed to find tablespace for table ");
+call mtr.add_suppression("InnoDB: Table test/t5980.* does not have an .ibd file in the database directory.");
-- enable_query_log
=== modified file 'storage/innobase/dict/dict0load.cc'
--- a/storage/innobase/dict/dict0load.cc revid:yasufumi.kinoshita@stripped
+++ b/storage/innobase/dict/dict0load.cc revid:kevin.lewis@stripped
@@ -2131,19 +2131,19 @@ dict_get_and_save_data_dir_path(
if (!dict_mutex_own) {
dict_mutex_enter_for_mysql();
}
- if (!path) {
+ if (!path && !srv_force_recovery) {
path = dict_get_first_path(
table->space, table->name);
}
if (path) {
dict_save_data_dir_path(table, path);
+ mem_free(path);
}
if (!dict_mutex_own) {
dict_mutex_exit_for_mysql();
}
- mem_free(path);
}
}
@@ -2261,8 +2261,10 @@ err_exit:
} else if (!fil_space_for_table_exists_in_mem(
table->space, name, FALSE, FALSE)) {
- if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) {
- /* Do not bother to retry opening temporary tables. */
+ if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)
+ || srv_force_recovery) {
+ /* Do not bother to retry opening temporary tables
+ or retry any tablespace if force_recovery is on. */
table->ibd_file_missing = TRUE;
} else {
ib_logf(IB_LOG_LEVEL_ERROR,
=== modified file 'storage/innobase/fil/fil0fil.cc'
--- a/storage/innobase/fil/fil0fil.cc revid:yasufumi.kinoshita@stripped
+++ b/storage/innobase/fil/fil0fil.cc revid:kevin.lewis@stripped
@@ -2557,25 +2557,27 @@ fil_delete_tablespace(
#endif /* !UNIV_HOTBACKUP */
- mutex_enter(&fil_system->mutex);
-
- if (!fil_space_free(id, TRUE)) {
- err = DB_TABLESPACE_NOT_FOUND;
- }
-
- mutex_exit(&fil_system->mutex);
-
/* If it is a delete then also delete any generated files, otherwise
when we drop the database the remove directory will fail. */
-
{
char* cfg_name = fil_make_cfg_name(path);
-
os_file_delete_if_exists(cfg_name);
-
mem_free(cfg_name);
}
+ /* Delete the link file pointing to the ibd file we are deleting. */
+ if (FSP_FLAGS_HAS_DATA_DIR(space->flags)) {
+ fil_delete_link_file(space->name);
+ }
+
+ mutex_enter(&fil_system->mutex);
+
+ if (!fil_space_free(id, TRUE)) {
+ err = DB_TABLESPACE_NOT_FOUND;
+ }
+
+ mutex_exit(&fil_system->mutex);
+
if (err != DB_SUCCESS) {
rw_lock_x_unlock(&space->latch);
} else if (!os_file_delete(path) && !os_file_delete_if_exists(path)) {
=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc revid:yasufumi.kinoshita@stripped
+++ b/storage/innobase/handler/ha_innodb.cc revid:kevin.lewis@stripped
@@ -9699,7 +9699,8 @@ int
ha_innobase::truncate()
/*===================*/
{
- dberr_t error;
+ dberr_t err;
+ int error;
DBUG_ENTER("ha_innobase::truncate");
@@ -9713,10 +9714,29 @@ ha_innobase::truncate()
}
/* Truncate the table in InnoDB */
- error = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx);
+ err = row_truncate_table_for_mysql(prebuilt->table, prebuilt->trx);
+
+ switch (err) {
+
+ case DB_TABLESPACE_DELETED:
+ case DB_TABLESPACE_NOT_FOUND:
+ ib_senderrf(
+ prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR,
+ (err == DB_TABLESPACE_DELETED ?
+ ER_TABLESPACE_DISCARDED : ER_TABLESPACE_MISSING),
+ table->s->table_name.str);
+ table->status = STATUS_NOT_FOUND;
+ error = HA_ERR_NO_SUCH_TABLE;
+ break;
- DBUG_RETURN(convert_error_code_to_mysql(error, prebuilt->table->flags,
- NULL));
+ default:
+ error = convert_error_code_to_mysql(
+ err, prebuilt->table->flags,
+ prebuilt->trx->mysql_thd);
+ table->status = STATUS_NOT_FOUND;
+ break;
+ }
+ DBUG_RETURN(error);
}
/*****************************************************************//**
=== modified file 'storage/innobase/row/row0merge.cc'
--- a/storage/innobase/row/row0merge.cc revid:yasufumi.kinoshita@stripped
+++ b/storage/innobase/row/row0merge.cc revid:kevin.lewis@stripped
@@ -3136,7 +3136,9 @@ row_merge_rename_tables(
/* Update SYS_TABLESPACES and SYS_DATAFILES if the old
table is in a non-system tablespace where space > 0. */
- if (err == DB_SUCCESS && old_table->space) {
+ if (err == DB_SUCCESS
+ && old_table->space != TRX_SYS_SPACE
+ && !old_table->ibd_file_missing) {
/* Make pathname to update SYS_DATAFILES. */
char* tmp_path = row_make_new_pathname(old_table, tmp_name);
@@ -3163,7 +3165,9 @@ row_merge_rename_tables(
/* Update SYS_TABLESPACES and SYS_DATAFILES if the new
table is in a non-system tablespace where space > 0. */
- if (err == DB_SUCCESS && new_table->space) {
+ if (err == DB_SUCCESS
+ && new_table->space != TRX_SYS_SPACE
+ && !new_table->ibd_file_missing) {
/* Make pathname to update SYS_DATAFILES. */
char* old_path = row_make_new_pathname(new_table, old_name);
=== modified file 'storage/innobase/row/row0mysql.cc'
--- a/storage/innobase/row/row0mysql.cc revid:yasufumi.kinoshita@stripped
+++ b/storage/innobase/row/row0mysql.cc revid:kevin.lewis@stripped
@@ -3182,6 +3182,12 @@ row_truncate_table_for_mysql(
return(DB_ERROR);
}
+ if (dict_table_is_discarded(table)) {
+ return(DB_TABLESPACE_DELETED);
+ } else if (table->ibd_file_missing) {
+ return(DB_TABLESPACE_NOT_FOUND);
+ }
+
trx_start_if_not_started(trx);
trx->op_info = "truncating table";
@@ -4032,7 +4038,7 @@ check_next_foreign:
/* We do not allow temporary tables with a remote path. */
ut_a(!(is_temp && DICT_TF_HAS_DATA_DIR(table->flags)));
- if (DICT_TF_HAS_DATA_DIR(table->flags)) {
+ if (space_id && DICT_TF_HAS_DATA_DIR(table->flags)) {
dict_get_and_save_data_dir_path(table, true);
ut_a(table->data_dir_path);
@@ -4089,7 +4095,7 @@ check_next_foreign:
a temp table or if the tablesace has been discarded. */
print_msg = !(is_temp || ibd_file_missing);
- if (err == DB_SUCCESS && space_id > 0) {
+ if (err == DB_SUCCESS && space_id > TRX_SYS_SPACE) {
if (!is_temp
&& !fil_space_for_table_exists_in_mem(
space_id, tablename, FALSE, print_msg)) {
@@ -4596,7 +4602,9 @@ row_rename_table_for_mysql(
"InnoDB: " REFMAN "innodb-troubleshooting.html\n",
stderr);
goto funct_exit;
- } else if (!dict_table_is_discarded(table) && table->ibd_file_missing) {
+
+ } else if (table->ibd_file_missing
+ && !dict_table_is_discarded(table)) {
err = DB_TABLE_NOT_FOUND;
@@ -4606,6 +4614,7 @@ row_rename_table_for_mysql(
old_name);
goto funct_exit;
+
} else if (new_is_tmp) {
/* MySQL is doing an ALTER TABLE command and it renames the
original table to a temporary table name. We want to preserve
@@ -4662,7 +4671,9 @@ row_rename_table_for_mysql(
/* SYS_TABLESPACES and SYS_DATAFILES track non-system tablespaces
which have space IDs > 0. */
- if (err == DB_SUCCESS && table->space) {
+ if (err == DB_SUCCESS
+ && table->space != TRX_SYS_SPACE
+ && !table->ibd_file_missing) {
/* Make a new pathname to update SYS_DATAFILES. */
char* new_path = row_make_new_pathname(table, new_name);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (kevin.lewis:3918 to 3919) | kevin.lewis | 29 Jun |