forked from mysql/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.test
78 lines (54 loc) · 2.49 KB
/
bootstrap.test
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
# Embedded server doesn't support restarting.
--source include/not_embedded.inc
# Prepare MYSQLD_DATADIR and MYSQLD_BOOTSTRAP_CMD.
# Add the datadir to the bootstrap command.
--let $MYSQLD_DATADIR = `SELECT @@datadir`
--let $MYSQLD_BOOTSTRAP_CMD = $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM
###########################################################################
# 1. Check that --bootstrap reads from stdin
###########################################################################
# Stop server
--source include/shutdown_mysqld.inc
--write_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql
USE test;
CREATE TABLE t1(a INT);
EOF
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql
###########################################################################
# 2. Check that --bootstrap of file with SQL error returns error
###########################################################################
--write_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql
USE test;
CREATE TABLE t2;
EOF
--error 1
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql
# Start server
--source include/start_mysqld.inc
# Drop t1 from the previous test (1).
DROP TABLE t1;
# Table t2 should not exists
--error ER_BAD_TABLE_ERROR
DROP TABLE t2;
###########################################################################
# 3. Bootstrap with a query larger than 2*thd->net.max_packet
###########################################################################
# Prepare a long query.
# NOTE: no need to save max_allowed_packet value as the server will be restarted.
SET @@global.max_allowed_packet = 100 * @@global.max_allowed_packet;
CREATE TABLE t1 SELECT 2 AS a, CONCAT(REPEAT('MySQL', @@max_allowed_packet/10), ';') AS b;
--replace_result $MYSQLTEST_VARDIR VARDIR
--eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/long_query.sql' FROM t1
# Stop server
--source include/shutdown_mysqld.inc
--error 1
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/long_query.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/long_query.sql
# Start server
--source include/start_mysqld.inc
SHOW CREATE TABLE t1;
SELECT a, LENGTH(b) FROM t1;
DROP TABLE t1;
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap.log