| 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 |
################################################################################ |
| 15 |
|
| 16 |
if ($no_debug) |
| 17 |
{ |
| 18 |
--disable_query_log |
| 19 |
} |
| 20 |
|
| 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; |
| 24 |
|
| 25 |
if ($do_file_tests) |
| 26 |
{ |
| 27 |
let $ls_file= $MYSQLD_DATADIR/test/tmp2; |
| 28 |
# List the files belonging to the table t1 |
| 29 |
--replace_result $MYSQLTEST_VARDIR \$MYSQLTEST_VARDIR #p# #P# #sp# #SP# |
| 30 |
--list_files_write_file $ls_file $MYSQLD_DATADIR/test t1* |
| 31 |
--chmod 0644 $ls_file |
| 32 |
if ($with_directories) |
| 33 |
{ |
| 34 |
--replace_result $MYSQLTEST_VARDIR \$MYSQLTEST_VARDIR #p# #P# #sp# #SP# |
| 35 |
--list_files_append_file $ls_file $MYSQLTEST_VARDIR/tmp t1* |
| 36 |
} |
| 37 |
eval SET @aux = load_file('$ls_file'); |
| 38 |
|
| 39 |
# clean up |
| 40 |
--remove_file $ls_file |
| 41 |
} |
| 42 |
if (!$do_file_tests) |
| 43 |
{ |
| 44 |
SET @aux = '--- not determined ---'; |
| 45 |
} |
| 46 |
|
| 47 |
# UPDATE the current filelist of the table t1 within t0_definition |
| 48 |
# Note: This list should be empty, because the table t1 was dropped ! |
| 49 |
eval INSERT INTO t0_definition SET state = 'old', file_list = @aux |
| 50 |
ON DUPLICATE KEY UPDATE file_list = @aux; |
| 51 |
# eval UPDATE t0_definition SET file_list = @aux WHERE state = 'old'; |
| 52 |
|
| 53 |
# Check if filelist is empty. |
| 54 |
let $found_garbage= `SELECT file_list <> '' FROM t0_definition WHERE state = 'old'`; |
| 55 |
if ($found_garbage) |
| 56 |
{ |
| 57 |
# Unfortunately the DROP TABLE did not remove the unused files |
| 58 |
if ($ls) |
| 59 |
{ |
| 60 |
--echo # Attention: There are unused files. |
| 61 |
--echo # Either the DROP TABLE or a preceding ALTER TABLE |
| 62 |
--echo # <alter partitioning> worked incomplete. |
| 63 |
--echo # We found: |
| 64 |
# Print the list of files into the protocol |
| 65 |
eval SELECT file_list AS "unified filelist" |
| 66 |
FROM t0_definition WHERE state = 'old'; |
| 67 |
} |
| 68 |
# Do a manual cleanup, because the following tests should not suffer from |
| 69 |
# remaining files |
| 70 |
--remove_files_wildcard $MYSQLD_DATADIR/test t1* |
| 71 |
if ($with_directories) |
| 72 |
{ |
| 73 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1* |
| 74 |
} |
| 75 |
} |
| 76 |
--enable_query_log |