2007-02-06 13:35:54 +01:00
|
|
|
################################################################################
|
2007-11-20 16:04:07 +01:00
|
|
|
# inc/partition_check_drop.inc #
|
2007-02-06 13:35:54 +01:00
|
|
|
# #
|
|
|
|
# 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. #
|
|
|
|
# #
|
|
|
|
#------------------------------------------------------------------------------#
|
2007-11-20 16:04:07 +01:00
|
|
|
# Original Author: mleich #
|
2007-02-06 13:35:54 +01:00
|
|
|
# Original Date: 2006-05-12 #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
if ($no_debug)
|
|
|
|
{
|
|
|
|
--disable_query_log
|
|
|
|
}
|
|
|
|
|
2008-04-04 17:46:48 +02:00
|
|
|
# Get the MySQL Servers datadir without ending slash
|
|
|
|
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
|
|
|
|
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
|
|
|
|
|
2007-02-06 13:35:54 +01:00
|
|
|
if ($do_file_tests)
|
|
|
|
{
|
2008-08-04 07:04:47 +02:00
|
|
|
let $ls_file= $MYSQLD_DATADIR/test/tmp2;
|
|
|
|
# List the files belonging to the table t1
|
|
|
|
--list_files_write_file $ls_file $MYSQLD_DATADIR/test t1*
|
|
|
|
--chmod 0644 $ls_file
|
|
|
|
if ($with_directories)
|
|
|
|
{
|
|
|
|
--list_files_append_file $ls_file $MYSQLTEST_VARDIR/tmp t1*
|
|
|
|
}
|
|
|
|
eval SET @aux = load_file('$ls_file');
|
|
|
|
|
|
|
|
# clean up
|
|
|
|
remove_file $ls_file;
|
2007-02-06 13:35:54 +01:00
|
|
|
}
|
|
|
|
if (!$do_file_tests)
|
|
|
|
{
|
2008-08-04 07:04:47 +02:00
|
|
|
SET @aux = '--- not determined ---';
|
2007-02-06 13:35:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# UPDATE the current filelist of the table t1 within t0_definition
|
|
|
|
# Note: This list should be empty, because the table t1 was dropped !
|
2008-07-09 13:19:04 +02:00
|
|
|
eval INSERT INTO t0_definition SET state = 'old', file_list = @aux
|
|
|
|
ON DUPLICATE KEY UPDATE file_list = @aux;
|
|
|
|
# eval UPDATE t0_definition SET file_list = @aux WHERE state = 'old';
|
2007-02-06 13:35:54 +01:00
|
|
|
|
|
|
|
# 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.
|
2007-11-20 16:04:07 +01:00
|
|
|
--echo # Either the DROP TABLE or a preceding ALTER TABLE
|
2007-02-06 13:35:54 +01:00
|
|
|
--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
|
2008-04-04 17:46:48 +02:00
|
|
|
--exec rm -f $MYSQLD_DATADIR/test/t1* || true
|
2007-02-06 13:35:54 +01:00
|
|
|
if ($with_directories)
|
|
|
|
{
|
2008-02-29 12:52:50 +04:00
|
|
|
--exec rm -f $MYSQLTEST_VARDIR/tmp/t1* || true
|
2007-02-06 13:35:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
--enable_query_log
|