Debian Codegraph @

mysql-test/suite/sysschema/t/fn_format_path.test

raw
1 # Windows paths are \ not /, so ignore here
2 -- source include/not_windows.inc
3 # Tests for sys schema
4 # Verify the sys.format_path() function perfoms as expected
5 #
6
7 # Save current server option values;
8 let $page_size = `select @@innodb_page_size`;
9 let $MYSQLD_BASEDIR= `select @@basedir`;
10
11 # Create custom datadir
12 --mkdir $MYSQL_TMP_DIR/custom_datadir
13 let $CUSTOM_DATADIR = $MYSQL_TMP_DIR/custom_datadir/data;
14
15 # Stop the server because the MTR uses default value for innodb_undo_directory.
16 --source include/shutdown_mysqld.inc
17
18 let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/boot.sql;
19
20 # Create bootstrap file
21 write_file $BOOTSTRAP_SQL;
22 CREATE DATABASE test DEFAULT CHARACTER SET latin1;
23 EOF
24
25 # Set the bootstrap parameter with new innodb_undo_directory
26 let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure $KEYRING_PLUGIN_OPT --lc_messages_dir=$MYSQL_SHAREDIR --innodb-page-size=$page_size --basedir=$MYSQLD_BASEDIR --datadir=$CUSTOM_DATADIR --innodb_redo_log_capacity=30M --innodb_undo_directory=$MYSQLTEST_VARDIR/tmp/innodb_undo --init-file=$BOOTSTRAP_SQL --secure-file-priv="" </dev/null>>$MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1;
27
28 # Run the bootstrap command
29 --exec $NEW_CMD
30
31 # Start the DB server with new datadir, innodb_data_home_dir, innodb_log_group_home_dir and innodb_undo_directory
32 --replace_result $CUSTOM_DATADIR CUSTOM_DATADIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
33 --let $restart_parameters="restart: --datadir=$CUSTOM_DATADIR --innodb_data_home_dir=$MYSQLTEST_VARDIR/tmp/innodb --innodb_log_group_home_dir=$MYSQLTEST_VARDIR/tmp/innodb_logs --innodb_undo_directory=$MYSQLTEST_VARDIR/tmp/innodb_undo"
34 --source include/start_mysqld.inc
35
36 # Passing NULL should return NULL
37 SELECT sys.format_path(NULL);
38
39 # Ensure basedir is recognized and stripped
40 SET @mypath := CONCAT(@@global.basedir, 'logs/binlog.000001');
41
42 SELECT sys.format_path(@mypath);
43
44 # Ensure datadir is recognized and stripped
45 SET @mypath := CONCAT(@@global.datadir, 'foo/bar.foo');
46
47 SELECT sys.format_path(@mypath);
48
49 # Ensure tmpdir is recognized and stripped
50 SET @mypath := CONCAT(@@global.tmpdir, '/foo/bar.foo');
51
52 SELECT sys.format_path(@mypath);
53
54 # Ensure innodb_data_home_dir is recognized and stripped
55 SET @mypath := CONCAT(@@global.innodb_data_home_dir, '/foo/bar.ibd');
56
57 SELECT sys.format_path(@mypath);
58
59 # Ensure innodb_log_group_home_dir is recognized and stripped
60 SET @mypath := CONCAT(@@global.innodb_log_group_home_dir, '/#innodb_redo/#ib_redo0');
61
62 SELECT sys.format_path(@mypath);
63
64 # Ensure innodb_undo_directory is recognized and stripped
65 SET @mypath := CONCAT(@@global.innodb_undo_directory, '/undo0');
66
67 SELECT sys.format_path(@mypath);
68
69 # Unrecognized paths should return the full path
70 SELECT sys.format_path('/foo/bar/baz.foo');
71
72 # Restart the server
73 let $restart_parameters=;
74 --source include/restart_mysqld.inc
75
76 # Cleanup
77 --remove_file $BOOTSTRAP_SQL
78 --force-rmdir $MYSQL_TMP_DIR/custom_datadir
79 --remove_file $MYSQLTEST_VARDIR/tmp/bootstrap.log