Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDEV-13157 Specifying DATA DIRECTORY in tables leads to failing EXCHA…
…NGE PARTITION
  • Loading branch information
vuvova committed Sep 18, 2017
1 parent be3490f commit a5ee773
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
6 changes: 5 additions & 1 deletion mysql-test/r/partition_symlink.result
Expand Up @@ -33,11 +33,15 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp/'
INSERT INTO t1 VALUES (0), (1), (2);
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Tables have different definitions
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2;
ERROR HY000: Tables have different definitions
SELECT * FROM t1;
a
1
2
SELECT * FROM t2;
a
0
DROP TABLE t1, t2;
# Creating two non colliding tables mysqltest2.t1 and test.t1
# test.t1 have partitions in mysqltest2-directory!
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/parts/r/partition_exch_qa_14.result
Expand Up @@ -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_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;
ERROR HY000: Tables have different definitions
DROP TABLE IF EXISTS t_10;
DROP TABLE IF EXISTS t_100;
DROP TABLE IF EXISTS t_1000;
Expand Down Expand Up @@ -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_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;
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_100;
DROP TABLE IF EXISTS t_1000;
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/parts/t/partition_exch_qa_14.test
Expand Up @@ -19,7 +19,6 @@ echo # === Data/Index directories are identical;
let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
source suite/parts/inc/part_exch_tabs.inc;
error ER_TABLES_DIFFERENT_METADATA;
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
source suite/parts/inc/part_exch_drop_tabs.inc;

Expand All @@ -29,7 +28,7 @@ echo # === partition has directories, the table does not;
let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
let $index_directory= ;
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;
source suite/parts/inc/part_exch_drop_tabs.inc;

Expand Down
3 changes: 1 addition & 2 deletions mysql-test/t/partition_symlink.test
Expand Up @@ -38,11 +38,10 @@ SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t2;
INSERT INTO t1 VALUES (0), (1), (2);
--error ER_TABLES_DIFFERENT_METADATA
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
--error ER_TABLES_DIFFERENT_METADATA
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2;
--sorted_result
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1, t2;
# skipped because of bug#52354
Expand Down
4 changes: 4 additions & 0 deletions sql/ha_partition.h
Expand Up @@ -356,6 +356,10 @@ class ha_partition :public handler
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
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:
int copy_partitions(ulonglong * const copied, ulonglong * const deleted);
void cleanup_new_partition(uint part_count);
Expand Down
4 changes: 0 additions & 4 deletions sql/sql_partition.cc
Expand Up @@ -4652,10 +4652,6 @@ bool compare_partition_options(HA_CREATE_INFO *table_create_info,
option_diffs[errors++]= "MAX_ROWS";
if (part_elem->part_min_rows != table_create_info->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++)
my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),
Expand Down
7 changes: 5 additions & 2 deletions sql/sql_partition_admin.cc
Expand Up @@ -171,7 +171,8 @@ static bool check_exchange_partition(TABLE *table, TABLE *part_table)
*/
static bool compare_table_with_partition(THD *thd, TABLE *table,
TABLE *part_table,
partition_element *part_elem)
partition_element *part_elem,
uint part_id)
{
HA_CREATE_INFO table_create_info, part_create_info;
Alter_info part_alter_info;
Expand All @@ -196,6 +197,7 @@ static bool compare_table_with_partition(THD *thd, TABLE *table,
}
/* db_type is not set in prepare_alter_table */
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
auto_increment value as well.
Expand Down Expand Up @@ -606,7 +608,8 @@ bool Sql_cmd_alter_table_exchange_partition::
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);

/* Table and partition has same structure/options, OK to exchange */
Expand Down

0 comments on commit a5ee773

Please sign in to comment.