1
######## include/ddl1.inc ######
3
# Purpose of include/ddl1.inc - include/ddl8.inc:
5
# Stress storage engines with rapid CREATE/DROP TABLE/INDEX
6
# and following SELECT/INSERT/SHOW etc.
9
# $loop_size -- number of rounds till we look at the clock again
10
# $runtime -- rough intended runtime per subtest variant
11
# Real runtime without server restarts and comparison is:
13
# - > runtime needed for $loop_size execution loops
14
# $engine_type -- storage engine to be used in CREATE TABLE
15
# must be set within the routine sourcing this script.
17
# Other stuff which must already exist:
19
# - stmt_start and stmt_break prepared by the default connection
22
# The test does suppress the writing of most statements, server error
23
# messages and result sets.
24
# This is needed because their number is usual not deterministic.
25
# The test is partially self checking. That means is prints some
26
# helpful hints into the protocol and aborts if something is wrong.
28
# Creation of this test:
31
############################################################################
35
# 1. Base question of the test:
36
# There was just a create or drop of some object (TABLE/INDEX).
38
# Could it happen that the next statement referring to this
39
# object gets a somehow wrong server response (result set,
40
# error message, warning) because the creation or removal of
41
# the object is in an incomplete state?
43
# Thinkable reasons for incomplete state of creation or removal:
44
# The server performs the creation or removal
45
# - all time incomplete.
47
# Bug#28309 First insert violates unique constraint
48
# - was "memory" table empty ?
50
# In that case the next statement has probably to wait till
53
# 2. Why do we use in some scripts "--error 0,<expected error>" followed
54
# a check of $mysql_errno?
56
# System reactions when running with "--error 0,<expected error>":
57
# - RC=0 --> no error message
58
# - RC=<expected error> --> no error message
59
# - RC not in (0,<expected error>) --> error message + abort of script
62
# Requirements and tricky solution for statements which are expected
64
# 1. RC=<expected error>
65
# - no abort of script execution
66
# --> add "--error <expected error>"
67
# - no error message into the protocol, because the number of
68
# executions is NOT deterministic
69
# --> use "--error 0,<expected error>"
71
# - abort of script execution
72
# "--error 0,<expected error>" prevents the automatic abort of
73
# execution. Therefore we do not need to code the abort.
74
# --> Check $mysql_errno and do an explicit abort if $mysql_errno = 0.
75
# 3. RC not in (0,<expected error>)
76
# - abort of script execution
77
# "--error 0,<expected error>" causes an automatic abort.
79
# 3. We do not check the correctness of the SHOW CREATE TABLE output
80
# in detail. This must be done within other tests.
81
# We only check here that
82
# - same CREATE TABLE/INDEX statements lead to the same
83
# - different CREATE TABLE/INDEX statements lead to different
84
# SHOW CREATE TABLE output
85
# (Applies to ddl4.inc. and ddl8.inc.)
87
# 4. It could be assumed that running this test with
89
# There are already subtests using prepared statements contained.
90
# - SP/CURSOR/VIEW-PROTOCOL
91
# These protocol variants transform SELECTs to hopefully much
92
# stressing statement sequencies using SP/CURSOR/VIEW.
93
# The SELECTs within include/ddl*.inc are very simple.
94
# does not increase the coverage.
95
# Therefore we skip runs with these protocols.
97
# 5. The test consumes significant runtime when running on a non RAM
98
# based filesystem (run without "--mem").
99
# Therefore we adjust $runtime and $loop_size depending on "--big-test"
101
# $runtime and $loop_size do not influence the expected results.
102
# Rough runtime in seconds reported by mysql-test-run.pl:
103
# (engine_type = MEMORY)
104
# option set -> $runtime $loop_size real runtime in seconds
107
# --big-test 5 100 200
108
# --mem --big-test 5 100 400
109
# I assume that runs with slow filesystems are as much valuable
110
# as runs with extreme fast filesystems.
112
# 6. Hints for analysis of test failures:
113
# 1. Look into the protocol and check in which ddl*.inc
114
# script the difference to the expected result occured.
115
# 2. Comment the sourcing of all other ddl*.inc scripts
117
# 3. Edit the ddl*.inc script where the error occured and
119
# - "--disable_query_log", "--disable_result_log"
120
# - successful passed subtests.
122
# Have a look into VARDIR/master-data/mysql/general_log.CSV
123
# and construct a new testcase from that.
124
# 5. If the problem is not deterministic, please try the following
125
# - increase $runtime (important), $loop_size (most probably
126
# less important) within the "t/ddl_<engine>.test" and
127
# maybe the "--testcase-timeout" assigned to mysqltest-run.pl
128
# - vary the I/O performance of the testing machine by using
129
# a RAM or disk based filesystem for VARDIR
133
#----------------------------------------------------------------------
134
# Settings for Subtest 1 variants
135
# Scenario: CREATE with UNIQUE KEY/INSERT/DROP TABLE like in Bug#28309
136
let $create_table= CREATE TABLE t1 (f1 BIGINT,f2 BIGINT,UNIQUE(f1),UNIQUE(f2))
137
ENGINE = $engine_type;
138
let $insert_into= INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
139
let $drop_table= DROP TABLE t1;
140
#----------------------------------------------------------------------
143
--echo # Subtest 1A (one connection, no PREPARE/EXECUTE)
144
--echo # connection action
145
--echo # default: $create_table
146
--echo # default: $insert_into
147
--echo # default: $drop_table
151
# Determine the current time.
153
# Run execution loops till the planned runtime is reached
156
let $loop_run= $loop_size;
164
if (`EXECUTE stmt_break`)
171
--echo # Subtest 1B (one connection, use PREPARE/EXECUTE)
172
--echo # connection action
173
--echo # default: $create_table
174
--echo # default: $insert_into
175
--echo # default: $drop_table
178
eval PREPARE create_table FROM "$create_table";
179
EXECUTE create_table;
180
eval PREPARE insert_into FROM "$insert_into";
181
eval PREPARE drop_table FROM "$drop_table";
184
# Determine the current time.
186
# Run execution loops till the planned runtime is reached
189
let $loop_run= $loop_size;
192
EXECUTE create_table;
197
if (`EXECUTE stmt_break`)
202
DEALLOCATE PREPARE create_table;
203
DEALLOCATE PREPARE insert_into;
204
DEALLOCATE PREPARE drop_table;
207
--echo # Subtest 1C (two connections, no PREPARE/EXECUTE)
208
--echo # connection action
209
--echo # default: $create_table
210
--echo # con2: $insert_into
211
--echo # con2: $drop_table
215
# Determine the current time.
217
# Run execution loops till the planned runtime is reached
220
let $loop_run= $loop_size;
230
if (`EXECUTE stmt_break`)
237
--echo # Subtest 1D (two connections, use PREPARE/EXECUTE)
238
--echo # connection action
239
--echo # default: $create_table
240
--echo # con2: $insert_into
241
--echo # con2: $drop_table
244
eval PREPARE create_table FROM "$create_table";
245
EXECUTE create_table;
247
eval PREPARE insert_into FROM "$insert_into";
248
eval PREPARE drop_table FROM "$drop_table";
252
# Determine the current time.
254
# Run execution loops till the planned runtime is reached
257
let $loop_run= $loop_size;
260
EXECUTE create_table;
267
if (`EXECUTE stmt_break`)
272
DEALLOCATE PREPARE create_table;
274
DEALLOCATE PREPARE insert_into;
275
DEALLOCATE PREPARE drop_table;