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
2a4c1902
Commit
2a4c1902
authored
Dec 07, 2020
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIXMEs, fixes, tests
- alter fix - Test definite order fix
parent
4f34732e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1326 additions
and
184 deletions
+1326
-184
mysql-test/include/foreign_fail.inc
mysql-test/include/foreign_fail.inc
+4
-1
mysql-test/suite/innodb/r/f.result
mysql-test/suite/innodb/r/f.result
+1250
-117
mysql-test/suite/innodb/t/f.test
mysql-test/suite/innodb/t/f.test
+40
-18
mysql-test/suite/parts/r/partition_debug_innodb.result
mysql-test/suite/parts/r/partition_debug_innodb.result
+4
-28
sql/datadict.cc
sql/datadict.cc
+1
-1
sql/sql_class.h
sql/sql_class.h
+19
-3
sql/sql_rename.cc
sql/sql_rename.cc
+1
-2
sql/sql_table.cc
sql/sql_table.cc
+7
-14
No files found.
mysql-test/include/foreign_fail.inc
View file @
2a4c1902
...
...
@@ -54,7 +54,7 @@ if ($crash_statement)
--
echo
# State after crash (before recovery)
--
list_files_write_file
$DATADIR
.
files
.
txt
$DATADIR
/
test
--
replace_result
#p# #P# #sp# #SP# #tmp# #TMP#
--
replace_regex
/
sql
-
exchange
.*
\
./
sql
-
exchange
./
/
sql
-
shadow
-
[
0
-
9
a
-
f
]
*-/
sql
-
shadow
-/
/
sql
-
alter
-
[
0
-
9
a
-
f
]
*-/
sql
-
alter
-/
/
#sql-ib[1-9][0-9]*\.ibd\n//
--
replace_regex
/
sql
-
exchange
.*
\
./
sql
-
exchange
./
/
sql
(
f
?
)
-
shadow
-
[
0
-
9
a
-
f
]
*-/
sql
\
1
-
shadow
-/
/
sql
-
alter
-
[
0
-
9
a
-
f
]
*-/
sql
-
alter
-/
/
#sql-ib[1-9][0-9]*\.ibd\n//
--
cat_file
$DATADIR
.
files
.
txt
--
remove_file
$DATADIR
.
files
.
txt
...
...
@@ -68,6 +68,9 @@ if ($crash_statement)
--
replace_regex
/
sql
-
alter
-
[
0
-
9
a
-
f
]
*-/
sql
-
alter
-/
/
#sql-ib[1-9][0-9]*\.ibd\n//
--
cat_file
$DATADIR
.
files
.
txt
--
remove_file
$DATADIR
.
files
.
txt
# TODO: when ALTER crashes it leaves tmp garbage. Should be fixed via DDL log
# (though engine files can left too).
--
remove_files_wildcard
$DATADIR
/
test
#sql-alter*.*
}
if
(
!
$crash_statement
)
...
...
mysql-test/suite/innodb/r/f.result
View file @
2a4c1902
...
...
@@ -306,8 +306,8 @@ set @@debug_dbug= "+d,crash_fk_write_shadow_frm";
drop tables t4, t1, t3, t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-
4-
t2.frm
#sqlf-shadow-
4-
t3.frm
#sqlf-shadow-t2.frm
#sqlf-shadow-t3.frm
db.opt
t1.MYD
t1.MYI
...
...
@@ -400,16 +400,16 @@ set @@debug_dbug= "+d,crash_fk_backup_frm";
drop tables t4, t1, t3, t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-
3-
t1.frm
#sqlf-shadow-
3-
t2.frm
#sqlf-shadow-
3-
t3.frm
#sqlf-shadow-t1.frm
#sqlf-shadow-t2.frm
#sqlf-shadow-t3.frm
db.opt
t1.MYD
t1.MYI
t1.f
bk
t1.f
rm
t2.MYD
t2.MYI
t2.f
rm
t2.f
bk
t3.MYD
t3.MYI
t3.fbk
...
...
@@ -495,15 +495,15 @@ set @@debug_dbug= "+d,crash_fk_install_shadow_frm";
drop tables t4, t1, t3, t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-
3-t2
.frm
#sqlf-shadow-
t1
.frm
db.opt
t1.MYD
t1.MYI
t1.fbk
t1.frm
t2.MYD
t2.MYI
t2.fbk
t2.frm
t3.MYD
t3.MYI
t3.fbk
...
...
@@ -768,8 +768,8 @@ set @@debug_dbug= "+d,crash_fk_write_shadow_frm";
create table t4 (a int primary key, x int references t1(x), y int references t2(y), z int references t3(z));
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-
3-t1
.frm
#sqlf-shadow-
3-
t3.frm
#sqlf-shadow-
t2
.frm
#sqlf-shadow-t3.frm
db.opt
t1.MYD
t1.MYI
...
...
@@ -834,19 +834,19 @@ set @@debug_dbug= "+d,crash_fk_backup_frm";
create table t4 (a int primary key, x int references t1(x), y int references t2(y), z int references t3(z));
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-
3-
t1.frm
#sqlf-shadow-
3-
t2.frm
#sqlf-shadow-
3-
t3.frm
#sqlf-shadow-t1.frm
#sqlf-shadow-t2.frm
#sqlf-shadow-t3.frm
db.opt
t1.MYD
t1.MYI
t1.f
bk
t1.f
rm
t2.MYD
t2.MYI
t2.fbk
t3.MYD
t3.MYI
t3.f
rm
t3.f
bk
t4.frm
# State after crash recovery
db.opt
...
...
@@ -901,12 +901,11 @@ set @@debug_dbug= "+d,crash_fk_install_shadow_frm";
create table t4 (a int primary key, x int references t1(x), y int references t2(y), z int references t3(z));
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-
3-t3
.frm
#sqlf-shadow-
t1
.frm
db.opt
t1.MYD
t1.MYI
t1.fbk
t1.frm
t2.MYD
t2.MYI
t2.fbk
...
...
@@ -914,6 +913,7 @@ t2.frm
t3.MYD
t3.MYI
t3.fbk
t3.frm
t4.frm
# State after crash recovery
db.opt
...
...
@@ -1217,27 +1217,26 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_
backup
_frm";
set @@debug_dbug= "+d,crash_fk_
write_shadow
_frm";
rename table t4 to xt4, t1 to xt1, t3 to xt3, t2 to xt2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-3-xt1.frm
#sqlf-shadow-3-xt2.frm
#sqlf-shadow-3-xt3.frm
#sqlf-shadow-3-xt4.frm
#sqlf-shadow-xt2.frm
#sqlf-shadow-xt3.frm
#sqlf-shadow-xt4.frm
db.opt
xt1.MYD
xt1.MYI
xt1.f
bk
xt1.f
rm
xt2.MYD
xt2.MYI
xt2.frm
xt3.MYD
xt3.MYI
xt3.f
bk
xt3.f
rm
xt4.MYD
xt4.MYI
xt4.f
bk
xt4.f
rm
# State after crash recovery
db.opt
xt1.MYD
...
...
@@ -1316,24 +1315,24 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_
install_shadow
_frm";
set @@debug_dbug= "+d,crash_fk_
backup
_frm";
rename table t4 to xt4, t1 to xt1, t3 to xt3, t2 to xt2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-3-xt4.frm
#sqlf-shadow-xt1.frm
#sqlf-shadow-xt2.frm
#sqlf-shadow-xt3.frm
#sqlf-shadow-xt4.frm
db.opt
xt1.MYD
xt1.MYI
xt1.fbk
xt1.frm
xt2.MYD
xt2.MYI
xt2.fbk
xt2.frm
xt3.MYD
xt3.MYI
xt3.fbk
xt3.frm
xt4.MYD
xt4.MYI
xt4.fbk
...
...
@@ -1386,7 +1385,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before
failure
# State before
crash
db.opt
t1.MYD
t1.MYI
...
...
@@ -1415,23 +1414,44 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_write_shadow_frm";
alter table t3 rename xt3;
ERROR HY000: Unknown error
# State after failure
set @@debug_dbug= "+d,crash_fk_install_shadow_frm";
rename table t4 to xt4, t1 to xt1, t3 to xt3, t2 to xt2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-xt1.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
xt1.MYD
xt1.MYI
xt1.fbk
xt2.MYD
xt2.MYI
xt2.fbk
xt2.frm
xt3.MYD
xt3.MYI
xt3.fbk
xt3.frm
xt4.MYD
xt4.MYI
xt4.fbk
xt4.frm
# State after crash recovery
db.opt
xt1.MYD
xt1.MYI
xt1.frm
xt2.MYD
xt2.MYI
xt2.frm
xt3.MYD
xt3.MYI
xt3.frm
xt4.MYD
xt4.MYI
xt4.frm
set foreign_key_checks= 0;
rename table xt4 to t4, xt3 to t3, xt2 to t2, xt1 to t1;
set foreign_key_checks= 1;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
...
...
@@ -1493,7 +1513,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_
backup
_frm";
set @@debug_dbug= "+d,fail_fk_
write_shadow
_frm";
alter table t3 rename xt3;
ERROR HY000: Unknown error
# State after failure
...
...
@@ -1571,7 +1591,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_
install_shadow
_frm";
set @@debug_dbug= "+d,fail_fk_
backup
_frm";
alter table t3 rename xt3;
ERROR HY000: Unknown error
# State after failure
...
...
@@ -1604,9 +1624,6 @@ test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
call drop_tables;
# RENAME COLUMN
call make_tables;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
...
...
@@ -1652,8 +1669,8 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_
write
_shadow_frm";
alter table t
2 change y z int, change x y int, change b c int
;
set @@debug_dbug= "+d,fail_fk_
install
_shadow_frm";
alter table t
3 rename xt3
;
ERROR HY000: Unknown error
# State after failure
db.opt
...
...
@@ -1701,7 +1718,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before
failure
# State before
crash
db.opt
t1.MYD
t1.MYI
...
...
@@ -1730,10 +1747,25 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_backup_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Unknown error
# State after failure
set @@debug_dbug= "+d,crash_fk_write_shadow_frm";
alter table t3 rename xt3;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-t4.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
# State after crash recovery
db.opt
t1.MYD
t1.MYI
...
...
@@ -1779,7 +1811,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before
failure
# State before
crash
db.opt
t1.MYD
t1.MYI
...
...
@@ -1808,10 +1840,26 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_install_shadow_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Unknown error
# State after failure
set @@debug_dbug= "+d,crash_fk_backup_frm";
alter table t3 rename xt3;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-t2.frm
#sqlf-shadow-t4.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.fbk
# State after crash recovery
db.opt
t1.MYD
t1.MYI
...
...
@@ -1857,7 +1905,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before
failure
# State before
crash
db.opt
t1.MYD
t1.MYI
...
...
@@ -1886,10 +1934,26 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_backup_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Unknown error
# State after failure
set @@debug_dbug= "+d,crash_fk_install_shadow_frm";
alter table t3 rename xt3;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlf-shadow-t2.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.fbk
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.fbk
t4.frm
# State after crash recovery
db.opt
t1.MYD
t1.MYI
...
...
@@ -1919,6 +1983,9 @@ test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
call drop_tables;
# RENAME COLUMN
call make_tables;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
...
...
@@ -1964,8 +2031,8 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_
install
_shadow_frm";
alter table t
3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2
;
set @@debug_dbug= "+d,fail_fk_
write
_shadow_frm";
alter table t
2 change y z int, change x y int, change b c int
;
ERROR HY000: Unknown error
# State after failure
db.opt
...
...
@@ -1997,24 +2064,6 @@ test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
call drop_tables;
# ADD/DROP FOREIGN KEY, DROP COLUMN
call make_tables;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`x` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`z` int(11) NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`z`),
KEY `fk_t3` (`x`),
KEY `fk_t3_2` (`y`),
KEY `fk_t3_3` (`c`),
CONSTRAINT `fk_t3` FOREIGN KEY (`x`) REFERENCES `t2` (`x`),
CONSTRAINT `fk_t3_2` FOREIGN KEY (`y`) REFERENCES `t2` (`y`),
CONSTRAINT `fk_t3_3` FOREIGN KEY (`c`) REFERENCES `t3` (`z`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
...
...
@@ -2060,14 +2109,8 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_write_shadow_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
set @@debug_dbug= "+d,fail_fk_backup_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Unknown error
# State after failure
db.opt
...
...
@@ -2144,14 +2187,8 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_backup_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
set @@debug_dbug= "+d,fail_fk_install_shadow_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Unknown error
# State after failure
db.opt
...
...
@@ -2199,7 +2236,7 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before
failure
# State before
crash
db.opt
t1.MYD
t1.MYI
...
...
@@ -2228,16 +2265,1112 @@ test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_install_shadow_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
ERROR HY000: Unknown error
# State after failure
set @@debug_dbug= "+d,crash_fk_write_shadow_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.frm
#sqlf-shadow-t4.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
# State after crash recovery
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before crash
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_backup_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.frm
#sqlf-shadow-t3.frm
#sqlf-shadow-t4.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.fbk
# State after crash recovery
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before crash
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_install_shadow_frm";
alter table t2 change y z int, change x y int, change b c int;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.frm
#sqlf-shadow-t3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.fbk
t4.MYD
t4.MYI
t4.fbk
t4.frm
# State after crash recovery
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_write_shadow_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Unknown error
# State after failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_backup_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Unknown error
# State after failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_install_shadow_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Unknown error
# State after failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before crash
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_write_shadow_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
# State after crash recovery
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before crash
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_backup_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.frm
#sqlf-shadow-t4.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
# State after crash recovery
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before crash
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_install_shadow_frm";
alter table t3 rename column z to z2, rename column y to y2, rename column x to x2, rename column c to c2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.frm
#sqlf-shadow-t4.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.fbk
# State after crash recovery
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
call drop_tables;
# ADD/DROP FOREIGN KEY, DROP COLUMN
call make_tables;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`x` int(11) DEFAULT NULL,
`y` int(11) DEFAULT NULL,
`z` int(11) NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`z`),
KEY `fk_t3` (`x`),
KEY `fk_t3_2` (`y`),
KEY `fk_t3_3` (`c`),
CONSTRAINT `fk_t3` FOREIGN KEY (`x`) REFERENCES `t2` (`x`),
CONSTRAINT `fk_t3_2` FOREIGN KEY (`y`) REFERENCES `t2` (`y`),
CONSTRAINT `fk_t3_3` FOREIGN KEY (`c`) REFERENCES `t3` (`z`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_write_shadow_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
ERROR HY000: Unknown error
# State after failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_backup_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
ERROR HY000: Unknown error
# State after failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,fail_fk_install_shadow_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
ERROR HY000: Unknown error
# State after failure
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set session debug_dbug=@save_dbug;
set @save_dbug=@@debug_dbug;
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
# State before crash
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
check tables t1, t2, t3, t4;
Table Op Msg_type Msg_text
test.t1 check Note Found 2 referenced keys
test.t1 check Note Found 1 self-references
test.t1 check status OK
test.t2 check Note Found 3 referenced keys
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 self-references
test.t2 check status OK
test.t3 check Note Found 1 referenced keys
test.t3 check Note Found 2 foreign keys
test.t3 check Note Found 1 self-references
test.t3 check status OK
test.t4 check Note Found 3 foreign keys
test.t4 check status OK
set @@debug_dbug= "+d,crash_fk_write_shadow_frm";
alter table t3
drop foreign key fk_t3,
drop foreign key fk_t3_2,
drop foreign key fk_t3_3,
drop c,
add foreign key (x) references t1(x),
add foreign key (y) references t2(x);
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sql-alter-3.MYD
#sql-alter-3.MYI
#sql-alter-3.frm
#sqlf-shadow-t2.frm
db.opt
t1.MYD
t1.MYI
t1.frm
t2.MYD
t2.MYI
t2.frm
t3.MYD
t3.MYI
t3.frm
t4.MYD
t4.MYI
t4.frm
# State after crash recovery
#sql-alter-3.MYD
#sql-alter-3.MYI
#sql-alter-3.frm
db.opt
t1.MYD
t1.MYI
...
...
mysql-test/suite/innodb/t/f.test
View file @
2a4c1902
--
source
include
/
have_innodb
.
inc
--
source
include
/
have_debug
.
inc
# Don't test this under valgrind, memory leaks will occur
--
source
include
/
not_valgrind
.
inc
# Crash tests don't work with embedded
--
source
include
/
not_embedded
.
inc
# In fail_fk_backup_frm the log is already written but rename is not done
call
mtr
.
add_suppression
(
"Failed to execute action for entry"
);
...
...
@@ -60,8 +64,6 @@ let $debug_dbug="+d,crash_fk_install_shadow_frm";
--
source
include
/
foreign_fail
.
inc
call
drop_tables
;
# FIXME: crash statements
--
echo
# CREATE TABLE
create
table
t1
(
x
int
primary
key
);
create
table
t2
(
y
int
primary
key
);
...
...
@@ -100,11 +102,13 @@ let $debug_dbug="+d,fail_fk_backup_frm";
let
$debug_dbug
=
"+d,fail_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$crash_statement
=
$fail_statement
;
# TODO:
rollback RENAME TABLE (and other DDL?)
via DDL log
# TODO:
RENAME TABLE is not crash-safe itself, so rollback it
via DDL log
# NB: if we rename back in different order we'll lose some referenced hints
# (Foreign_key_io::parse() skips them if it can't find table by name)
# MDEV-23433 solves the problem of missing referenced hints
let
$fixup_statement
=
rename
table
xt4
to
t4
,
xt3
to
t3
,
xt2
to
t2
,
xt1
to
t1
;
let
$debug_dbug
=
"+d,crash_fk_write_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_backup_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_install_shadow_frm"
;
...
...
@@ -118,11 +122,13 @@ let $debug_dbug="+d,fail_fk_backup_frm";
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,fail_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
#let $crash_statement= $fail_statement;
#let $debug_dbug="+d,crash_fk_backup_frm";
#--source include/foreign_fail.inc
#let $debug_dbug="+d,crash_fk_install_shadow_frm";
#--source include/foreign_fail.inc
let
$crash_statement
=
$fail_statement
;
let
$debug_dbug
=
"+d,crash_fk_write_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_backup_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
call
drop_tables
;
--
echo
# RENAME COLUMN
...
...
@@ -136,16 +142,34 @@ let $debug_dbug="+d,fail_fk_backup_frm";
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,fail_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$crash_statement
=
$fail_statement
;
let
$debug_dbug
=
"+d,crash_fk_write_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_backup_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$fail_statement
=
alter
table
t3
rename
column
z
to
z2
,
rename
column
y
to
y2
,
rename
column
x
to
x2
,
rename
column
c
to
c2
;
--
let
$crash_statement
=
let
$debug_dbug
=
"+d,fail_fk_write_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,fail_fk_backup_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,fail_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$crash_statement
=
$fail_statement
;
let
$debug_dbug
=
"+d,crash_fk_write_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_backup_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,crash_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
call
drop_tables
;
--
echo
# ADD/DROP FOREIGN KEY, DROP COLUMN
call
make_tables
;
--
let
$create_statement
=
--
let
$crash_statement
=
show
create
table
t3
;
let
$fail_statement
=
alter
table
t3
drop
foreign
key
fk_t3
,
...
...
@@ -160,18 +184,16 @@ let $debug_dbug="+d,fail_fk_backup_frm";
--
source
include
/
foreign_fail
.
inc
let
$debug_dbug
=
"+d,fail_fk_install_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
let
$crash_statement
=
$fail_statement
;
let
$debug_dbug
=
"+d,crash_fk_write_shadow_frm"
;
--
source
include
/
foreign_fail
.
inc
# TODO: ALTER TABLE is not crash-safe itself, so rollback it via DDL log
#let $debug_dbug="+d,crash_fk_backup_frm";
#--source include/foreign_fail.inc
#let $debug_dbug="+d,crash_fk_install_shadow_frm";
#--source include/foreign_fail.inc
call
drop_tables
;
#set @save_dbug=@@debug_dbug;
#let $create_statement= create or replace table t1 (id int primary key);
#let $create_statement2= create or replace table t2 (id int);
#let $insert_statement= insert into t1 values(1);
#let $insert_statement2= insert into t2 values(1);
#set session debug_dbug="+d,crash_fk_alter_1";
#let $crash_statement= alter table t2 add foreign key (id) references t1(id), algorithm=copy;
#--source suite/parts/inc/partition_crash_t2.inc
drop
procedure
make_tables
;
drop
procedure
drop_tables
;
set
session
debug_dbug
=@
save_dbug
;
mysql-test/suite/parts/r/partition_debug_innodb.result
View file @
2a4c1902
...
...
@@ -388,13 +388,7 @@ a b
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.ibd
db.opt
t1#P#p0.ibd
t1#P#p1.ibd
t1.frm
t1.par
t2.frm
#sql-exchange.frm
# State after crash recovery
db.opt
t1#P#p0.ibd
...
...
@@ -496,13 +490,7 @@ a b
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.ibd
db.opt
t1#P#p0.ibd
t1#P#p1.ibd
t1.frm
t1.par
t2.frm
#sql-exchange.frm
# State after crash recovery
db.opt
t1#P#p0.ibd
...
...
@@ -604,13 +592,7 @@ a b
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.ibd
db.opt
t1#P#p1.ibd
t1.frm
t1.par
t2.frm
t2.ibd
#sql-exchange.ibd
# State after crash recovery
db.opt
t1#P#p0.ibd
...
...
@@ -712,13 +694,7 @@ a b
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
ERROR HY000: Lost connection to MySQL server during query
# State after crash (before recovery)
#sqlx-nnnn_nnnn.ibd
db.opt
t1#P#p1.ibd
t1.frm
t1.par
t2.frm
t2.ibd
#sql-exchange.ibd
# State after crash recovery
db.opt
t1#P#p0.ibd
...
...
sql/datadict.cc
View file @
2a4c1902
...
...
@@ -767,7 +767,7 @@ void FK_backup_storage::drop_backup_frms(THD *thd)
continue
;
if
(
deactivate_ddl_log_entry
(
bak
.
second
.
restore_backup_entry
->
entry_pos
))
{
//
FIXME
: test getting into here (and other deactivate_ddl_log_entry() failures)
//
TODO
: test getting into here (and other deactivate_ddl_log_entry() failures)
my_printf_error
(
ER_DDL_LOG_ERROR
,
"Deactivating restore backup entry %u failed"
,
MYF
(
0
),
bak
.
second
.
restore_backup_entry
->
entry_pos
);
// TODO: must be atomic
...
...
sql/sql_class.h
View file @
2a4c1902
...
...
@@ -1023,7 +1023,7 @@ class FK_share_backup : public FK_backup
};
// NB: FK_ddl_backup responds for share release unlike FK_
tabl
e_backup
// NB: FK_ddl_backup responds for share release unlike FK_
shar
e_backup
class
FK_ddl_backup
:
public
FK_share_backup
{
/* NB: if sa.share is not empty, share is auto-released on destructor */
...
...
@@ -1032,7 +1032,7 @@ class FK_ddl_backup : public FK_share_backup
NB: if sa.share is not empty, share == sa.share. ALTER algorithms are more
complex and shares are held and released in separate container alter_ctx.fk_shares.
To make DDL logging common for all commands we handle it via FK_backup_storage interface, but
without templating and virtual interfaces (these are overcomplexity for only 2 varia
tion
s)
without templating and virtual interfaces (these are overcomplexity for only 2 varia
nt
s)
we have to converge backup operations into single FK_ddl_backup.
*/
...
...
@@ -1057,6 +1057,17 @@ class FK_ddl_backup : public FK_share_backup
bool
backup_frm
(
ddl_log_info
&
log_info
,
Table_name
table
);
};
#ifndef DBUG_OFF
// NB: we do want definite order of shares in test cases
struct
TABLE_SHARE_by_name
{
bool
operator
()
(
const
TABLE_SHARE
*
s1
,
const
TABLE_SHARE
*
s2
)
const
{
return
s1
->
cmp_db_table
(
s2
->
db
,
s2
->
table_name
)
<
0
;
}
};
#endif
/*
NB: again, ALTER does require duplicate check hence mbd::map is used, while other commands
...
...
@@ -1064,7 +1075,12 @@ class FK_ddl_backup : public FK_share_backup
ifaces we just use mbd::map for everything. We are not going to hit bottleneck here:
it is DDL (rare operation), it is less than hundred of foreign keys normally.
*/
class
FK_backup_storage
:
public
mbd
::
map
<
TABLE_SHARE
*
,
FK_ddl_backup
>
,
public
ddl_log_info
class
FK_backup_storage
:
public
mbd
::
map
<
TABLE_SHARE
*
,
FK_ddl_backup
#ifndef DBUG_OFF
,
TABLE_SHARE_by_name
#endif
>
,
public
ddl_log_info
{
public:
int
write_shadow_frms
();
...
...
sql/sql_rename.cc
View file @
2a4c1902
...
...
@@ -348,8 +348,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
Shared table. Just drop the old .frm as it's not correct anymore
Discovery will find the old table when it's accessed
*/
// FIXME: tdc_remove_table() is now done later. Does that work?
// tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str);
tdc_remove_table
(
thd
,
ren_table
->
db
.
str
,
ren_table
->
table_name
.
str
);
quick_rm_table
(
thd
,
0
,
&
ren_table
->
db
,
&
old_alias
,
FRM_ONLY
,
0
);
DBUG_RETURN
(
0
);
}
...
...
sql/sql_table.cc
View file @
2a4c1902
...
...
@@ -8191,7 +8191,8 @@ static bool mysql_inplace_alter_table(THD *thd,
if
(
wait_while_table_is_used
(
thd
,
table
,
HA_EXTRA_PREPARE_FOR_RENAME
))
goto
rollback
;
if
(
alter_ctx
->
fk_handle_alter
(
thd
))
if
(
alter_ctx
->
fk_handle_alter
(
thd
)
||
alter_ctx
->
fk_ref_backup
.
install_shadow_frms
())
goto
rollback
;
/* Set MDL_BACKUP_DDL */
...
...
@@ -8262,13 +8263,15 @@ static bool mysql_inplace_alter_table(THD *thd,
{
my_error
(
HA_ERR_INCOMPATIBLE_DEFINITION
,
MYF
(
0
));
alter_ctx
->
fk_ref_backup
.
rollback
(
thd
);
// FIXME: why not goto rollback?
goto
cleanup
;
}
}
table
->
s
->
frm_image
=
NULL
;
alter_ctx
->
fk_ref_backup
.
drop_backup_frms
(
thd
);
alter_ctx
->
fk_ref_backup
.
clear
();
close_all_tables_for_name
(
thd
,
table
->
s
,
alter_ctx
->
is_table_renamed
()
?
HA_EXTRA_PREPARE_FOR_RENAME
:
...
...
@@ -8276,15 +8279,6 @@ static bool mysql_inplace_alter_table(THD *thd,
NULL
);
table_list
->
table
=
table
=
NULL
;
// FIXME: do right after fk_handle_alter?
if
(
alter_ctx
->
fk_ref_backup
.
install_shadow_frms
())
{
alter_ctx
->
fk_ref_backup
.
rollback
(
thd
);
DBUG_RETURN
(
true
);
}
alter_ctx
->
fk_ref_backup
.
drop_backup_frms
(
thd
);
/*
Replace the old .FRM with the new .FRM, but keep the old name for now.
Rename to the new name (if needed) will be handled separately below.
...
...
@@ -8310,7 +8304,6 @@ static bool mysql_inplace_alter_table(THD *thd,
if
(
mysql_rename_table
(
db_type
,
&
alter_ctx
->
db
,
&
alter_ctx
->
table_name
,
&
alter_ctx
->
new_db
,
&
alter_ctx
->
new_alias
,
0
))
{
// FIXME: rollback only table name
/*
If the rename fails we will still have a working table
with the old name, but with other changes applied.
...
...
@@ -8331,7 +8324,6 @@ static bool mysql_inplace_alter_table(THD *thd,
(
void
)
mysql_rename_table
(
db_type
,
&
alter_ctx
->
new_db
,
&
alter_ctx
->
new_alias
,
&
alter_ctx
->
db
,
&
alter_ctx
->
alias
,
NO_FK_CHECKS
);
// FIXME: if rename succeeds rollback only table name
DBUG_RETURN
(
true
);
}
rename_table_in_stat_tables
(
thd
,
&
alter_ctx
->
db
,
&
alter_ctx
->
alias
,
...
...
@@ -11252,6 +11244,7 @@ do_continue:;
if
(
wait_while_table_is_used
(
thd
,
table
,
HA_EXTRA_PREPARE_FOR_RENAME
))
goto
err_new_table_cleanup
;
alter_ctx
.
fk_ref_backup
.
erase
(
table
->
s
);
if
(
alter_ctx
.
fk_handle_alter
(
thd
))
// NB: now after lock upgrade it jumps to "err_with_mdl" as well
goto
err_new_table_cleanup
;
...
...
@@ -13191,7 +13184,7 @@ bool fk_handle_rename(THD *thd, TABLE_LIST *old_table, const LEX_CSTRING *new_db
if
(
share
->
foreign_keys
.
is_empty
()
&&
share
->
referenced_keys
.
is_empty
())
return
false
;
mbd
::
set
<
Table_name
>
tables
;
mbd
::
set
<
Table_name
>
already
;
// FIXME: do we need it for mbd::map?
mbd
::
set
<
Table_name
>
already
;
MDL_request_list
mdl_list
;
for
(
auto
&
bak
:
fk_rename_backup
)
{
...
...
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