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
b08b78c5
Commit
b08b78c5
authored
Oct 21, 2022
by
Nikita Malyavin
Committed by
Sergei Golubchik
Aug 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-29068 Cascade foreign key updates do not apply in online alter
parent
84ed2e7c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
0 deletions
+103
-0
mysql-test/main/alter_table_online.result
mysql-test/main/alter_table_online.result
+40
-0
mysql-test/main/alter_table_online.test
mysql-test/main/alter_table_online.test
+51
-0
sql/sql_table.cc
sql/sql_table.cc
+12
-0
No files found.
mysql-test/main/alter_table_online.result
View file @
b08b78c5
...
...
@@ -80,3 +80,43 @@ XA END 'xid';
XA COMMIT 'xid' ONE PHASE;
DROP TABLE t;
disconnect con1;
connection default;
#
# MDEV-29068 Cascade foreign key updates do not apply in online alter
#
create table t1 (a int primary key) engine=InnoDB;
insert into t1 values (1),(2),(3);
create table t2 (b int, foreign key (b)
references t1 (a)
on update cascade) engine=InnoDB;
insert into t2 values (1),(2),(3);
alter table t2 add c int, algorithm=copy, lock=none;
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
alter table t2 add c int, algorithm=inplace, lock=none;
create or replace table t2 (b int, foreign key (b)
references t1 (a)
on delete set null) engine=InnoDB;
alter table t2 add c int, algorithm=copy, lock=none;
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
alter table t2 add c int, algorithm=inplace, lock=none;
create or replace table t2 (b int, foreign key (b)
references t1 (a)
on delete no action) engine=InnoDB;
insert into t2 values (1),(2),(3);
alter table t2 add c int, algorithm=copy, lock=none;
create or replace table t2 (b int, foreign key (b)
references t1 (a)
on update restrict) engine=InnoDB;
insert into t2 values (1),(2),(3);
alter table t2 add c int, algorithm=copy, lock=none;
drop table t2, t1;
create table t1 (a int primary key, b int unique) engine=InnoDB;
insert into t1 values (1, 1),(2, 2),(3, 3);
create table t2 (a int references t1 (a),
b int references t1 (b) on update cascade) engine=InnoDB;
insert into t2 values (1, 1),(2, 2);
alter table t2 add c int, algorithm=copy, lock=none;
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
alter table t2 add c int, algorithm=copy;
alter table t2 add d int, algorithm=inplace;
drop table t2, t1;
mysql-test/main/alter_table_online.test
View file @
b08b78c5
...
...
@@ -64,3 +64,54 @@ XA COMMIT 'xid' ONE PHASE;
DROP
TABLE
t
;
--
disconnect
con1
--
connection
default
--
echo
#
--
echo
# MDEV-29068 Cascade foreign key updates do not apply in online alter
--
echo
#
create
table
t1
(
a
int
primary
key
)
engine
=
InnoDB
;
insert
into
t1
values
(
1
),(
2
),(
3
);
create
table
t2
(
b
int
,
foreign
key
(
b
)
references
t1
(
a
)
on
update
cascade
)
engine
=
InnoDB
;
insert
into
t2
values
(
1
),(
2
),(
3
);
--
error
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter
table
t2
add
c
int
,
algorithm
=
copy
,
lock
=
none
;
alter
table
t2
add
c
int
,
algorithm
=
inplace
,
lock
=
none
;
create
or
replace
table
t2
(
b
int
,
foreign
key
(
b
)
references
t1
(
a
)
on
delete
set
null
)
engine
=
InnoDB
;
--
error
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter
table
t2
add
c
int
,
algorithm
=
copy
,
lock
=
none
;
alter
table
t2
add
c
int
,
algorithm
=
inplace
,
lock
=
none
;
create
or
replace
table
t2
(
b
int
,
foreign
key
(
b
)
references
t1
(
a
)
on
delete
no
action
)
engine
=
InnoDB
;
insert
into
t2
values
(
1
),(
2
),(
3
);
alter
table
t2
add
c
int
,
algorithm
=
copy
,
lock
=
none
;
create
or
replace
table
t2
(
b
int
,
foreign
key
(
b
)
references
t1
(
a
)
on
update
restrict
)
engine
=
InnoDB
;
insert
into
t2
values
(
1
),(
2
),(
3
);
alter
table
t2
add
c
int
,
algorithm
=
copy
,
lock
=
none
;
drop
table
t2
,
t1
;
create
table
t1
(
a
int
primary
key
,
b
int
unique
)
engine
=
InnoDB
;
insert
into
t1
values
(
1
,
1
),(
2
,
2
),(
3
,
3
);
create
table
t2
(
a
int
references
t1
(
a
),
b
int
references
t1
(
b
)
on
update
cascade
)
engine
=
InnoDB
;
insert
into
t2
values
(
1
,
1
),(
2
,
2
);
--
error
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter
table
t2
add
c
int
,
algorithm
=
copy
,
lock
=
none
;
alter
table
t2
add
c
int
,
algorithm
=
copy
;
alter
table
t2
add
d
int
,
algorithm
=
inplace
;
# Cleanup
drop
table
t2
,
t1
;
sql/sql_table.cc
View file @
b08b78c5
...
...
@@ -10071,6 +10071,18 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
online
=
online
&&
!
table
->
s
->
tmp_table
;
List
<
FOREIGN_KEY_INFO
>
fk_list
;
table
->
file
->
get_foreign_key_list
(
thd
,
&
fk_list
);
for
(
auto
&
fk
:
fk_list
)
{
if
(
fk_modifies_child
(
fk
.
delete_method
)
||
fk_modifies_child
(
fk
.
update_method
))
{
online
=
false
;
break
;
}
}
#ifdef WITH_WSREP
if
(
WSREP
(
thd
)
&&
(
thd
->
lex
->
sql_command
==
SQLCOM_ALTER_TABLE
||
...
...
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