Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
aa1a2507
Commit
aa1a2507
authored
Jul 15, 2022
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-29067 Online alter ignores check constraint violation
parent
472c3d08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
248 additions
and
0 deletions
+248
-0
mysql-test/main/alter_table_online_debug.result
mysql-test/main/alter_table_online_debug.result
+138
-0
mysql-test/main/alter_table_online_debug.test
mysql-test/main/alter_table_online_debug.test
+104
-0
sql/rpl_record.cc
sql/rpl_record.cc
+6
-0
No files found.
mysql-test/main/alter_table_online_debug.result
View file @
aa1a2507
...
...
@@ -578,6 +578,39 @@ set debug_sync= 'reset';
drop table t1;
drop table t2;
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
#
...
...
@@ -747,5 +780,110 @@ connection default;
drop table t1;
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
#
mysql-test/main/alter_table_online_debug.test
View file @
aa1a2507
...
...
@@ -717,6 +717,30 @@ drop table t1;
drop
table
t2
;
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
# MDEV-28930 ALTER TABLE Deadlocks with parallel TL_WRITE
--
echo
#
...
...
@@ -930,6 +954,86 @@ set sql_mode= default;
drop
table
t1
;
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
# End of 11.2 tests
--
echo
#
sql/rpl_record.cc
View file @
aa1a2507
...
...
@@ -387,6 +387,12 @@ int unpack_row(rpl_group_info *rgi, TABLE *table, uint const colcnt,
{
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment