mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / parts / inc / partition_check_drop.inc
blob137de4165a0f8cb55a5f0c3f5f0c1d4397fb68b5
1 ################################################################################
2 # inc/partition_check_drop.inc                                                 #
3 #                                                                              #
4 # Purpose:                                                                     #
5 #   Check that a drop table removes all files belonging to this table.         #
6 #   Remaining unused files can be caused by imperfect DROP TABLE or            #
7 #   ALTER TABLE <alter partitioning>.                                          #
8 #                                                                              #
9 #   This routine is only useful for the partition_<feature>_<engine> tests.    #
10 #                                                                              #
11 #------------------------------------------------------------------------------#
12 # Original Author: mleich                                                      #
13 # Original Date: 2006-05-12                                                    #
14 ################################################################################
16 if ($no_debug)
18    --disable_query_log
21 # Get the MySQL Servers datadir without ending slash
22 let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
23 #echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
25 if ($do_file_tests)
27   let $ls_file= $MYSQLD_DATADIR/test/tmp2;
28   # List the files belonging to the table t1
29   --list_files_write_file $ls_file $MYSQLD_DATADIR/test t1*
30   --chmod 0644 $ls_file
31   if ($with_directories)
32   {
33     --list_files_append_file $ls_file $MYSQLTEST_VARDIR/tmp t1*
34   }
35   eval SET @aux = load_file('$ls_file');
37   # clean up
38   remove_file $ls_file;
40 if (!$do_file_tests)
42   SET @aux = '--- not determined ---';
45 # UPDATE the current filelist of the table t1 within t0_definition
46 # Note: This list should be empty, because the table t1 was dropped !
47 eval INSERT INTO t0_definition SET state = 'old', file_list = @aux
48 ON DUPLICATE KEY UPDATE file_list = @aux;
49 # eval UPDATE t0_definition SET file_list = @aux WHERE state = 'old';
51 # Check if filelist is empty.
52 let $found_garbage= `SELECT file_list <> '' FROM t0_definition WHERE state = 'old'`;
53 if ($found_garbage)
55    # Unfortunately the DROP TABLE did not remove the unused files
56    if ($ls)
57    {
58       --echo # Attention: There are unused files.
59       --echo #            Either the DROP TABLE or a preceding ALTER TABLE
60       --echo #            <alter partitioning> worked incomplete.
61       --echo # We found:
62       # Print the list of files into the protocol
63       eval SELECT REPLACE(file_list,'$MYSQLTEST_VARDIR','\$MYSQLTEST_VARDIR')
64                   AS "unified filelist"
65            FROM t0_definition WHERE state = 'old';
66    }
67    # Do a manual cleanup, because the following tests should not suffer from
68    # remaining files
69    --remove_files_wildcard $MYSQLD_DATADIR/test t1*
70    if ($with_directories)
71    {
72            --remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*
73    }
75 --enable_query_log