1--source include/linux.inc
2--source include/not_embedded.inc
3
4--echo #
5--echo # BUG#11747548:DETECT ORPHAN TEMP-POOL FILES, AND HANDLE GRACEFULLY.
6--echo #
7
8--echo #Set up.
9#
10# Note: We are explicitly using MyISAM engine here as the TC is trying
11# to check for MyISAM files MYD/MYI. With InnoDB no such files are created
12# instead intrinsic tables are stored in shared temporary tablespace.
13#
14let $internal_se = `select @@internal_tmp_disk_storage_engine`;
15set global internal_tmp_disk_storage_engine = myisam;
16
17CREATE TABLE pid_table(pid_no INT);
18CREATE TABLE t1 (a BLOB);
19INSERT INTO t1 VALUES (1), (2);
20
21--echo #Create MYD and MYI files for intrinsic temp table.
22--let $pid_file=`SELECT @@pid_file`
23--replace_result $pid_file pid_file
24--eval LOAD DATA LOCAL INFILE '$pid_file' INTO TABLE pid_table
25--let $temp_file_MYD= `SELECT CONCAT('#sql_', LCASE(HEX(pid_no)), '_0', '.MYD') FROM pid_table`
26--let $temp_file_MYI= `SELECT CONCAT('#sql_', LCASE(HEX(pid_no)), '_0', '.MYI') FROM pid_table`
27--write_file $MYSQLTEST_VARDIR/tmp/$temp_file_MYD
28EOF
29--write_file $MYSQLTEST_VARDIR/tmp/$temp_file_MYI
30EOF
31
32--echo #Reports an error since the temp file already exists.
33--replace_regex /.*Can't create\/write *.*/Can't create or write to file/
34--error 1
35SELECT a FROM t1 ORDER BY rand(1);
36
37--echo #With patch, the query executes successfully.
38SELECT a FROM t1 ORDER BY rand(1);
39
40--echo #cleanup
41DROP TABLE t1, pid_table;
42eval set global internal_tmp_disk_storage_engine = $internal_se;
43