File: fn_format_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 (79 lines) | stat: -rw-r--r-- 2,959 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
# Windows paths are \ not /, so ignore here
-- source include/not_windows.inc
# Tests for sys schema
# Verify the sys.format_path() function perfoms as expected
#

# Save current server option values;
let $page_size = `select @@innodb_page_size`;
let $MYSQLD_BASEDIR= `select @@basedir`;

# Create custom datadir
--mkdir $MYSQL_TMP_DIR/custom_datadir
let $CUSTOM_DATADIR = $MYSQL_TMP_DIR/custom_datadir/data;

# Stop the server because the MTR uses default value for innodb_undo_directory.
--source include/shutdown_mysqld.inc

let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/boot.sql;

# Create bootstrap file
write_file $BOOTSTRAP_SQL;
CREATE DATABASE test DEFAULT CHARACTER SET latin1;
EOF

# Set the bootstrap parameter with new innodb_undo_directory
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;

# Run the bootstrap command
--exec $NEW_CMD

# Start the DB server with new datadir, innodb_data_home_dir, innodb_log_group_home_dir and innodb_undo_directory
--replace_result $CUSTOM_DATADIR CUSTOM_DATADIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--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"
--source include/start_mysqld.inc

# Passing NULL should return NULL
SELECT sys.format_path(NULL);

# Ensure basedir is recognized and stripped
SET @mypath := CONCAT(@@global.basedir, 'logs/binlog.000001');

SELECT sys.format_path(@mypath);

# Ensure datadir is recognized and stripped
SET @mypath := CONCAT(@@global.datadir, 'foo/bar.foo');

SELECT sys.format_path(@mypath);

# Ensure tmpdir is recognized and stripped
SET @mypath := CONCAT(@@global.tmpdir, '/foo/bar.foo');

SELECT sys.format_path(@mypath);

# Ensure innodb_data_home_dir is recognized and stripped
SET @mypath := CONCAT(@@global.innodb_data_home_dir, '/foo/bar.ibd');

SELECT sys.format_path(@mypath);

# Ensure innodb_log_group_home_dir is recognized and stripped
SET @mypath := CONCAT(@@global.innodb_log_group_home_dir, '/#innodb_redo/#ib_redo0');

SELECT sys.format_path(@mypath);

# Ensure innodb_undo_directory is recognized and stripped
SET @mypath := CONCAT(@@global.innodb_undo_directory, '/undo0');

SELECT sys.format_path(@mypath);

# Unrecognized paths should return the full path
SELECT sys.format_path('/foo/bar/baz.foo');

# Restart the server
let $restart_parameters=;
--source include/restart_mysqld.inc

# Cleanup
--remove_file $BOOTSTRAP_SQL
--force-rmdir $MYSQL_TMP_DIR/custom_datadir
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap.log