File: alter_datadir_path.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (455 lines) | stat: -rw-r--r-- 21,849 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
--echo #
--echo #Bug #33398681 Innodb ibd tablespace file is moved back from innodb_directories to datadir after ALTER TABLE
--echo #

#This test will check whether the ibd tablespace file is moved back or not

#Table t1a: Covers scenario create non-partitioned table without data directory specification and alter table force
#Table t1b: Covers scenario create non-partitioned table without data directory specification and alter table force algo=inplace
#Table t1c: Covers scenario create non-partitioned table without data directory specification and alter table force algo=copy
#Table t2a: Covers scenario create non-partitioned table with data directory specification and alter table force
#Table t2b: Covers scenario create non-partitioned table with data directory specification and alter table force algo=inplace
#Table t2c: Covers scenario create non-partitioned table with data directory specification and alter table force algo=copy
#Table t3a: Covers scenario create partitioned table without data directory specification and alter table force
#Table t3b: Covers scenario create partitioned table without data directory specification and alter table force algo=inplace
#Table t3c: Covers scenario create partitioned table without data directory specification and alter table force algo=copy
#Table t4a: Covers scenario create partitioned table with data directory specification and alter table force
#Table t4b: Covers scenario create partitioned table with data directory specification and alter table force algo=inplace
#Table t4c: Covers scenario create partitioned table with data directory specification and alter table force algo=copy
#Table t5a: Covers scenario create non-partitioned table with data directory specification and alter table force but moving ibd files from external dir to default dir
#Table t5b: Covers scenario create non-partitioned table with data directory specification and alter table force algo=inplace but moving ibd files from external dir to default dir
#Table t5c: Covers scenario create non-partitioned table with data directory specification and alter table force algo=copy but moving ibd files from external dir to default dir
#Table t6a: Covers scenario create partitioned table with data directory specification and alter table force but moving ibd files from external dir to default dir
#Table t6b: Covers scenario create partitioned table with data directory specification and alter table force algo=inplace but moving ibd files from external dir to default dir
#Table t6c: Covers scenario create partitioned table with data directory specification and alter table force algo=copy but moving ibd files from external dir to default dir
#Table t7a: Covers scenario create non-partitioned table with data directory specification and move from external dir 1 to external dir 2 and alter table force
#Table t7b: Covers scenario create non-partitioned table with data directory specification and move from external dir 1 to external dir 2 and alter table force algo=inplace
#Table t7c: Covers scenario create non-partitioned table with data directory specification and move from external dir 1 to external dir 2 and alter table force algo=copy
#Table t8a: Covers scenario create partitioned table with data directory clause and both partitions in different directories, move to default dir and alter table force
#Table t8b: Covers scenario create partitioned table with data directory clause and both partitions in different directories, move to default dir and alter table force algo=inplace
#Table t8c: Covers scenario create partitioned table with data directory clause and both partitions in different directories, move to default dir and alter table force algo=copy
#Table t8d: Covers scenario create partitioned table with one partition in data directory clause and the other partition in default data dir path, move to default dir and alter table force algo=copy
#Table t9a: Covers scenario create partitioned table without data directory clause but moving each partition to different external directories and alter table force
#Table t9b: Covers scenario create partitioned table without data directory clause but moving each partition to different external directories and alter table force algo=inplace
#Table t9c: Covers scenario create partitioned table without data directory clause but moving each partition to different external directories and alter table force algo=copy

--echo # Set different paths for --datadir
LET $MYSQLD_DATADIR = `select @@datadir`;
LET $EXTERNAL_DIR = $MYSQL_TMP_DIR/external_dir;
LET $EXTERNAL_DIR2 = $MYSQL_TMP_DIR/external_dir2;
LET $INNODB_DIRECTORIES = $MYSQLTEST_VARDIR/innodb_directories;
LET $data_directory_clause = DATA DIRECTORY='$EXTERNAL_DIR';
LET $data_directory_clause2 = DATA DIRECTORY='$EXTERNAL_DIR2';

--echo # Create innodb_directories folder
--mkdir $INNODB_DIRECTORIES
--mkdir $INNODB_DIRECTORIES/dbtest

--echo # Create external datadir folder
--mkdir $EXTERNAL_DIR
--mkdir $EXTERNAL_DIR/dbtest

--echo # Create external datadir2 folder
--mkdir $EXTERNAL_DIR2
--mkdir $EXTERNAL_DIR2/dbtest

--echo # Restart the engine to make the external directory known.
--let $external_dirs=$EXTERNAL_DIR;$EXTERNAL_DIR2
let restart_parameters = restart: --innodb-directories=$external_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--source include/restart_mysqld.inc

--echo # Create table
CREATE DATABASE dbtest;
USE dbtest;

--echo # Normal tables
CREATE TABLE `t1a` (`c1` INT);
CREATE TABLE `t1b` (`c1` INT);
CREATE TABLE `t1c` (`c1` INT);

--echo # Normal tables with data directory clause
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t2a` (`c1` INT) $data_directory_clause;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t2b` (`c1` INT) $data_directory_clause;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t2c` (`c1` INT) $data_directory_clause;

--echo # Partition tables
CREATE TABLE `t3a` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));
CREATE TABLE `t3b` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));
CREATE TABLE `t3c` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));

--echo # Partition tables with data directory clause
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t4a` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t4b` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t4c` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause);

--echo # Normal tables with data directory clause 2
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t5a` (`c1` INT) $data_directory_clause2;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t5b` (`c1` INT) $data_directory_clause2;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t5c` (`c1` INT) $data_directory_clause2;

--echo # Partition tables with data directory clause
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t6a` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause2, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause2);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t6b` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause2, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause2);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t6c` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause2, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause2);

--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # 1. ibd files for t1a, t1b, t1c, t3a, t3b, t3c

--echo # Check that the ibd files for each table exist in the working (dbtest) folder
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Move ibd files from default directory to new innodb directory
--copy_files_wildcard $MYSQLD_DATADIR/dbtest/ $INNODB_DIRECTORIES/dbtest/ *
--remove_files_wildcard $MYSQLD_DATADIR/dbtest/ *

--echo # Check that the files exist in the innodb_directories folder before alter after moving
--list_files $INNODB_DIRECTORIES/dbtest *

--echo # 2. ibd files for t2a, t2b, t2c, t4a, t4b, t4c

--echo # Check that the ibd files for each table exist in the external directory where the tables are created
--list_files $EXTERNAL_DIR/dbtest *

--echo # 3. ibd files for t5a, t5b, t5c, t6a, t6b, t6c

--echo # Check that the ibd files for each table exist in the external directory2 where the tables are created
--list_files $EXTERNAL_DIR2/dbtest *

--echo # Move ibd files for t5a, t5b, t5c, t6a, t6b, t6c from external directory2 to default directory
--copy_files_wildcard $EXTERNAL_DIR2/dbtest/ $MYSQLD_DATADIR/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR2/dbtest/ *

--echo # Check that the ibd files for t5a, t5b, t5c, t6a, t6b, t6c now exist in working (dbtest) folder
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Restart the server
--let $innodb_dirs=$INNODB_DIRECTORIES;$EXTERNAL_DIR;$EXTERNAL_DIR2
let restart_parameters = restart: --innodb-directories=$innodb_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--source include/start_mysqld.inc

--echo # Alter table
ALTER TABLE dbtest.t1a FORCE;
ALTER TABLE dbtest.t1b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t1c FORCE, ALGORITHM=COPY;

ALTER TABLE dbtest.t2a FORCE;
ALTER TABLE dbtest.t2b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t2c FORCE, ALGORITHM=COPY;

ALTER TABLE dbtest.t3a FORCE;
ALTER TABLE dbtest.t3b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t3c FORCE, ALGORITHM=COPY;

ALTER TABLE dbtest.t4a FORCE;
ALTER TABLE dbtest.t4b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t4c FORCE, ALGORITHM=COPY;

ALTER TABLE dbtest.t5a FORCE;
ALTER TABLE dbtest.t5b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t5c FORCE, ALGORITHM=COPY;

ALTER TABLE dbtest.t6a FORCE;
ALTER TABLE dbtest.t6b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t6c FORCE, ALGORITHM=COPY;

--echo # Check that the ibd files for t1a, t1b, t1c, t3a, t3b, t3c still exist in the innodb_directories folder
--list_files $INNODB_DIRECTORIES/dbtest *

--echo # Check that the ibd files for t1a, t1b, t1c, t3a, t3b, t3c do not exist and ibd files for t5a, t5b, t5c, t6a, t6b, t6c exist in the data directory folder
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Check that the ibd files for t5a, t5b, t5c, t6a, t6b, t6c do not exist in external directory2 where the tables are created
--list_files $EXTERNAL_DIR2/dbtest *

--echo # Check that the ibd files for t2a, t2b, t2c, t4a, t4b, t4c still exist in the external directory where the tables are created
--list_files $EXTERNAL_DIR/dbtest *

--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # Now move ibd files for t1a, t1b, t1c, t3a, t3b, t3c from innodb_directories folder to default directory
--copy_files_wildcard $INNODB_DIRECTORIES/dbtest/ $MYSQLD_DATADIR/dbtest/ *
--remove_files_wildcard $INNODB_DIRECTORIES/dbtest/ *

--echo # Restart the server
--let $innodb_dirs=$INNODB_DIRECTORIES;$EXTERNAL_DIR;$EXTERNAL_DIR2
let restart_parameters = restart: --innodb-directories=$innodb_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--source include/start_mysqld.inc

--echo # Alter table
ALTER TABLE dbtest.t1a FORCE;
ALTER TABLE dbtest.t1b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t1c FORCE, ALGORITHM=COPY;

ALTER TABLE dbtest.t3a FORCE;
ALTER TABLE dbtest.t3b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t3c FORCE, ALGORITHM=COPY;

--echo # Check ibd files for t1a, t1b, t1c, t3a, t3b, t3c exist in default directory
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Check ibd files for t1a, t1b, t1c, t3a, t3b, t3c do not exist in innodb_directories
--list_files $INNODB_DIRECTORIES/dbtest *

--echo # Clean Up

--echo # Drop tables
DROP TABLE dbtest.t1a;
DROP TABLE dbtest.t1b;
DROP TABLE dbtest.t1c;
DROP TABLE dbtest.t2a;
DROP TABLE dbtest.t2b;
DROP TABLE dbtest.t2c;
DROP TABLE dbtest.t3a;
DROP TABLE dbtest.t3b;
DROP TABLE dbtest.t3c;
DROP TABLE dbtest.t4a;
DROP TABLE dbtest.t4b;
DROP TABLE dbtest.t4c;
DROP TABLE dbtest.t5a;
DROP TABLE dbtest.t5b;
DROP TABLE dbtest.t5c;
DROP TABLE dbtest.t6a;
DROP TABLE dbtest.t6b;
DROP TABLE dbtest.t6c;

--echo # Clean up for other tests
--remove_files_wildcard $INNODB_DIRECTORIES/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR2/dbtest/ *

--echo # Additional test for tables with data directory clause

--echo # Move non-partitioned table with data dir clause at EXTERNAL_DIR1 to EXTERNAL_DIR2
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t7a` (`c1` INT) $data_directory_clause;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t7b` (`c1` INT) $data_directory_clause;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t7c` (`c1` INT) $data_directory_clause;

--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # Check that the ibd files for t7a, t7b, t7c exist in EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Move files from EXTERNAL_DIR to EXTERNAL_DIR2
--copy_files_wildcard $EXTERNAL_DIR/dbtest/ $EXTERNAL_DIR2/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR/dbtest/ *

--echo # Check that the ibd files now exist in EXTERNAL_DIR2
--list_files $EXTERNAL_DIR2/dbtest/ *

--echo # Restart the server
--let $innodb_dirs=$EXTERNAL_DIR;$EXTERNAL_DIR2
let restart_parameters = restart: --innodb-directories=$innodb_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--source include/start_mysqld.inc

--echo # Alter table
ALTER TABLE dbtest.t7a FORCE;
ALTER TABLE dbtest.t7b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t7c FORCE, ALGORITHM=COPY;

--echo # Check that the ibd files for t7a, t7b, t7c still exist in EXTERNAL_DIR2
--list_files $EXTERNAL_DIR2/dbtest/ *

--echo # Check that the ibd files for t7a, t7b, t7c do not exist in EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Clean up

--echo # Drop tables
DROP TABLE dbtest.t7a;
DROP TABLE dbtest.t7b;
DROP TABLE dbtest.t7c;

--echo # Clean up for other tests
--remove_files_wildcard $EXTERNAL_DIR/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR2/dbtest/ *


--echo # Additional tests for partitioned tables

--echo # 1. Creating partitioned table with data directory clause and both partitions in different directories
--echo # Partition tables with data directory clause
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t8a` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause2);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t8b` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause2);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t8c` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) $data_directory_clause2);
--echo # Partition table with one partition in external directory and one in default directory
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE `t8d` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10) $data_directory_clause, PARTITION p1 VALUES LESS THAN (20) );

--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # Check that for partition p0 for t8a, t8b, t8c and t8d exist in EXTERNAL_DIR and partition p1 for for t8a, t8b, t8c exist in EXTERNAL_DIR2

--echo # Listing EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Listing EXTERNAL_DIR2
--list_files $EXTERNAL_DIR2/dbtest/ *

--echo # List default directory. t8d's p1 partition should be present
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Restart the server
--let $innodb_dirs=$EXTERNAL_DIR;$EXTERNAL_DIR2
let restart_parameters = restart: --innodb-directories=$innodb_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--source include/start_mysqld.inc

--echo # Alter table
ALTER TABLE dbtest.t8a FORCE;
ALTER TABLE dbtest.t8b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t8c FORCE, ALGORITHM=COPY;
ALTER TABLE dbtest.t8d FORCE, ALGORITHM=COPY;
--echo # Check that for partition p0 for t8a, t8b, t8c still exist in EXTERNAL_DIR and partition p1 for for t8a, t8b, t8c still exist in EXTERNAL_DIR2

--echo # Listing EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Listing EXTERNAL_DIR2
--list_files $EXTERNAL_DIR2/dbtest/ *

--echo # List default directory. t8d's p1 partition should be present
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # Now lets move all partitioned tables p0 of t8a, t8b, t8c, t8d from EXTERNAL_DIR and partitioned tables p1 of t8a, t8b, t8c from EXTERNAL_DIR2 to default directory
--copy_files_wildcard $EXTERNAL_DIR/dbtest/ $MYSQLD_DATADIR/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR/dbtest/ *
--copy_files_wildcard $EXTERNAL_DIR2/dbtest/ $MYSQLD_DATADIR/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR2/dbtest/ *

--echo # Restart the server
--let $innodb_dirs=$EXTERNAL_DIR;$EXTERNAL_DIR2
let restart_parameters = restart: --innodb-directories=$innodb_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--source include/start_mysqld.inc

--echo # Alter table
ALTER TABLE dbtest.t8a FORCE;
ALTER TABLE dbtest.t8b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t8c FORCE, ALGORITHM=COPY;

--echo # Check that all the partitioned tables for t8a, t8b, t8c and t8d now exist in default directory
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Check that EXTERNAL_DIR and EXTERNAL_DIR2 are empty
--echo # Listing EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Listing EXTERNAL_DIR2
--list_files $EXTERNAL_DIR2/dbtest/ *

ALTER TABLE dbtest.t8d FORCE, ALGORITHM=COPY;

--echo # Check that all the partitioned tables for t8a, t8b, t8c and t8d now exist in default directory
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Check that EXTERNAL_DIR and EXTERNAL_DIR2 are empty
--echo # Listing EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Listing EXTERNAL_DIR2
--list_files $EXTERNAL_DIR2/dbtest/ *

--echo # Drop tables
DROP TABLE dbtest.t8a;
DROP TABLE dbtest.t8b;
DROP TABLE dbtest.t8c;
DROP TABLE dbtest.t8d;

--echo # Clean up for other tests
--remove_files_wildcard $EXTERNAL_DIR/dbtest/ *
--remove_files_wildcard $EXTERNAL_DIR2/dbtest/ *

--echo # 2. Creating partitioned table without data directory clause but moving each partition to different external directories
--echo # Partition tables
CREATE TABLE `t9a` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));
CREATE TABLE `t9b` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));
CREATE TABLE `t9c` (a INT, b INT) PARTITION BY RANGE(a) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));

--echo # Shutdown server
--source include/shutdown_mysqld.inc

--echo # Check that the ibd files for all p0 and p1 partitions of t9a, t9b, t9c  table exist in the working (dbtest) folder
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Now move only p1 partitioned tables of t9a, t9b, t9c to EXTERNAL_DIR
--copy_files_wildcard $MYSQLD_DATADIR/dbtest/ $EXTERNAL_DIR/dbtest/ t9a#p#p1.ibd
--remove_files_wildcard $MYSQLD_DATADIR/dbtest/ t9a#p#p1.ibd
--copy_files_wildcard $MYSQLD_DATADIR/dbtest/ $EXTERNAL_DIR/dbtest/ t9b#p#p1.ibd
--remove_files_wildcard $MYSQLD_DATADIR/dbtest/ t9b#p#p1.ibd
--copy_files_wildcard $MYSQLD_DATADIR/dbtest/ $EXTERNAL_DIR/dbtest/ t9c#p#p1.ibd
--remove_files_wildcard $MYSQLD_DATADIR/dbtest/ t9c#p#p1.ibd

--echo # Check that the ibd files for all p0 of t9a, t9b, t9c  table exist in the working (dbtest) folder
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Check that the ibd files for all p1 of t9a, t9b, t9c  table exist in EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *

--echo # Restart the server
--let $innodb_dirs=$EXTERNAL_DIR
let restart_parameters = restart: --innodb-directories=$innodb_dirs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--source include/start_mysqld.inc

--echo # Alter table
ALTER TABLE dbtest.t9a FORCE;
ALTER TABLE dbtest.t9b FORCE, ALGORITHM=INPLACE;
ALTER TABLE dbtest.t9c FORCE, ALGORITHM=COPY;


--echo # Check that the ibd files for all p0 of t9a, t9b, t9c  table still exist in the working (dbtest) folder
--list_files $MYSQLD_DATADIR/dbtest *

--echo # Check that the ibd files for all p1 of t9a, t9b, t9c  table still exist in EXTERNAL_DIR
--list_files $EXTERNAL_DIR/dbtest/ *


--echo # Drop tables and database
DROP TABLE dbtest.t9a;
DROP TABLE dbtest.t9b;
DROP TABLE dbtest.t9c;
DROP DATABASE dbtest;

--let restart_parameters="restart: "
--source include/restart_mysqld.inc

--rmdir $INNODB_DIRECTORIES/dbtest
--rmdir $INNODB_DIRECTORIES

--rmdir $EXTERNAL_DIR/dbtest
--rmdir $EXTERNAL_DIR

--rmdir $EXTERNAL_DIR2/dbtest
--rmdir $EXTERNAL_DIR2

--echo # End Test