mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-29067 Online alter ignores check constraint violation
This commit is contained in:
@ -578,6 +578,39 @@ set debug_sync= 'reset';
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
create table t1 (a char(6), b int) engine=innodb;
|
||||||
|
insert t1 values ('abcde1',1),('abcde2',2);
|
||||||
|
set debug_sync= 'now wait_for downgraded';
|
||||||
|
connection con2;
|
||||||
|
set sql_mode='';
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
alter table t1 modify a char(4), algorithm=copy, lock=none;
|
||||||
|
connection default;
|
||||||
|
update t1 set b=b+10 where a='abcde2';
|
||||||
|
select * from t1;
|
||||||
|
a b
|
||||||
|
abcde1 1
|
||||||
|
abcde2 12
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
connection con2;
|
||||||
|
Warnings:
|
||||||
|
Warning 1265 Data truncated for column 'a' at row 1
|
||||||
|
Warning 1265 Data truncated for column 'a' at row 2
|
||||||
|
Warning 1265 Data truncated for column 'a' at row 3
|
||||||
|
set sql_mode=default;
|
||||||
|
connection default;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` char(4) DEFAULT NULL,
|
||||||
|
`b` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
select * from t1;
|
||||||
|
a b
|
||||||
|
abcd 1
|
||||||
|
abcd 12
|
||||||
|
drop table t1;
|
||||||
|
set debug_sync= 'reset';
|
||||||
#
|
#
|
||||||
# MDEV-28930 ALTER TABLE Deadlocks with parallel TL_WRITE
|
# MDEV-28930 ALTER TABLE Deadlocks with parallel TL_WRITE
|
||||||
#
|
#
|
||||||
@ -747,5 +780,110 @@ connection default;
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
set debug_sync= reset;
|
set debug_sync= reset;
|
||||||
#
|
#
|
||||||
|
# MDEV-29067 Online alter ignores check constraint violation
|
||||||
|
#
|
||||||
|
## CHECK, INSERT
|
||||||
|
create table t1 (a int);
|
||||||
|
insert t1 values (1),(2);
|
||||||
|
set debug_sync= 'now wait_for downgraded';
|
||||||
|
connection con2;
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
alter table t1 add check (a<10), algorithm=copy, lock=none;
|
||||||
|
connection default;
|
||||||
|
insert t1 values (11),(12);
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
connection con2;
|
||||||
|
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
|
||||||
|
connection default;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
2
|
||||||
|
11
|
||||||
|
12
|
||||||
|
drop table t1;
|
||||||
|
## DEFAULT, INSERT
|
||||||
|
create table t1 (a int);
|
||||||
|
insert t1 values (1),(2);
|
||||||
|
set debug_sync= 'now wait_for downgraded';
|
||||||
|
connection con2;
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
alter table t1 add b int default(a+10), algorithm=copy, lock=none;
|
||||||
|
connection default;
|
||||||
|
insert t1 values (11),(12);
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
connection con2;
|
||||||
|
connection default;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) DEFAULT NULL,
|
||||||
|
`b` int(11) DEFAULT (`a` + 10)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
select * from t1;
|
||||||
|
a b
|
||||||
|
1 11
|
||||||
|
2 12
|
||||||
|
11 21
|
||||||
|
12 22
|
||||||
|
drop table t1;
|
||||||
|
set debug_sync= 'reset';
|
||||||
|
## CHECK, UPDATE
|
||||||
|
create table t1 (a int) engine=innodb;
|
||||||
|
insert t1 values (1),(2),(3),(4);
|
||||||
|
set debug_sync= 'now wait_for downgraded';
|
||||||
|
connection con2;
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
alter table t1 add check (a<10), algorithm=copy, lock=none;
|
||||||
|
connection default;
|
||||||
|
update t1 set a=a+10 where a > 2;
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
connection con2;
|
||||||
|
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
|
||||||
|
connection default;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
2
|
||||||
|
13
|
||||||
|
14
|
||||||
|
drop table t1;
|
||||||
|
## DEFAULT, UPDATE
|
||||||
|
create table t1 (a int) engine=innodb;
|
||||||
|
insert t1 values (1),(2),(3),(4);
|
||||||
|
set debug_sync= 'now wait_for downgraded';
|
||||||
|
connection con2;
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
alter table t1 add b int default(a+10), algorithm=copy, lock=none;
|
||||||
|
connection default;
|
||||||
|
update t1 set a=a+10 where a > 2;
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
connection con2;
|
||||||
|
connection default;
|
||||||
|
show create table t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) DEFAULT NULL,
|
||||||
|
`b` int(11) DEFAULT (`a` + 10)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
select * from t1;
|
||||||
|
a b
|
||||||
|
1 11
|
||||||
|
2 12
|
||||||
|
13 23
|
||||||
|
14 24
|
||||||
|
drop table t1;
|
||||||
|
set debug_sync= 'reset';
|
||||||
|
#
|
||||||
# End of 11.2 tests
|
# End of 11.2 tests
|
||||||
#
|
#
|
||||||
|
@ -717,6 +717,30 @@ drop table t1;
|
|||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Lossy alter, Update_row_log_event cannot find 'abcde2' in the new table
|
||||||
|
#
|
||||||
|
create table t1 (a char(6), b int) engine=innodb;
|
||||||
|
insert t1 values ('abcde1',1),('abcde2',2);
|
||||||
|
--send set debug_sync= 'now wait_for downgraded'
|
||||||
|
--connection con2
|
||||||
|
set sql_mode='';
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
--send alter table t1 modify a char(4), algorithm=copy, lock=none
|
||||||
|
--connection default
|
||||||
|
--reap
|
||||||
|
update t1 set b=b+10 where a='abcde2';
|
||||||
|
select * from t1;
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
--connection con2
|
||||||
|
--reap
|
||||||
|
set sql_mode=default;
|
||||||
|
--connection default
|
||||||
|
show create table t1;
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
set debug_sync= 'reset';
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # MDEV-28930 ALTER TABLE Deadlocks with parallel TL_WRITE
|
--echo # MDEV-28930 ALTER TABLE Deadlocks with parallel TL_WRITE
|
||||||
--echo #
|
--echo #
|
||||||
@ -930,6 +954,86 @@ set sql_mode= default;
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
set debug_sync= reset;
|
set debug_sync= reset;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-29067 Online alter ignores check constraint violation
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo ## CHECK, INSERT
|
||||||
|
create table t1 (a int);
|
||||||
|
insert t1 values (1),(2);
|
||||||
|
--send set debug_sync= 'now wait_for downgraded'
|
||||||
|
--connection con2
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
--send alter table t1 add check (a<10), algorithm=copy, lock=none
|
||||||
|
--connection default
|
||||||
|
--reap
|
||||||
|
insert t1 values (11),(12);
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
--connection con2
|
||||||
|
--error ER_CONSTRAINT_FAILED
|
||||||
|
--reap
|
||||||
|
--connection default
|
||||||
|
show create table t1;
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
--echo ## DEFAULT, INSERT
|
||||||
|
create table t1 (a int);
|
||||||
|
insert t1 values (1),(2);
|
||||||
|
--send set debug_sync= 'now wait_for downgraded'
|
||||||
|
--connection con2
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
--send alter table t1 add b int default(a+10), algorithm=copy, lock=none
|
||||||
|
--connection default
|
||||||
|
--reap
|
||||||
|
insert t1 values (11),(12);
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
--connection con2
|
||||||
|
--reap
|
||||||
|
--connection default
|
||||||
|
show create table t1;
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
set debug_sync= 'reset';
|
||||||
|
|
||||||
|
--echo ## CHECK, UPDATE
|
||||||
|
create table t1 (a int) engine=innodb;
|
||||||
|
insert t1 values (1),(2),(3),(4);
|
||||||
|
--send set debug_sync= 'now wait_for downgraded'
|
||||||
|
--connection con2
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
--send alter table t1 add check (a<10), algorithm=copy, lock=none
|
||||||
|
--connection default
|
||||||
|
--reap
|
||||||
|
update t1 set a=a+10 where a > 2;
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
--connection con2
|
||||||
|
--error ER_CONSTRAINT_FAILED
|
||||||
|
--reap
|
||||||
|
--connection default
|
||||||
|
show create table t1;
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
--echo ## DEFAULT, UPDATE
|
||||||
|
create table t1 (a int) engine=innodb;
|
||||||
|
insert t1 values (1),(2),(3),(4);
|
||||||
|
--send set debug_sync= 'now wait_for downgraded'
|
||||||
|
--connection con2
|
||||||
|
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||||
|
--send alter table t1 add b int default(a+10), algorithm=copy, lock=none
|
||||||
|
--connection default
|
||||||
|
--reap
|
||||||
|
update t1 set a=a+10 where a > 2;
|
||||||
|
set debug_sync= 'now signal goforit';
|
||||||
|
--connection con2
|
||||||
|
--reap
|
||||||
|
--connection default
|
||||||
|
show create table t1;
|
||||||
|
select * from t1;
|
||||||
|
drop table t1;
|
||||||
|
set debug_sync= 'reset';
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 11.2 tests
|
--echo # End of 11.2 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -387,6 +387,12 @@ int unpack_row(rpl_group_info *rgi, TABLE *table, uint const colcnt,
|
|||||||
{
|
{
|
||||||
copy->do_copy(copy);
|
copy->do_copy(copy);
|
||||||
}
|
}
|
||||||
|
/* we only check constraints for ALTER TABLE */
|
||||||
|
DBUG_ASSERT(table->in_use->lex->ignore == FALSE);
|
||||||
|
error= table->verify_constraints(false);
|
||||||
|
DBUG_ASSERT(error != VIEW_CHECK_SKIP);
|
||||||
|
if (error)
|
||||||
|
DBUG_RETURN(HA_ERR_GENERIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table->default_field)
|
if (table->default_field)
|
||||||
|
Reference in New Issue
Block a user