Skip to content
/ server Public

Commit db26f44

Browse files
MDEV-35562 Do not emit warning when deleting .par file in quick_rm_table
...just like the when deleting the .frm file in the same function. This improves consistency: internal duplicate deletion of .par file and .frm file both fail silently.
1 parent bb32ace commit db26f44

File tree

7 files changed

+71
-10
lines changed

7 files changed

+71
-10
lines changed

mysql-test/main/partition_alter.result

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,28 @@ partitio values in (2, 3, 4),
391391
pn values in (52, 53, 54));
392392
drop table t1;
393393
# End of 10.7 tests
394+
#
395+
# MDEV-35562 On partitionen tables algorithm is not supported
396+
# throw "no such file or directory" error
397+
#
398+
set @old_alter_algorithm=@@alter_algorithm;
399+
set alter_algorithm='NOCOPY';
400+
CREATE TABLE t1par (
401+
f1 datetime ,
402+
f2 VARCHAR(2) ,
403+
f3 VARCHAR(200) NOT NULL ,
404+
f4 VARCHAR(100) charset utf8
405+
)
406+
PARTITION BY RANGE COLUMNS(f2)
407+
(
408+
PARTITION p_01 VALUES LESS THAN ('02') ENGINE = InnoDB,
409+
PARTITION p_31 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB
410+
);
411+
ALTER online TABLE t1par MODIFY COLUMN f3 VARCHAR(201) NULL , LOCK=NONE;
412+
ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
413+
show warnings;
414+
Level Code Message
415+
Error 1845 ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE
416+
drop table t1par;
417+
set alter_algorithm=@old_alter_algorithm;
418+
# End of 10.11 tests

mysql-test/main/partition_alter.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,29 @@ partition by list(x) (
323323
drop table t1;
324324

325325
--echo # End of 10.7 tests
326+
327+
--echo #
328+
--echo # MDEV-35562 On partitionen tables algorithm is not supported
329+
--echo # throw "no such file or directory" error
330+
--echo #
331+
332+
set @old_alter_algorithm=@@alter_algorithm;
333+
set alter_algorithm='NOCOPY';
334+
CREATE TABLE t1par (
335+
f1 datetime ,
336+
f2 VARCHAR(2) ,
337+
f3 VARCHAR(200) NOT NULL ,
338+
f4 VARCHAR(100) charset utf8
339+
)
340+
PARTITION BY RANGE COLUMNS(f2)
341+
(
342+
PARTITION p_01 VALUES LESS THAN ('02') ENGINE = InnoDB,
343+
PARTITION p_31 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB
344+
);
345+
--error ER_ALTER_OPERATION_NOT_SUPPORTED
346+
ALTER online TABLE t1par MODIFY COLUMN f3 VARCHAR(201) NULL , LOCK=NONE;
347+
show warnings;
348+
drop table t1par;
349+
set alter_algorithm=@old_alter_algorithm;
350+
351+
--echo # End of 10.11 tests

sql/ha_partition.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,10 @@ int ha_partition::rename_table(const char *from, const char *to)
670670
SYNOPSIS
671671
create_partitioning_metadata()
672672
path Path to the new frm file (without ext)
673-
old_p Path to the old frm file (without ext)
674-
create_info Create info generated for CREATE TABLE
673+
old_path Path to the old frm file (without ext)
674+
action_flag Action to take
675+
ignore_delete_error Whether to ignore error in call to
676+
mysql_file_delete
675677
676678
RETURN VALUE
677679
>0 Error
@@ -687,7 +689,8 @@ int ha_partition::rename_table(const char *from, const char *to)
687689

688690
int ha_partition::create_partitioning_metadata(const char *path,
689691
const char *old_path,
690-
chf_create_flags action_flag)
692+
chf_create_flags action_flag,
693+
bool ignore_delete_error)
691694
{
692695
partition_element *part;
693696
DBUG_ENTER("ha_partition::create_partitioning_metadata");
@@ -706,7 +709,8 @@ int ha_partition::create_partitioning_metadata(const char *path,
706709
strxmov(name, path, ha_par_ext, NullS);
707710
strxmov(old_name, old_path, ha_par_ext, NullS);
708711
if ((action_flag == CHF_DELETE_FLAG &&
709-
mysql_file_delete(key_file_ha_partition_par, name, MYF(MY_WME))) ||
712+
mysql_file_delete(key_file_ha_partition_par, name,
713+
ignore_delete_error ? MYF(0) : MYF(MY_WME))) ||
710714
(action_flag == CHF_RENAME_FLAG &&
711715
mysql_file_rename(key_file_ha_partition_par, old_name, name,
712716
MYF(MY_WME))))

sql/ha_partition.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ class ha_partition final :public handler
552552
HA_CREATE_INFO *create_info) override;
553553
int create_partitioning_metadata(const char *name,
554554
const char *old_name,
555-
chf_create_flags action_flag)
555+
chf_create_flags action_flag,
556+
bool ignore_delete_error)
556557
override;
557558
bool check_if_updates_are_ignored(const char *op) const override;
558559
void update_create_info(HA_CREATE_INFO *create_info) override;

sql/handler.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5696,7 +5696,8 @@ handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info_arg)
56965696
int
56975697
handler::ha_create_partitioning_metadata(const char *name,
56985698
const char *old_name,
5699-
chf_create_flags action_flag)
5699+
chf_create_flags action_flag,
5700+
bool ignore_delete_error)
57005701
{
57015702
/*
57025703
Normally this is done when unlocked, but in fast_alter_partition_table,
@@ -5706,7 +5707,8 @@ handler::ha_create_partitioning_metadata(const char *name,
57065707
DBUG_ASSERT(m_lock_type == F_UNLCK ||
57075708
(!old_name && strcmp(name, table_share->path.str)));
57085709

5709-
return create_partitioning_metadata(name, old_name, action_flag);
5710+
return create_partitioning_metadata(name, old_name, action_flag,
5711+
ignore_delete_error);
57105712
}
57115713

57125714

sql/handler.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,8 @@ class handler :public Sql_alloc
35293529
int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info);
35303530

35313531
int ha_create_partitioning_metadata(const char *name, const char *old_name,
3532-
chf_create_flags action_flag);
3532+
chf_create_flags action_flag,
3533+
bool ignore_delete_error= false);
35333534

35343535
int ha_change_partitions(HA_CREATE_INFO *create_info,
35353536
const char *path,
@@ -5071,7 +5072,8 @@ class handler :public Sql_alloc
50715072

50725073
virtual int create_partitioning_metadata(const char *name,
50735074
const char *old_name,
5074-
chf_create_flags action_flag)
5075+
chf_create_flags action_flag,
5076+
bool ignore_delete_error)
50755077
{ return FALSE; }
50765078

50775079
virtual int change_partitions(HA_CREATE_INFO *create_info,

sql/sql_table.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,8 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
21022102
handler *file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base);
21032103
if (!file)
21042104
DBUG_RETURN(true);
2105-
(void) file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG);
2105+
(void) file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG,
2106+
true);
21062107
delete file;
21072108
}
21082109
if (!(flags & (FRM_ONLY|NO_HA_TABLE)))

0 commit comments

Comments
 (0)