partition_check_drop.inc 3.28 KB
Newer Older
1
################################################################################
mleich@five.local.lan's avatar
mleich@five.local.lan committed
2
# inc/partition_check_drop.inc                                                 #
3 4 5 6 7 8 9 10 11
#                                                                              #
# Purpose:                                                                     #
#   Check that a drop table removes all files belonging to this table.         #
#   Remaining unused files can be caused by imperfect DROP TABLE or            #
#   ALTER TABLE <alter partitioning>.                                          #
#                                                                              #
#   This routine is only useful for the partition_<feature>_<engine> tests.    #
#                                                                              #
#------------------------------------------------------------------------------#
mleich@five.local.lan's avatar
mleich@five.local.lan committed
12
# Original Author: mleich                                                      #
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
# Original Date: 2006-05-12                                                    #
# Change Author:                                                               #
# Change Date:                                                                 #
# Change:                                                                      #
################################################################################

if ($no_debug)
{
   --disable_query_log
}

if ($do_file_tests)
{
# List the files belonging to the table t1
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* > $MYSQLTEST_VARDIR/master-data/test/tmp2 || true
if ($with_directories)
{
--exec ls $MYSQLTEST_VARDIR/master-data/test/data/t1* >> $MYSQLTEST_VARDIR/master-data/test/tmp2 || true
--exec ls $MYSQLTEST_VARDIR/master-data/test/index/t1* >> $MYSQLTEST_VARDIR/master-data/test/tmp2 || true
}
eval SET @aux = CONCAT('load_file(''$MYSQLTEST_VARDIR','/master-data/test/tmp2'')');
let $file_list= `SELECT @aux`;
}
if (!$do_file_tests)
{
let $file_list= '--- not determined ---';
}

# UPDATE the current filelist of the table t1 within t0_definition
# Note: This list should be empty, because the table t1 was dropped !
eval INSERT INTO t0_definition SET state = 'old', file_list = $file_list
ON DUPLICATE KEY UPDATE file_list = $file_list;
# eval UPDATE t0_definition SET file_list = $file_list WHERE state = 'old';

# Check if filelist is empty.
let $found_garbage= `SELECT file_list <> '' FROM t0_definition WHERE state = 'old'`;
if ($found_garbage)
{
   # Unfortunately the DROP TABLE did not remove the unused files
   if ($ls)
   {
      --echo # Attention: There are unused files.
mleich@five.local.lan's avatar
mleich@five.local.lan committed
55
      --echo #            Either the DROP TABLE or a preceding ALTER TABLE
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
      --echo #            <alter partitioning> worked incomplete.
      --echo # We found:
      # Print the list of files into the protocol
      eval SELECT REPLACE(file_list,'$MYSQLTEST_VARDIR','\$MYSQLTEST_VARDIR')
                  AS "unified filelist"
           FROM t0_definition WHERE state = 'old';
   }
   # Do a manual cleanup, because the following tests should not suffer from
   # remaining files
   --exec rm -f $MYSQLTEST_VARDIR/master-data/test/t1* || true
   if ($with_directories)
   {
	   --exec rm -f $MYSQLTEST_VARDIR/master-data/test/data/t1* || true
	   --exec rm -f $MYSQLTEST_VARDIR/master-data/test/index/t1* || true
   }
}
--enable_query_log