Commit 7e0c8fc3 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-12389 ADD CHECK leaves an orphaned .par file

parent 152aec01
......@@ -51,3 +51,44 @@ execute stmt;
execute stmt;
deallocate prepare stmt;
drop table test_data;
create table t1(id int, d date not null, b bool not null default 0, primary key(id,d))
engine=innodb
partition by range columns (d) (
partition p1 values less than ('2016-10-18'),
partition p2 values less than ('2020-10-19'));
insert t1 values (0, '2000-01-02', 0);
insert t1 values (1, '2020-01-02', 10);
alter table t1 add check (b in (0, 1));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`d` date NOT NULL,
`b` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`,`d`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE COLUMNS(d)
(PARTITION p1 VALUES LESS THAN ('2016-10-18') ENGINE = InnoDB,
PARTITION p2 VALUES LESS THAN ('2020-10-19') ENGINE = InnoDB) */
insert t1 values (2, '2020-01-03', 20);
drop table t1;
create table t1(id int, d date not null, b bool not null default 0, primary key(id,d))
partition by range columns (d) (
partition p1 values less than ('2016-10-18'),
partition p2 values less than ('2020-10-19'));
insert t1 values (0, '2000-01-02', 0);
insert t1 values (1, '2020-01-02', 10);
alter table t1 add check (b in (0, 1));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`d` date NOT NULL,
`b` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`,`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE COLUMNS(d)
(PARTITION p1 VALUES LESS THAN ('2016-10-18') ENGINE = MyISAM,
PARTITION p2 VALUES LESS THAN ('2020-10-19') ENGINE = MyISAM) */
insert t1 values (2, '2020-01-03', 20);
drop table t1;
--source include/have_innodb.inc
--source include/have_partition.inc
CREATE TABLE `test_data` (
......@@ -64,3 +65,41 @@ deallocate prepare stmt;
drop table test_data;
#
# MDEV-12389 ADD CHECK leaves an orphaned .par file
#
--let $datadir=`SELECT @@datadir`
# InnoDB
create table t1(id int, d date not null, b bool not null default 0, primary key(id,d))
engine=innodb
partition by range columns (d) (
partition p1 values less than ('2016-10-18'),
partition p2 values less than ('2020-10-19'));
insert t1 values (0, '2000-01-02', 0);
insert t1 values (1, '2020-01-02', 10);
# should fail in 10.2
alter table t1 add check (b in (0, 1));
# should have CHECK in 10.2
show create table t1;
# should fail in 10.2
insert t1 values (2, '2020-01-03', 20);
drop table t1;
--list_files $datadir/test
# MyISAM, different execution path
create table t1(id int, d date not null, b bool not null default 0, primary key(id,d))
partition by range columns (d) (
partition p1 values less than ('2016-10-18'),
partition p2 values less than ('2020-10-19'));
insert t1 values (0, '2000-01-02', 0);
insert t1 values (1, '2020-01-02', 10);
# should fail in 10.2
alter table t1 add check (b in (0, 1));
# should have CHECK in 10.2
show create table t1;
# should fail in 10.2
insert t1 values (2, '2020-01-03', 20);
drop table t1;
--list_files $datadir/test
......@@ -8856,7 +8856,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
TODO don't create the frm in the first place
*/
deletefrm(alter_ctx.get_tmp_path());
const char *path= alter_ctx.get_tmp_path();
table->file->ha_create_partitioning_metadata(path, NULL, CHF_DELETE_FLAG);
deletefrm(path);
my_free(const_cast<uchar*>(frm.str));
goto end_inplace;
}
......
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