Skip to content

Commit a5ee773

Browse files
committed
MDEV-13157 Specifying DATA DIRECTORY in tables leads to failing EXCHANGE PARTITION
1 parent be3490f commit a5ee773

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

mysql-test/r/partition_symlink.result

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ t2 CREATE TABLE `t2` (
3333
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp/'
3434
INSERT INTO t1 VALUES (0), (1), (2);
3535
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
36-
ERROR HY000: Tables have different definitions
3736
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2;
3837
ERROR HY000: Tables have different definitions
38+
SELECT * FROM t1;
39+
a
40+
1
41+
2
3942
SELECT * FROM t2;
4043
a
44+
0
4145
DROP TABLE t1, t2;
4246
# Creating two non colliding tables mysqltest2.t1 and test.t1
4347
# test.t1 have partitions in mysqltest2-directory!

mysql-test/suite/parts/r/partition_exch_qa_14.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ CREATE TABLE tsp_03(a INT,b VARCHAR(55),PRIMARY KEY (a)) ENGINE = MYISAM DATA DI
5555
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;
5656
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;
5757
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
58-
ERROR HY000: Tables have different definitions
5958
DROP TABLE IF EXISTS t_10;
6059
DROP TABLE IF EXISTS t_100;
6160
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
125124
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;
126125
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;
127126
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
128-
ERROR HY000: Non matching attribute 'DATA DIRECTORY' between partition and table
127+
ERROR HY000: Tables have different definitions
129128
DROP TABLE IF EXISTS t_10;
130129
DROP TABLE IF EXISTS t_100;
131130
DROP TABLE IF EXISTS t_1000;

mysql-test/suite/parts/t/partition_exch_qa_14.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ echo # === Data/Index directories are identical;
1919
let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
2020
let $index_directory= INDEX DIRECTORY = '$idx_dir_path';
2121
source suite/parts/inc/part_exch_tabs.inc;
22-
error ER_TABLES_DIFFERENT_METADATA;
2322
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
2423
source suite/parts/inc/part_exch_drop_tabs.inc;
2524

@@ -29,7 +28,7 @@ echo # === partition has directories, the table does not;
2928
let $p_index_directory= INDEX DIRECTORY = '$idx_dir_path';
3029
let $index_directory= ;
3130
source suite/parts/inc/part_exch_tabs.inc;
32-
error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION;
31+
error ER_TABLES_DIFFERENT_METADATA;
3332
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
3433
source suite/parts/inc/part_exch_drop_tabs.inc;
3534

mysql-test/t/partition_symlink.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ SHOW CREATE TABLE t1;
3838
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
3939
SHOW CREATE TABLE t2;
4040
INSERT INTO t1 VALUES (0), (1), (2);
41-
--error ER_TABLES_DIFFERENT_METADATA
4241
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
4342
--error ER_TABLES_DIFFERENT_METADATA
4443
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t2;
45-
--sorted_result
44+
SELECT * FROM t1;
4645
SELECT * FROM t2;
4746
DROP TABLE t1, t2;
4847
# skipped because of bug#52354

sql/ha_partition.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ class ha_partition :public handler
356356
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
357357
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
358358
uint table_changes);
359+
void update_part_create_info(HA_CREATE_INFO *create_info, uint part_id)
360+
{
361+
m_file[part_id]->update_create_info(create_info);
362+
}
359363
private:
360364
int copy_partitions(ulonglong * const copied, ulonglong * const deleted);
361365
void cleanup_new_partition(uint part_count);

sql/sql_partition.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4652,10 +4652,6 @@ bool compare_partition_options(HA_CREATE_INFO *table_create_info,
46524652
option_diffs[errors++]= "MAX_ROWS";
46534653
if (part_elem->part_min_rows != table_create_info->min_rows)
46544654
option_diffs[errors++]= "MIN_ROWS";
4655-
if (part_elem->data_file_name || table_create_info->data_file_name)
4656-
option_diffs[errors++]= "DATA DIRECTORY";
4657-
if (part_elem->index_file_name || table_create_info->index_file_name)
4658-
option_diffs[errors++]= "INDEX DIRECTORY";
46594655

46604656
for (i= 0; i < errors; i++)
46614657
my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),

sql/sql_partition_admin.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ static bool check_exchange_partition(TABLE *table, TABLE *part_table)
171171
*/
172172
static bool compare_table_with_partition(THD *thd, TABLE *table,
173173
TABLE *part_table,
174-
partition_element *part_elem)
174+
partition_element *part_elem,
175+
uint part_id)
175176
{
176177
HA_CREATE_INFO table_create_info, part_create_info;
177178
Alter_info part_alter_info;
@@ -196,6 +197,7 @@ static bool compare_table_with_partition(THD *thd, TABLE *table,
196197
}
197198
/* db_type is not set in prepare_alter_table */
198199
part_create_info.db_type= part_table->part_info->default_engine_type;
200+
((ha_partition*)(part_table->file))->update_part_create_info(&part_create_info, part_id);
199201
/*
200202
Since we exchange the partition with the table, allow exchanging
201203
auto_increment value as well.
@@ -606,7 +608,8 @@ bool Sql_cmd_alter_table_exchange_partition::
606608
DBUG_RETURN(TRUE);
607609
}
608610

609-
if (compare_table_with_partition(thd, swap_table, part_table, part_elem))
611+
if (compare_table_with_partition(thd, swap_table, part_table, part_elem,
612+
swap_part_id))
610613
DBUG_RETURN(TRUE);
611614

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

0 commit comments

Comments
 (0)