mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 01:04:19 +01:00
6aa9a552c2
There are a few different cases to consider Logging of CREATE TABLE and CREATE TABLE ... LIKE - If REPLACE is used and there was an existing table, DDL log the drop of the table. - If discovery of table is to be done - DDL LOG create table else - DDL log create table (with engine type) - create the table - If table was created - Log entry to binary log with xid - Mark DDL log completed Crash recovery: - If query was in binary log do nothing and exit - If discoverted table - Delete the .frm file -else - Drop created table and frm file - If table was dropped, write a DROP TABLE statement in binary log CREATE TABLE ... SELECT required a little more work as when one is using statement logging the query is written to the binary log before commit is done. This was fixed by adding a DROP TABLE to the binary log during crash recovery if the ddl log entry was not closed. In this case the binary log will contain: CREATE TABLE xxx ... SELECT .... DROP TABLE xxx; Other things: - Added debug_crash_here() functionality to Aria to be able to test crash in create table between the creation of the .MAI and the .MAD files.
130 lines
4 KiB
Text
130 lines
4 KiB
Text
CALL mtr.add_suppression("Operating system error number");
|
|
CALL mtr.add_suppression("The error means the system cannot");
|
|
CALL mtr.add_suppression("returned OS error 71");
|
|
#Test1: table with missing .ibd can be dropped directly
|
|
create table t1(a int)engine=innodb;
|
|
drop table t1;
|
|
db.opt
|
|
# Test droping table without frm without super privilege
|
|
create table t1(a int) engine=innodb;
|
|
create user test identified by '123456';
|
|
grant all privileges on test.t1 to 'test'@'%'identified by '123456';
|
|
connect con_test, localhost, test,'123456', ;
|
|
connection con_test;
|
|
drop table t1;
|
|
drop table t1;
|
|
ERROR 42S02: Unknown table 'test.t1'
|
|
connection default;
|
|
disconnect con_test;
|
|
drop user test;
|
|
db.opt
|
|
#Test5: drop table with triger, and with missing frm
|
|
create table t1(a int)engine=innodb;
|
|
create trigger t1_trg before insert on t1 for each row begin end;
|
|
drop table t1;
|
|
drop table t1;
|
|
ERROR 42S02: Unknown table 'test.t1'
|
|
db.opt
|
|
#Test6: table with foreign key references can not be dropped
|
|
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
|
CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB;
|
|
drop table parent;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table child;
|
|
drop table parent;
|
|
db.opt
|
|
#Test7: drop table twice
|
|
create table t1(a int)engine=innodb;
|
|
drop table t1;
|
|
db.opt
|
|
drop table if exists t1;
|
|
Warnings:
|
|
Note 1051 Unknown table 'test.t1'
|
|
db.opt
|
|
#Test9: check compatibility with restrict/cascade
|
|
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
|
CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB;
|
|
drop table parent;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table parent restrict;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table parent cascade;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table parent;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table parent restrict;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table parent cascade;
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
drop table child;
|
|
drop table parent;
|
|
#Test10: drop non-innodb engine table returns ok
|
|
create table t1(a int) engine=myisam;
|
|
drop table t1;
|
|
create table t1(a int) engine=myisam;
|
|
drop table t1;
|
|
Warnings:
|
|
Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
|
|
create table t1(a int) engine=myisam;
|
|
drop table t1;
|
|
Warnings:
|
|
Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
|
|
db.opt
|
|
create table t1(a int) engine=aria;
|
|
db.opt
|
|
t1.MAI
|
|
drop table t1;
|
|
ERROR 42S02: Unknown table 'test.t1'
|
|
show warnings;
|
|
Level Code Message
|
|
Error 1051 Unknown table 'test.t1'
|
|
db.opt
|
|
create table t2(a int) engine=aria;
|
|
flush tables;
|
|
db.opt
|
|
t2.MAD
|
|
drop table t2;
|
|
ERROR 42S02: Unknown table 'test.t2'
|
|
show warnings;
|
|
Level Code Message
|
|
Error 1051 Unknown table 'test.t2'
|
|
db.opt
|
|
create table t2(a int) engine=aria;
|
|
flush tables;
|
|
db.opt
|
|
t2.frm
|
|
drop table t2;
|
|
Warnings:
|
|
Warning 1017 Can't find file: './test/t2.MAI' (errno: 2 "No such file or directory")
|
|
create table t2(a int not null) engine=CSV;
|
|
flush tables;
|
|
drop table t2;
|
|
db.opt
|
|
create table t2(a int not null) engine=CSV;
|
|
flush tables;
|
|
drop table t2;
|
|
db.opt
|
|
create table t2(a int not null) engine=archive;
|
|
flush tables;
|
|
select * from t2;
|
|
a
|
|
flush tables;
|
|
select * from t2;
|
|
ERROR 42S02: Table 'test.t2' doesn't exist
|
|
db.opt
|
|
drop table t2;
|
|
ERROR 42S02: Unknown table 'test.t2'
|
|
create table t2(a int not null) engine=archive;
|
|
flush tables;
|
|
drop table t2;
|
|
ERROR 42S02: Unknown table 'test.t2'
|
|
db.opt
|
|
#
|
|
# MDEV-23549 CREATE fails after DROP without FRM
|
|
#
|
|
create table t1 (a int);
|
|
select * from t1;
|
|
a
|
|
drop table t1;
|
|
create table t1 (a int);
|
|
drop table t1;
|