Skip to content
Permalink
Browse files

MDEV-12923 MyISAM allows CHECK constraint violation in ALTER TABLE

use correct type for Alter_inplace_info flags.
  • Loading branch information...
vuvova committed Jun 24, 2017
1 parent 9edfc00 commit 7bea860709cf63d3180c934ab75d7042e0cd8867
@@ -1925,8 +1925,8 @@ ALTER TABLE ti1 FORCE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE tm1 FORCE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
ALTER TABLE ti1 AUTO_INCREMENT 3;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
@@ -83,14 +83,16 @@ 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));
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`#sql-temporary`
alter table t1 add check (b in (0, 10));
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`),
CONSTRAINT `CONSTRAINT_1` CHECK (`b` in (0,1))
CONSTRAINT `CONSTRAINT_1` CHECK (`b` in (0,10))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
PARTITION BY RANGE COLUMNS(d)
(PARTITION p1 VALUES LESS THAN ('2016-10-18') ENGINE = MyISAM,
@@ -96,8 +96,10 @@ 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);
# FIXME: MDEV-12923 MyISAM allows CHECK constraint violation in ALTER TABLE
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CONSTRAINT_FAILED
alter table t1 add check (b in (0, 1));
alter table t1 add check (b in (0, 10));
show create table t1;
--error ER_CONSTRAINT_FAILED
insert t1 values (2, '2020-01-03', 20);
@@ -2291,16 +2291,19 @@ ha_myisam::check_if_supported_inplace_alter(TABLE *new_table,
{
DBUG_ENTER("ha_myisam::check_if_supported_inplace_alter");

const uint readd_index= Alter_inplace_info::ADD_INDEX |
const Alter_inplace_info::HA_ALTER_FLAGS readd_index=
Alter_inplace_info::ADD_INDEX |
Alter_inplace_info::DROP_INDEX;
const uint readd_unique= Alter_inplace_info::ADD_UNIQUE_INDEX |
Alter_inplace_info::DROP_UNIQUE_INDEX;
const uint readd_pk= Alter_inplace_info::ADD_PK_INDEX |
Alter_inplace_info::DROP_PK_INDEX;
const Alter_inplace_info::HA_ALTER_FLAGS readd_unique=
Alter_inplace_info::ADD_UNIQUE_INDEX |
Alter_inplace_info::DROP_UNIQUE_INDEX;
const Alter_inplace_info::HA_ALTER_FLAGS readd_pk=
Alter_inplace_info::ADD_PK_INDEX |
Alter_inplace_info::DROP_PK_INDEX;

const uint op= alter_info->handler_flags;
const Alter_inplace_info::HA_ALTER_FLAGS op= alter_info->handler_flags;

if (alter_info->handler_flags & Alter_inplace_info::ALTER_COLUMN_VCOL)
if (op & Alter_inplace_info::ALTER_COLUMN_VCOL)
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);

/*

0 comments on commit 7bea860

Please sign in to comment.
You can’t perform that action at this time.