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

MDEV-12923 MyISAM allows CHECK constraint violation in ALTER TABLE

use correct type for Alter_inplace_info flags.
parent 9edfc006
......@@ -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,6 +83,8 @@ 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` (
......@@ -90,7 +92,7 @@ t1 CREATE TABLE `t1` (
`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);
/*
......
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