mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
@ -1,6 +1,8 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
|
||||
--enable_connect_log
|
||||
|
||||
--echo #
|
||||
--echo # Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE
|
||||
--echo # ADD FOREIGN KEY
|
||||
@ -24,3 +26,49 @@ ALTER TABLE `title` ADD FOREIGN KEY (`title_reporter_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
|
||||
drop table title, department, people;
|
||||
|
||||
#
|
||||
# FK and prelocking:
|
||||
# child table accesses (reads and writes) wait for locks.
|
||||
#
|
||||
create table t1 (a int primary key, b int) engine=innodb;
|
||||
create table t2 (c int primary key, d int,
|
||||
foreign key (d) references t1 (a) on update cascade) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
insert t2 values (4,1),(5,2),(6,3);
|
||||
flush table t2 with read lock; # this takes MDL_SHARED_NO_WRITE
|
||||
connect (con1,localhost,root);
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
delete from t1 where a=2;
|
||||
send update t1 set a=10 where a=1;
|
||||
connection default;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
|
||||
source include/wait_condition.inc;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
reap;
|
||||
connection default;
|
||||
lock table t2 write; # this takes MDL_SHARED_NO_READ_WRITE
|
||||
connection con1;
|
||||
send delete from t1 where a=2;
|
||||
connection default;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
|
||||
source include/wait_condition.inc;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
reap;
|
||||
connection default;
|
||||
unlock tables;
|
||||
disconnect con1;
|
||||
|
||||
# but privileges should not be checked
|
||||
create user foo;
|
||||
grant select,update on test.t1 to foo;
|
||||
connect(foo,localhost,foo);
|
||||
update t1 set a=30 where a=3;
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from t2;
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
|
Reference in New Issue
Block a user