List:Commits« Previous MessageNext Message »
From:kevin.lewis Date:March 10 2012 4:25am
Subject:bzr push into mysql-trunk branch (kevin.lewis:3719 to 3720)
View as plain text  
 3720 kevin.lewis@stripped	2012-03-09
      local commit. Add test for DISCARD/IMPORT with DATA DIRECTORY and fix code bugs for DISCARD/IMPORT

    modified:
      mysql-test/suite/innodb/r/innodb-restart.result
      mysql-test/suite/innodb/r/innodb-tablespace.result
      mysql-test/suite/innodb/t/innodb-restart.test
      mysql-test/suite/innodb/t/innodb-tablespace.test
      storage/innobase/fil/fil0fil.cc
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/include/fil0fil.h
      storage/innobase/row/row0mysql.cc
 3719 kevin.lewis@stripped	2012-03-09
      Local commit.  Clean up testcases for PB2

    modified:
      mysql-test/suite/innodb/r/innodb-tablespace.result
      mysql-test/suite/innodb/t/innodb-tablespace.test
      mysql-test/suite/parts/t/partition_basic_symlink_innodb.test
=== modified file 'mysql-test/suite/innodb/r/innodb-restart.result'
--- a/mysql-test/suite/innodb/r/innodb-restart.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb-restart.result	revid:kevin.lewis@stripped
@@ -83,7 +83,7 @@ SELECT count(*) FROM t4;
 count(*)
 16
 CREATE TABLE t5(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT)
-ROW_FORMAT=DYNAMIC  ENGINE=InnoDB  DATA DIRECTORY='MYSQL_TMP_DIR/innodb';
+ROW_FORMAT=DYNAMIC  ENGINE=InnoDB  DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir';
 INSERT INTO t5 VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot');
 INSERT INTO t5 (SELECT 0, c2, c3, c4, c5 FROM t5);
 INSERT INTO t5 (SELECT 0, c2, c3, c4, c5 FROM t5);
@@ -98,7 +98,7 @@ t5	CREATE TABLE `t5` (
   `c4` date DEFAULT NULL,
   `c5` text,
   PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=1000000027 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/innodb/'
+) ENGINE=InnoDB AUTO_INCREMENT=1000000027 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
 SELECT count(*) FROM t5;
 count(*)
 16
@@ -124,7 +124,7 @@ MYSQLD_DATADIR/test/t1.ibd
 MYSQLD_DATADIR/test/t2.ibd
 MYSQLD_DATADIR/test/t3.ibd
 MYSQLD_DATADIR/test/t4.ibd
-MYSQL_TMP_DIR/innodb/test/t5.ibd
+MYSQL_TMP_DIR/alternate_dir/test/t5.ibd
 # Restart the server
 SHOW VARIABLES LIKE 'innodb_file_per_table';
 Variable_name	Value
@@ -178,7 +178,7 @@ t5	CREATE TABLE `t5` (
   `c4` date DEFAULT NULL,
   `c5` text,
   PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=1000000020 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/innodb/'
+) ENGINE=InnoDB AUTO_INCREMENT=1000000020 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
 INSERT INTO t1 (SELECT 0, c2, c3, c4, c5 FROM t1);
 INSERT INTO t2 (SELECT 0, c2, c3, c4, c5 FROM t2);
 INSERT INTO t3 (SELECT 0, c2, c3, c4, c5 FROM t3);
@@ -221,7 +221,7 @@ MYSQLD_DATADIR/test/t1.ibd
 MYSQLD_DATADIR/test/t2.ibd
 MYSQLD_DATADIR/test/t3.ibd
 MYSQLD_DATADIR/test/t4.ibd
-MYSQL_TMP_DIR/innodb/test/t5.ibd
+MYSQL_TMP_DIR/alternate_dir/test/t5.ibd
 DROP TABLE t1;
 DROP TABLE t2;
 DROP TABLE t3;
@@ -230,7 +230,7 @@ DROP TABLE t4;
 TRUNCATE TABLE t5;
 SELECT path FROM information_schema.innodb_sys_datafiles;
 path
-MYSQL_TMP_DIR/innodb/test/t5.ibd
+MYSQL_TMP_DIR/alternate_dir/test/t5.ibd
 INSERT INTO t5 VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot');
 INSERT INTO t5 (SELECT 0, c2, c3, c4, c5 FROM t5);
 SELECT count(*) FROM t5;
@@ -245,14 +245,14 @@ t5	CREATE TABLE `t5` (
   `c4` date DEFAULT NULL,
   `c5` text,
   PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=1000000002 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/innodb/'
+) ENGINE=InnoDB AUTO_INCREMENT=1000000002 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
 # Restart the server
 SHOW VARIABLES LIKE 'innodb_file_per_table';
 Variable_name	Value
 innodb_file_per_table	OFF
 SELECT path FROM information_schema.innodb_sys_datafiles;
 path
-MYSQL_TMP_DIR/innodb/test/t5.ibd
+MYSQL_TMP_DIR/alternate_dir/test/t5.ibd
 INSERT INTO t5 (SELECT 0, c2, c3, c4, c5 FROM t5);
 SELECT count(*) FROM t5;
 count(*)
@@ -266,12 +266,12 @@ t5	CREATE TABLE `t5` (
   `c4` date DEFAULT NULL,
   `c5` text,
   PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=1000000005 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/innodb/'
+) ENGINE=InnoDB AUTO_INCREMENT=1000000005 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
 # Rename file table and tablespace, then restart
 RENAME TABLE t5 TO t55;
 SELECT path FROM information_schema.innodb_sys_datafiles;
 path
-MYSQL_TMP_DIR/innodb/test/t55.ibd
+MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
 INSERT INTO t55 (SELECT 0, c2, c3, c4, c5 FROM t55);
 SELECT count(*) FROM t55;
 count(*)
@@ -285,14 +285,14 @@ t55	CREATE TABLE `t55` (
   `c4` date DEFAULT NULL,
   `c5` text,
   PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=1000000012 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/innodb/'
+) ENGINE=InnoDB AUTO_INCREMENT=1000000012 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
 # Restart the server
 SHOW VARIABLES LIKE 'innodb_file_per_table';
 Variable_name	Value
 innodb_file_per_table	OFF
 SELECT path FROM information_schema.innodb_sys_datafiles;
 path
-MYSQL_TMP_DIR/innodb/test/t55.ibd
+MYSQL_TMP_DIR/alternate_dir/test/t55.ibd
 INSERT INTO t55 (SELECT 0, c2, c3, c4, c5 FROM t55);
 SELECT count(*) FROM t55;
 count(*)
@@ -306,5 +306,5 @@ t55	CREATE TABLE `t55` (
   `c4` date DEFAULT NULL,
   `c5` text,
   PRIMARY KEY (`c1`)
-) ENGINE=InnoDB AUTO_INCREMENT=1000000024 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/innodb/'
+) ENGINE=InnoDB AUTO_INCREMENT=1000000024 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/'
 DROP TABLE t55;

=== modified file 'mysql-test/suite/innodb/r/innodb-tablespace.result'
--- a/mysql-test/suite/innodb/r/innodb-tablespace.result	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/r/innodb-tablespace.result	revid:kevin.lewis@stripped
@@ -58,7 +58,7 @@ t1	CREATE TABLE `t1` (
 DROP TABLE t1;
 # Now set innodb_file_per_table so that DATA DIRECTORY can be tested.
 SET GLOBAL innodb_file_per_table=ON;
-# Create the tablespace in MYSQL_TMP_DIR/innodb/data
+# Create the tablespace in MYSQL_TMP_DIR/alternate_dir/data
 # InnoDB will create the sub-directories if needed.
 CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data';
 SHOW WARNINGS;
@@ -232,6 +232,62 @@ t1	CREATE TEMPORARY TABLE `t1` (
   PRIMARY KEY (`a`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 DROP TABLE t1;
+# Test discard/import of InnoDB tables. 
+CREATE TABLE t1 (a int KEY, b text) DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data';
+INSERT INTO t1 VALUES (1, "blue");
+SELECT * FROM t1;
+a	b
+1	blue
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` text,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data/'
+SELECT name,n_cols,file_format,row_format
+FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
+name	n_cols	file_format	row_format
+test/t1	5	Antelope	Compact
+SELECT name,file_format,row_format
+FROM information_schema.innodb_sys_tablespaces;
+name	file_format	row_format
+test/t1	Antelope	Compact or Redundant
+SELECT path FROM information_schema.innodb_sys_datafiles;
+path
+MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+# Make a backup copy of the tablespace.
+# Discard the tablespace.
+ALTER TABLE t1 DISCARD TABLESPACE;
+SELECT path FROM information_schema.innodb_sys_datafiles;
+path
+MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` text,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data/'
+# Restore the backup.
+# Import the tablespace.
+ALTER TABLE t1 IMPORT TABLESPACE;
+SELECT path FROM information_schema.innodb_sys_datafiles;
+path
+MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+INSERT INTO t1 VALUES (2, "red");
+SELECT * FROM t1;
+a	b
+1	blue
+2	red
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` text,
+  PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data/'
+DROP TABLE t1;
 #
 # Cleanup
 #

=== modified file 'mysql-test/suite/innodb/t/innodb-restart.test'
--- a/mysql-test/suite/innodb/t/innodb-restart.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb-restart.test	revid:kevin.lewis@stripped
@@ -15,7 +15,7 @@ SET default_storage_engine=InnoDB;
 
 -- disable_query_log
 let $MYSQLD_DATADIR= `select @@datadir`;
-let $data_directory = DATA DIRECTORY='$MYSQL_TMP_DIR/innodb';
+let $data_directory = DATA DIRECTORY='$MYSQL_TMP_DIR/alternate_dir';
 
 let $innodb_file_per_table=`select @@innodb_file_per_table`;
 let $innodb_file_format=`select @@innodb_file_format`;
@@ -69,7 +69,7 @@ SELECT count(*) FROM t4;
 
 
 # Test the DATA DIRECTORY is visible after restart.
---mkdir $MYSQL_TMP_DIR/innodb
+--mkdir $MYSQL_TMP_DIR/alternate_dir
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 eval CREATE TABLE t5(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT)
 	ROW_FORMAT=DYNAMIC  ENGINE=InnoDB  $data_directory;
@@ -166,7 +166,6 @@ INSERT INTO t55 (SELECT 0, c2, c3, c4, c
 SELECT count(*) FROM t55;
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 SHOW CREATE TABLE t55;
-
 DROP TABLE t55;
 
 -- disable_query_log

=== modified file 'mysql-test/suite/innodb/t/innodb-tablespace.test'
--- a/mysql-test/suite/innodb/t/innodb-tablespace.test	revid:kevin.lewis@stripped
+++ b/mysql-test/suite/innodb/t/innodb-tablespace.test	revid:kevin.lewis@stripped
@@ -56,7 +56,7 @@ DROP TABLE t1;
 --echo # Now set innodb_file_per_table so that DATA DIRECTORY can be tested.
 SET GLOBAL innodb_file_per_table=ON;
 
---echo # Create the tablespace in MYSQL_TMP_DIR/innodb/data
+--echo # Create the tablespace in MYSQL_TMP_DIR/alternate_dir/data
 --echo # InnoDB will create the sub-directories if needed.
 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 eval CREATE TABLE t1 (a int KEY, b text) $data_directory;
@@ -201,10 +201,68 @@ SHOW WARNINGS;
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
 
+--echo # Test discard/import of InnoDB tables. 
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE TABLE t1 (a int KEY, b text) $data_directory;
+INSERT INTO t1 VALUES (1, "blue");
+SELECT * FROM t1;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t1;
+SELECT name,n_cols,file_format,row_format
+       FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
+SELECT name,file_format,row_format
+       FROM information_schema.innodb_sys_tablespaces;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles;
+--file_exists $MYSQLD_DATADIR/test/t1.frm
+--file_exists $MYSQLD_DATADIR/test/t1.isl
+--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+--error 1
+--file_exists $MYSQLD_DATADIR/test/t1.ibd
+
+--echo # Make a backup copy of the tablespace.
+copy_file $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd  $MYSQL_TMP_DIR/alternate_dir/data/test/t1.backup;
+
+--echo # Discard the tablespace.
+ALTER TABLE t1 DISCARD TABLESPACE;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t1;
+--file_exists $MYSQLD_DATADIR/test/t1.frm
+--file_exists $MYSQLD_DATADIR/test/t1.isl
+--error 1
+--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+--error 1
+--file_exists $MYSQLD_DATADIR/test/t1.ibd
+
+--echo # Restore the backup.
+copy_file $MYSQL_TMP_DIR/alternate_dir/data/test/t1.backup  $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd;
+
+--echo # Import the tablespace.
+ALTER TABLE t1 IMPORT TABLESPACE;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SELECT path FROM information_schema.innodb_sys_datafiles;
+INSERT INTO t1 VALUES (2, "red");
+SELECT * FROM t1;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+SHOW CREATE TABLE t1;
+--file_exists $MYSQLD_DATADIR/test/t1.frm
+--file_exists $MYSQLD_DATADIR/test/t1.isl
+--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+DROP TABLE t1;
+--error 1
+--file_exists $MYSQLD_DATADIR/test/t1.frm
+--error 1
+--file_exists $MYSQLD_DATADIR/test/t1.isl
+--error 1
+--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1.ibd
+
 --echo #
 --echo # Cleanup
 --echo #
 
+--remove_file $MYSQL_TMP_DIR/alternate_dir/data/test/t1.backup
 --rmdir $MYSQL_TMP_DIR/alternate_dir/data/test
 --rmdir $MYSQL_TMP_DIR/alternate_dir/data
 --rmdir $MYSQL_TMP_DIR/alternate_dir

=== modified file 'storage/innobase/fil/fil0fil.cc'
--- a/storage/innobase/fil/fil0fil.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/fil/fil0fil.cc	revid:kevin.lewis@stripped
@@ -2605,7 +2605,7 @@ fil_rename_tablespace_in_mem(
 Allocates a file name for a single-table tablespace. The string must be freed
 by caller with mem_free().
 @return	own: file name */
-static
+UNIV_INTERN
 char*
 fil_make_ibd_name(
 /*==============*/
@@ -3260,14 +3260,12 @@ UNIV_INTERN
 ibool
 fil_reset_too_high_lsns(
 /*====================*/
-	const char*	name,		/*!< in: table name in the
-					databasename/tablename format */
+	const char*	filepath,	/*!< in: filepath of tablespace */
 	lsn_t		current_lsn)	/*!< in: reset lsn's if the lsn stamped
 					to FIL_PAGE_FILE_FLUSH_LSN in the
 					first page is too high */
 {
 	os_file_t	file;
-	char*		filepath;
 	byte*		page;
 	byte*		buf2;
 	lsn_t		flush_lsn;
@@ -3278,8 +3276,6 @@ fil_reset_too_high_lsns(
 	ibool		success;
 	page_zip_des_t	page_zip;
 
-	filepath = fil_make_ibd_name(name, FALSE);
-
 	file = os_file_create_simple_no_error_handling(
 		innodb_file_data_key, filepath, OS_FILE_OPEN,
 		OS_FILE_READ_WRITE, &success);
@@ -3294,7 +3290,6 @@ fil_reset_too_high_lsns(
 		      "InnoDB: open the tablespace file ", stderr);
 		ut_print_filename(stderr, filepath);
 		fputs("!\n", stderr);
-		mem_free(filepath);
 
 		return(FALSE);
 	}
@@ -3411,7 +3406,6 @@ fil_reset_too_high_lsns(
 func_exit:
 	os_file_close(file);
 	ut_free(buf2);
-	mem_free(filepath);
 
 	return(success);
 }

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/handler/ha_innodb.cc	revid:kevin.lewis@stripped
@@ -8542,8 +8542,16 @@ ha_innobase::update_create_info(
 	/* Update the DATA DIRECTORY name from SYS_DATAFILES. */
 	if (DICT_TF_HAS_DATA_DIR(prebuilt->table->flags)) {
 		if (!prebuilt->table->data_dir_path) {
-			char* path = fil_space_get_first_path(
-				prebuilt->table->space);
+			char* path;
+			if (prebuilt->table->tablespace_discarded) {
+				mutex_enter(&(dict_sys->mutex));
+				dict_get_first_path(
+					prebuilt->table->space, &path);
+				mutex_exit(&dict_sys->mutex);
+			} else {
+				path = fil_space_get_first_path(
+					prebuilt->table->space);
+			}
 			ut_a(path);
 			dict_save_data_dir_path(prebuilt->table, path);
 			mem_free(path);

=== modified file 'storage/innobase/include/fil0fil.h'
--- a/storage/innobase/include/fil0fil.h	revid:kevin.lewis@stripped
+++ b/storage/innobase/include/fil0fil.h	revid:kevin.lewis@stripped
@@ -460,6 +460,16 @@ fil_rename_tablespace(
 					in the normal data directory. */
 
 /*******************************************************************//**
+Allocates a file name for a single-table tablespace. The string must be freed
+by caller with mem_free().
+@return	own: file name */
+UNIV_INTERN
+char*
+fil_make_ibd_name(
+/*==============*/
+	const char*	name,		/*!< in: table name or a dir path */
+	ibool		is_full_path);	/*!< in: TRUE if it is a dir path */
+/*******************************************************************//**
 Allocates a file name for a tablespace ISL file (InnoDB Symbolic Link).
 The string must be freed by caller with mem_free().
 @return	own: file name */
@@ -548,8 +558,7 @@ UNIV_INTERN
 ibool
 fil_reset_too_high_lsns(
 /*====================*/
-	const char*	name,		/*!< in: table name in the
-					databasename/tablename format */
+	const char*	filepath,	/*!< in: filepath of tablespace */
 	lsn_t		current_lsn);	/*!< in: reset lsn's if the lsn stamped
 					to FIL_PAGE_FILE_FLUSH_LSN in the
 					first page is too high */

=== modified file 'storage/innobase/row/row0mysql.cc'
--- a/storage/innobase/row/row0mysql.cc	revid:kevin.lewis@stripped
+++ b/storage/innobase/row/row0mysql.cc	revid:kevin.lewis@stripped
@@ -2843,6 +2843,7 @@ row_import_tablespace_for_mysql(
 	trx_t*		trx)	/*!< in: transaction handle */
 {
 	dict_table_t*	table;
+	char*		filepath = NULL;
 	ibool		success;
 	lsn_t		current_lsn;
 	ulint		err		= DB_SUCCESS;
@@ -2851,38 +2852,6 @@ row_import_tablespace_for_mysql(
 
 	trx->op_info = "importing tablespace";
 
-	current_lsn = log_get_lsn();
-
-	/* It is possible, though very improbable, that the lsn's in the
-	tablespace to be imported have risen above the current system lsn, if
-	a lengthy purge, ibuf merge, or rollback was performed on a backup
-	taken with ibbackup. If that is the case, reset page lsn's in the
-	file. We assume that mysqld was shut down after it performed these
-	cleanup operations on the .ibd file, so that it stamped the latest lsn
-	to the FIL_PAGE_FILE_FLUSH_LSN in the first page of the .ibd file.
-
-	TODO: reset also the trx id's in clustered index records and write
-	a new space id to each data page. That would allow us to import clean
-	.ibd files from another MySQL installation. */
-
-	success = fil_reset_too_high_lsns(name, current_lsn);
-
-	if (!success) {
-		ut_print_timestamp(stderr);
-		fputs("  InnoDB: Error: cannot reset lsn's in table ", stderr);
-		ut_print_name(stderr, trx, TRUE, name);
-		fputs("\n"
-		      "InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n",
-		      stderr);
-
-		err = DB_ERROR;
-
-		row_mysql_lock_data_dictionary(trx);
-		table = NULL;
-
-		goto funct_exit;
-	}
-
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks can occur then in these operations */
 
@@ -2932,6 +2901,44 @@ row_import_tablespace_for_mysql(
 		goto funct_exit;
 	}
 
+	/* It is possible, though very improbable, that the lsn's in the
+	tablespace to be imported have risen above the current system lsn, if
+	a lengthy purge, ibuf merge, or rollback was performed on a backup
+	taken with ibbackup. If that is the case, reset page lsn's in the
+	file. We assume that mysqld was shut down after it performed these
+	cleanup operations on the .ibd file, so that it stamped the latest lsn
+	to the FIL_PAGE_FILE_FLUSH_LSN in the first page of the .ibd file.
+
+	TODO: reset also the trx id's in clustered index records and write
+	a new space id to each data page. That would allow us to import clean
+	.ibd files from another MySQL installation. */
+
+	current_lsn = log_get_lsn();
+	/* Use the remote filepath if needed. */
+	if (DICT_TF_HAS_DATA_DIR(table->flags)) {
+		dict_get_first_path(table->space, &filepath);
+	} else {
+		filepath = fil_make_ibd_name(name, FALSE);
+	}
+	ut_a(filepath);
+
+	success = fil_reset_too_high_lsns(filepath, current_lsn);
+
+	if (!success) {
+		ut_print_timestamp(stderr);
+		fputs("  InnoDB: Error: cannot reset lsn's in table ", stderr);
+		ut_print_name(stderr, trx, TRUE, name);
+		fputs("\n"
+		      "InnoDB: in ALTER TABLE ... IMPORT TABLESPACE\n",
+		      stderr);
+
+		err = DB_ERROR;
+
+		table = NULL;
+
+		goto funct_exit;
+	}
+
 	/* Play safe and remove all insert buffer entries, though we should
 	have removed them already when DISCARD TABLESPACE was called */
 
@@ -2940,7 +2947,7 @@ row_import_tablespace_for_mysql(
 	success = fil_open_single_table_tablespace(
 		TRUE, table->space,
 		dict_tf_to_fsp_flags(table->flags),
-		table->name, NULL);
+		table->name, filepath);
 	if (success) {
 		table->ibd_file_missing = FALSE;
 		table->tablespace_discarded = FALSE;
@@ -2961,6 +2968,9 @@ row_import_tablespace_for_mysql(
 
 funct_exit:
 
+	if (filepath) {
+		mem_free(filepath);
+	}
 	if (table != NULL) {
 		dict_table_close(table, TRUE);
 	}

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (kevin.lewis:3719 to 3720) kevin.lewis12 Mar