1--source include/have_partition.inc
2# See https://bugs.launchpad.net/percona-server/+bug/1657908
3
4source include/have_tokudb.inc;
5
6SET GLOBAL tokudb_dir_per_db=ON;
7
8--let $DB= test
9--let $DATADIR= `SELECT @@datadir`
10
11--delimiter |
12CREATE PROCEDURE create_table()
13BEGIN
14CREATE TABLE test.t1 (
15  a INT
16) ENGINE = TokuDB
17PARTITION BY RANGE (a)
18(PARTITION p100 VALUES LESS THAN (100) ENGINE = TokuDB,
19 PARTITION p_to_del VALUES LESS THAN (200) ENGINE = TokuDB,
20 PARTITION p300 VALUES LESS THAN (300) ENGINE = TokuDB,
21 PARTITION p400 VALUES LESS THAN (400) ENGINE = TokuDB
22);
23END|
24--delimiter ;
25
26--echo ### Create partitioned table
27CALL create_table();
28--source dir_per_db_show_table_files.inc
29
30--echo ### Stop server
31--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
32--shutdown_server
33--source include/wait_until_disconnected.inc
34
35--echo ### Remove 'main' file of one of the partitions
36--remove_files_wildcard $DATADIR/$DB t1_P_p_to_del_main_*.tokudb
37
38--echo ### Start server
39--enable_reconnect
40--exec echo "restart: --loose-tokudb-dir-per-db=ON" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
41--source include/wait_until_connected_again.inc
42
43--echo ### Make sure 'main' partition file is deleted
44--source dir_per_db_show_table_files.inc
45
46--echo ### Make sure the table still exists
47SHOW TABLES;
48
49--echo ### Drop table
50# error 1051 was here before the fix
51DROP TABLE t1;
52
53--echo ### Make sure the table is dropped
54SHOW TABLES;
55
56--echo ### Check what files still exist after DROP TABLE
57--source dir_per_db_show_table_files.inc
58
59--echo ### Remove the rest of the files
60--remove_files_wildcard $DATADIR/$DB *.tokudb
61
62--echo ### Make sure there are no tokudb files
63--source dir_per_db_show_table_files.inc
64
65--echo ### Create the same table once more
66# engine error 17 (EEXIST) was here before the fix
67CALL create_table();
68--source dir_per_db_show_table_files.inc
69
70--echo ### Restore state
71DROP TABLE t1;
72DROP PROCEDURE create_table;
73SET GLOBAL tokudb_dir_per_db=default;
74