Commit a5ee7739 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-13157 Specifying DATA DIRECTORY in tables leads to failing EXCHANGE PARTITION

parent be3490f0
...@@ -33,11 +33,15 @@ t2 CREATE TABLE `t2` ( ...@@ -33,11 +33,15 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp/' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp/'
INSERT INTO t1 VALUES (0), (1), (2); INSERT INTO t1 VALUES (0), (1), (2);
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Tables have different definitions
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2; ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2;
ERROR HY000: Tables have different definitions ERROR HY000: Tables have different definitions
SELECT * FROM t1;
a
1
2
SELECT * FROM t2; SELECT * FROM t2;
a a
0
DROP TABLE t1, t2; DROP TABLE t1, t2;
# Creating two non colliding tables mysqltest2.t1 and test.t1 # Creating two non colliding tables mysqltest2.t1 and test.t1
# test.t1 have partitions in mysqltest2-directory! # test.t1 have partitions in mysqltest2-directory!
......
...@@ -55,7 +55,6 @@ CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DI ...@@ -55,7 +55,6 @@ CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DI
CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4; CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0; CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-data-dir' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/mysql-test-idx-dir' AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
ERROR HY000: Tables have different definitions
DROP TABLE IF EXISTS t_10; DROP TABLE IF EXISTS t_10;
DROP TABLE IF EXISTS t_100; DROP TABLE IF EXISTS t_100;
DROP TABLE IF EXISTS t_1000; DROP TABLE IF EXISTS t_1000;
...@@ -125,7 +124,7 @@ CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM AS SE ...@@ -125,7 +124,7 @@ CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM AS SE
CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4; CREATE TABLE tsp_04(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 4;
CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0; CREATE TABLE tsp_00(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM AS SELECT a, b FROM t_10 WHERE MOD(a,5)= 0;
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
ERROR HY000: Non matching attribute 'DATA DIRECTORY' between partition and table ERROR HY000: Tables have different definitions
DROP TABLE IF EXISTS t_10; DROP TABLE IF EXISTS t_10;
DROP TABLE IF EXISTS t_100; DROP TABLE IF EXISTS t_100;
DROP TABLE IF EXISTS t_1000; DROP TABLE IF EXISTS t_1000;
......
...@@ -19,7 +19,6 @@ echo # === Data/Index directories are identical; ...@@ -19,7 +19,6 @@ echo # === Data/Index directories are identical;
let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path'; let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
let $index_directory= INDEX DIRECTORY = '$idx_dir_path'; let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
source suite/parts/inc/part_exch_tabs.inc; source suite/parts/inc/part_exch_tabs.inc;
error ER_TABLES_DIFFERENT_METADATA;
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
source suite/parts/inc/part_exch_drop_tabs.inc; source suite/parts/inc/part_exch_drop_tabs.inc;
...@@ -29,7 +28,7 @@ echo # === partition has directories, the table does not; ...@@ -29,7 +28,7 @@ echo # === partition has directories, the table does not;
let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path'; let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
let $index_directory= ; let $index_directory= ;
source suite/parts/inc/part_exch_tabs.inc; source suite/parts/inc/part_exch_tabs.inc;
error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION; error ER_TABLES_DIFFERENT_METADATA;
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
source suite/parts/inc/part_exch_drop_tabs.inc; source suite/parts/inc/part_exch_drop_tabs.inc;
......
...@@ -38,11 +38,10 @@ SHOW CREATE TABLE t1; ...@@ -38,11 +38,10 @@ SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
INSERT INTO t1 VALUES (0), (1), (2); INSERT INTO t1 VALUES (0), (1), (2);
--error ER_TABLES_DIFFERENT_METADATA
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
--error ER_TABLES_DIFFERENT_METADATA --error ER_TABLES_DIFFERENT_METADATA
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2; ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2;
--sorted_result SELECT * FROM t1;
SELECT * FROM t2; SELECT * FROM t2;
DROP TABLE t1, t2; DROP TABLE t1, t2;
# skipped because of bug#52354 # skipped because of bug#52354
......
...@@ -356,6 +356,10 @@ class ha_partition :public handler ...@@ -356,6 +356,10 @@ class ha_partition :public handler
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info, virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
uint table_changes); uint table_changes);
void update_part_create_info(HA_CREATE_INFO *create_info, uint part_id)
{
m_file[part_id]->update_create_info(create_info);
}
private: private:
int copy_partitions(ulonglong * const copied, ulonglong * const deleted); int copy_partitions(ulonglong * const copied, ulonglong * const deleted);
void cleanup_new_partition(uint part_count); void cleanup_new_partition(uint part_count);
......
...@@ -4652,10 +4652,6 @@ bool compare_partition_options(HA_CREATE_INFO *table_create_info, ...@@ -4652,10 +4652,6 @@ bool compare_partition_options(HA_CREATE_INFO *table_create_info,
option_diffs[errors++]= "MAX_ROWS"; option_diffs[errors++]= "MAX_ROWS";
if (part_elem->part_min_rows != table_create_info->min_rows) if (part_elem->part_min_rows != table_create_info->min_rows)
option_diffs[errors++]= "MIN_ROWS"; option_diffs[errors++]= "MIN_ROWS";
if (part_elem->data_file_name || table_create_info->data_file_name)
option_diffs[errors++]= "DATA DIRECTORY";
if (part_elem->index_file_name || table_create_info->index_file_name)
option_diffs[errors++]= "INDEX DIRECTORY";
for (i= 0; i < errors; i++) for (i= 0; i < errors; i++)
my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0), my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),
......
...@@ -171,7 +171,8 @@ static bool check_exchange_partition(TABLE *table, TABLE *part_table) ...@@ -171,7 +171,8 @@ static bool check_exchange_partition(TABLE *table, TABLE *part_table)
*/ */
static bool compare_table_with_partition(THD *thd, TABLE *table, static bool compare_table_with_partition(THD *thd, TABLE *table,
TABLE *part_table, TABLE *part_table,
partition_element *part_elem) partition_element *part_elem,
uint part_id)
{ {
HA_CREATE_INFO table_create_info, part_create_info; HA_CREATE_INFO table_create_info, part_create_info;
Alter_info part_alter_info; Alter_info part_alter_info;
...@@ -196,6 +197,7 @@ static bool compare_table_with_partition(THD *thd, TABLE *table, ...@@ -196,6 +197,7 @@ static bool compare_table_with_partition(THD *thd, TABLE *table,
} }
/* db_type is not set in prepare_alter_table */ /* db_type is not set in prepare_alter_table */
part_create_info.db_type= part_table->part_info->default_engine_type; part_create_info.db_type= part_table->part_info->default_engine_type;
((ha_partition*)(part_table->file))->update_part_create_info(&part_create_info, part_id);
/* /*
Since we exchange the partition with the table, allow exchanging Since we exchange the partition with the table, allow exchanging
auto_increment value as well. auto_increment value as well.
...@@ -606,7 +608,8 @@ bool Sql_cmd_alter_table_exchange_partition:: ...@@ -606,7 +608,8 @@ bool Sql_cmd_alter_table_exchange_partition::
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (compare_table_with_partition(thd, swap_table, part_table, part_elem)) if (compare_table_with_partition(thd, swap_table, part_table, part_elem,
swap_part_id))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* Table and partition has same structure/options, OK to exchange */ /* Table and partition has same structure/options, OK to exchange */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment