mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-12389 ADD CHECK leaves an orphaned .par file
This commit is contained in:
@ -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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
--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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user