Commit 7b216ceb authored by Marko Mäkelä's avatar Marko Mäkelä

Avoid DROP DATABASE test

DROP DATABASE would internally execute DROP TABLE on every contained
table and finally remove the directory. In InnoDB, DROP TABLE is
sometimes executed in the background. The table would be renamed to
a name that starts with #sql. The existence of these files would
prevent DROP DATABASE from succeeding.

CREATE OR REPLACE DATABASE can internally execute DROP DATABASE if
the directory already exists. This could fail due to the InnoDB
background DROP TABLE, possibly due to some tables that were
leftovers from earlier tests.
parent 6812fb79
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
-- echo # -- echo #
# Use character-set-server in test db # Use character-set-server in test db
create or replace database test; create database best;
use test; use best;
set default_storage_engine=innodb; set default_storage_engine=innodb;
set @bigval= repeat('0123456789', 30); set @bigval= repeat('0123456789', 30);
delimiter ~~; delimiter ~~;
create or replace procedure check_table(table_name varchar(255)) create procedure check_table(table_name varchar(255))
begin begin
select table_id into @table_id select table_id into @table_id
from information_schema.innodb_sys_tables from information_schema.innodb_sys_tables
where name = concat('test/', table_name); where name = concat('best/', table_name);
select name, mtype, hex(prtype) as prtype, len select name, mtype, hex(prtype) as prtype, len
from information_schema.innodb_sys_columns from information_schema.innodb_sys_columns
where table_id = @table_id; where table_id = @table_id;
...@@ -30,7 +30,7 @@ delimiter ;~~ ...@@ -30,7 +30,7 @@ delimiter ;~~
--echo # VARCHAR -> CHAR, VARBINARY -> BINARY conversion --echo # VARCHAR -> CHAR, VARBINARY -> BINARY conversion
set @bigval= repeat('0123456789', 20); set @bigval= repeat('0123456789', 20);
create or replace table t (a varchar(300)); create table t (a varchar(300));
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t modify a char(255), algorithm=instant; alter table t modify a char(255), algorithm=instant;
alter table t modify a char(255), algorithm=copy; alter table t modify a char(255), algorithm=copy;
...@@ -166,8 +166,8 @@ create or replace table t1 (x tinyint); ...@@ -166,8 +166,8 @@ create or replace table t1 (x tinyint);
insert into t1 set x= 42; insert into t1 set x= 42;
alter table t1 modify x int; alter table t1 modify x int;
flush tables t1 for export; flush tables t1 for export;
--move_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg --move_file $MYSQLD_DATADIR/best/t1.cfg $MYSQLD_DATADIR/best/t2.cfg
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd --copy_file $MYSQLD_DATADIR/best/t1.ibd $MYSQLD_DATADIR/best/t2.ibd
unlock tables; unlock tables;
alter table t2 import tablespace; alter table t2 import tablespace;
...@@ -246,4 +246,4 @@ alter table t1 modify a char(20); ...@@ -246,4 +246,4 @@ alter table t1 modify a char(20);
select * from t1; select * from t1;
check table t1; check table t1;
create or replace database test charset latin1; drop database best;
set @s= '1992-01-01'; set @s= '1992-01-01';
set @e= '1999-12-31'; set @e= '1999-12-31';
create or replace table t (s date, e date); create table t (s date, e date);
# period start/end columns are implicit NOT NULL # period start/end columns are implicit NOT NULL
alter table t add period for a(s, e); alter table t add period for a(s, e);
show create table t; show create table t;
...@@ -96,9 +96,11 @@ t1 CREATE TABLE `t1` ( ...@@ -96,9 +96,11 @@ t1 CREATE TABLE `t1` (
`s1` date NOT NULL, `s1` date NOT NULL,
PERIOD FOR `b` (`s1`, `e`) PERIOD FOR `b` (`s1`, `e`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t2 (period for b(s,e)) select * from t; create table t2 (period for b(s,e)) select * from t;
ERROR 23000: CONSTRAINT `b` failed for `test`.`t2` ERROR 23000: CONSTRAINT `b` failed for `test`.`t2`
create table t2 (period for b(s1,e)) select * from t; create table t2 (period for b(s1,e)) select * from t;
drop table t2;
# SQL16 11.27 <add table period definition>, Syntax Rules, 5)g) # SQL16 11.27 <add table period definition>, Syntax Rules, 5)g)
# The declared type of BC1 shall be either DATE or a timestamp type # The declared type of BC1 shall be either DATE or a timestamp type
# and shall be equivalent to the declared type of BC2. # and shall be equivalent to the declared type of BC2.
...@@ -171,4 +173,4 @@ ERROR 23000: CONSTRAINT `mytime_1` failed for `test`.`t` ...@@ -171,4 +173,4 @@ ERROR 23000: CONSTRAINT `mytime_1` failed for `test`.`t`
alter table t add constraint mytime_1 check (x > 2); alter table t add constraint mytime_1 check (x > 2);
insert t values (3, @e, @s); insert t values (3, @e, @s);
ERROR 23000: CONSTRAINT `mytime_2` failed for `test`.`t` ERROR 23000: CONSTRAINT `mytime_2` failed for `test`.`t`
create or replace database test; drop table t;
create or replace table t (id int primary key, s date, e date, create table t (id int primary key, s date, e date, period for mytime(s,e));
period for mytime(s,e));
# CONSTRAINT CHECK (s < e) is added implicitly, and shouldn't be shown # CONSTRAINT CHECK (s < e) is added implicitly, and shouldn't be shown
# this is important for correct command-based replication # this is important for correct command-based replication
show create table t; show create table t;
...@@ -96,4 +95,4 @@ ERROR 23000: CONSTRAINT `mytime_1` failed for `test`.`t` ...@@ -96,4 +95,4 @@ ERROR 23000: CONSTRAINT `mytime_1` failed for `test`.`t`
show status like "Feature_application_time_periods"; show status like "Feature_application_time_periods";
Variable_name Value Variable_name Value
Feature_application_time_periods 6 Feature_application_time_periods 6
create or replace database test; drop table t;
create or replace table t (id int, s date, e date, period for apptime(s,e)); create table t (id int, s date, e date, period for apptime(s,e));
insert into t values(1, '1999-01-01', '2018-12-12'); insert into t values(1, '1999-01-01', '2018-12-12');
insert into t values(1, '1999-01-01', '2017-01-01'); insert into t values(1, '1999-01-01', '2017-01-01');
insert into t values(1, '2017-01-01', '2019-01-01'); insert into t values(1, '2017-01-01', '2019-01-01');
...@@ -353,4 +353,6 @@ id s e datediff(e, s) ...@@ -353,4 +353,6 @@ id s e datediff(e, s)
1 1999-01-01 1999-01-03 2 1 1999-01-01 1999-01-03 2
1 2018-12-10 2018-12-12 2 1 2018-12-10 2018-12-12 2
2 1999-01-01 1999-01-03 2 2 1999-01-01 1999-01-03 2
create or replace database test; drop table t,t2,t3,log_tbl;
drop view v;
drop procedure log;
create or replace table t (id int, s date, e date, period for apptime(s,e)); create table t (id int, s date, e date, period for apptime(s,e));
insert into t values(1, '1999-01-01', '2018-12-12'); insert into t values(1, '1999-01-01', '2018-12-12');
insert into t values(1, '1999-01-01', '2017-01-01'); insert into t values(1, '1999-01-01', '2017-01-01');
insert into t values(1, '2017-01-01', '2019-01-01'); insert into t values(1, '2017-01-01', '2019-01-01');
...@@ -268,4 +268,9 @@ x s e xs xe xs=s and xe=e ...@@ -268,4 +268,9 @@ x s e xs xe xs=s and xe=e
create or replace table t1 (f int, s date, e date, period for app(s,e)); create or replace table t1 (f int, s date, e date, period for app(s,e));
insert into t1 values (1,'2016-09-21','2019-06-14'); insert into t1 values (1,'2016-09-21','2019-06-14');
update ignore t1 for portion of app from '2019-03-13' to '2019-03-14' set f = 1; update ignore t1 for portion of app from '2019-03-13' to '2019-03-14' set f = 1;
create or replace database test; drop table t,t1,t2,log_tbl;
drop view v1;
drop function f;
drop function g;
drop function h;
drop procedure log;
# DELETE # DELETE
create or replace table t ( create table t (
s date, e date, s date, e date,
row_start SYS_TYPE as row start invisible, row_start SYS_TYPE as row start invisible,
row_end SYS_TYPE as row end invisible, row_end SYS_TYPE as row end invisible,
...@@ -86,4 +86,9 @@ x s e if(row_start = @ins_time, "OLD", "NEW") check_row(row_start, row_end) ...@@ -86,4 +86,9 @@ x s e if(row_start = @ins_time, "OLD", "NEW") check_row(row_start, row_end)
1 2018-01-01 2018-12-12 NEW CURRENT ROW 1 2018-01-01 2018-12-12 NEW CURRENT ROW
2 1999-01-01 1999-12-12 OLD CURRENT ROW 2 1999-01-01 1999-12-12 OLD CURRENT ROW
6 2000-01-01 2018-01-01 NEW CURRENT ROW 6 2000-01-01 2018-01-01 NEW CURRENT ROW
create or replace database test; drop table t,log_tbl;
drop function check_row;
drop function current_row;
drop procedure verify_trt;
drop procedure verify_trt_dummy;
drop procedure log;
set @s= '1992-01-01'; set @s= '1992-01-01';
set @e= '1999-12-31'; set @e= '1999-12-31';
create or replace table t (s date, e date); create table t (s date, e date);
--echo # period start/end columns are implicit NOT NULL --echo # period start/end columns are implicit NOT NULL
alter table t add period for a(s, e); alter table t add period for a(s, e);
...@@ -58,11 +58,13 @@ insert t(s, s1, e) values(@e, @e, @s); ...@@ -58,11 +58,13 @@ insert t(s, s1, e) values(@e, @e, @s);
create table t1 like t; create table t1 like t;
show create table t1; show create table t1;
drop table t1;
--error ER_CONSTRAINT_FAILED --error ER_CONSTRAINT_FAILED
create table t2 (period for b(s,e)) select * from t; create table t2 (period for b(s,e)) select * from t;
create table t2 (period for b(s1,e)) select * from t; create table t2 (period for b(s1,e)) select * from t;
drop table t2;
--echo # SQL16 11.27 <add table period definition>, Syntax Rules, 5)g) --echo # SQL16 11.27 <add table period definition>, Syntax Rules, 5)g)
--echo # The declared type of BC1 shall be either DATE or a timestamp type --echo # The declared type of BC1 shall be either DATE or a timestamp type
...@@ -128,4 +130,4 @@ alter table t add constraint mytime_1 check (x > 2); ...@@ -128,4 +130,4 @@ alter table t add constraint mytime_1 check (x > 2);
--error ER_CONSTRAINT_FAILED --error ER_CONSTRAINT_FAILED
insert t values (3, @e, @s); insert t values (3, @e, @s);
create or replace database test; drop table t;
create or replace table t (id int primary key, s date, e date, create table t (id int primary key, s date, e date, period for mytime(s,e));
period for mytime(s,e));
--echo # CONSTRAINT CHECK (s < e) is added implicitly, and shouldn't be shown --echo # CONSTRAINT CHECK (s < e) is added implicitly, and shouldn't be shown
--echo # this is important for correct command-based replication --echo # this is important for correct command-based replication
show create table t; show create table t;
...@@ -79,4 +78,4 @@ insert t values (2, '2001-01-01', '2001-01-01'); ...@@ -79,4 +78,4 @@ insert t values (2, '2001-01-01', '2001-01-01');
show status like "Feature_application_time_periods"; show status like "Feature_application_time_periods";
create or replace database test; drop table t;
source suite/period/engines.inc; source suite/period/engines.inc;
source include/have_log_bin.inc; source include/have_log_bin.inc;
create or replace table t (id int, s date, e date, period for apptime(s,e)); create table t (id int, s date, e date, period for apptime(s,e));
insert into t values(1, '1999-01-01', '2018-12-12'); insert into t values(1, '1999-01-01', '2018-12-12');
insert into t values(1, '1999-01-01', '2017-01-01'); insert into t values(1, '1999-01-01', '2017-01-01');
...@@ -181,4 +181,6 @@ delete from t for portion of apptime from '1999-01-03' to '2018-12-10'; ...@@ -181,4 +181,6 @@ delete from t for portion of apptime from '1999-01-03' to '2018-12-10';
--sorted_result --sorted_result
select *, datediff(e, s) from t; select *, datediff(e, s) from t;
create or replace database test; drop table t,t2,t3,log_tbl;
drop view v;
drop procedure log;
source suite/period/engines.inc; source suite/period/engines.inc;
source include/have_log_bin.inc; source include/have_log_bin.inc;
create or replace table t (id int, s date, e date, period for apptime(s,e)); create table t (id int, s date, e date, period for apptime(s,e));
insert into t values(1, '1999-01-01', '2018-12-12'); insert into t values(1, '1999-01-01', '2018-12-12');
insert into t values(1, '1999-01-01', '2017-01-01'); insert into t values(1, '1999-01-01', '2017-01-01');
...@@ -157,4 +157,9 @@ create or replace table t1 (f int, s date, e date, period for app(s,e)); ...@@ -157,4 +157,9 @@ create or replace table t1 (f int, s date, e date, period for app(s,e));
insert into t1 values (1,'2016-09-21','2019-06-14'); insert into t1 values (1,'2016-09-21','2019-06-14');
update ignore t1 for portion of app from '2019-03-13' to '2019-03-14' set f = 1; update ignore t1 for portion of app from '2019-03-13' to '2019-03-14' set f = 1;
create or replace database test; drop table t,t1,t2,log_tbl;
drop view v1;
drop function f;
drop function g;
drop function h;
drop procedure log;
...@@ -3,7 +3,7 @@ source suite/versioning/common.inc; ...@@ -3,7 +3,7 @@ source suite/versioning/common.inc;
--echo # DELETE --echo # DELETE
--replace_result $sys_datatype_expl SYS_TYPE --replace_result $sys_datatype_expl SYS_TYPE
eval create or replace table t ( eval create table t (
s date, e date, s date, e date,
row_start $sys_datatype_expl as row start invisible, row_start $sys_datatype_expl as row start invisible,
row_end $sys_datatype_expl as row end invisible, row_end $sys_datatype_expl as row end invisible,
...@@ -56,4 +56,9 @@ select *, if(row_start = @ins_time, "OLD", "NEW"), check_row(row_start, row_end) ...@@ -56,4 +56,9 @@ select *, if(row_start = @ins_time, "OLD", "NEW"), check_row(row_start, row_end)
from t for system_time all from t for system_time all
order by x, s, e, row_start; order by x, s, e, row_start;
create or replace database test; drop table t,log_tbl;
drop function check_row;
drop function current_row;
drop procedure verify_trt;
drop procedure verify_trt_dummy;
drop procedure log;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment