| 1 |
######## include/ddl1.inc ###### |
| 2 |
# |
| 3 |
# Purpose of include/ddl1.inc - include/ddl8.inc: |
| 4 |
# |
| 5 |
# Stress storage engines with rapid CREATE/DROP TABLE/INDEX |
| 6 |
# and following SELECT/INSERT/SHOW etc. |
| 7 |
# |
| 8 |
# The variables |
| 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: |
| 12 |
# - >= $runtime |
| 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. |
| 16 |
# |
| 17 |
# Other stuff which must already exist: |
| 18 |
# - connection con2 |
| 19 |
# - stmt_start and stmt_break prepared by the default connection |
| 20 |
# |
| 21 |
# Attention: |
| 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. |
| 27 |
# |
| 28 |
# Creation of this test: |
| 29 |
# 2007-07-04 mleich |
| 30 |
# |
| 31 |
############################################################################ |
| 32 |
# |
| 33 |
# Some details: |
| 34 |
# |
| 35 |
# 1. Base question of the test: |
| 36 |
# There was just a create or drop of some object (TABLE/INDEX). |
| 37 |
# |
| 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? |
| 42 |
# |
| 43 |
# Thinkable reasons for incomplete state of creation or removal: |
| 44 |
# The server performs the creation or removal |
| 45 |
# - all time incomplete. |
| 46 |
# Example: |
| 47 |
# Bug#28309 First insert violates unique constraint |
| 48 |
# - was "memory" table empty ? |
| 49 |
# - asynchronous |
| 50 |
# In that case the next statement has probably to wait till |
| 51 |
# completion. |
| 52 |
# |
| 53 |
# 2. Why do we use in some scripts "--error 0,<expected error>" followed |
| 54 |
# a check of $mysql_errno? |
| 55 |
# |
| 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 |
| 60 |
# execution |
| 61 |
# |
| 62 |
# Requirements and tricky solution for statements which are expected |
| 63 |
# to fail: |
| 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>" |
| 70 |
# 2. RC=0 = failure |
| 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. |
| 78 |
# |
| 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.) |
| 86 |
# |
| 87 |
# 4. It could be assumed that running this test with |
| 88 |
# - PS-PROTOCOL |
| 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. |
| 96 |
# |
| 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" |
| 100 |
# option. |
| 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 |
| 105 |
# 1 20 68 |
| 106 |
# --mem 1 20 32 |
| 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. |
| 111 |
# |
| 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 occurred. |
| 115 |
# 2. Comment the sourcing of all other ddl*.inc scripts |
| 116 |
# out. |
| 117 |
# 3. Edit the ddl*.inc script where the error occurred and |
| 118 |
# remove all |
| 119 |
# - "--disable_query_log", "--disable_result_log" |
| 120 |
# - successful passed subtests. |
| 121 |
# 4. Alternative: |
| 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 |
| 130 |
# |
| 131 |
|
| 132 |
|
| 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 |
#---------------------------------------------------------------------- |
| 141 |
|
| 142 |
# |
| 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 |
| 148 |
--disable_query_log |
| 149 |
connection default; |
| 150 |
let $run= 1; |
| 151 |
# Determine the current time. |
| 152 |
EXECUTE stmt_start; |
| 153 |
# Run execution loops till the planned runtime is reached |
| 154 |
while ($run) |
| 155 |
{ |
| 156 |
let $loop_run= $loop_size; |
| 157 |
while ($loop_run) |
| 158 |
{ |
| 159 |
eval $create_table; |
| 160 |
eval $insert_into; |
| 161 |
eval $drop_table; |
| 162 |
dec $loop_run; |
| 163 |
} |
| 164 |
if (`EXECUTE stmt_break`) |
| 165 |
{ |
| 166 |
let $run= 0; |
| 167 |
} |
| 168 |
} |
| 169 |
--enable_query_log |
| 170 |
# |
| 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 |
| 176 |
--disable_query_log |
| 177 |
connection default; |
| 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"; |
| 182 |
EXECUTE drop_table; |
| 183 |
let $run= 1; |
| 184 |
# Determine the current time. |
| 185 |
EXECUTE stmt_start; |
| 186 |
# Run execution loops till the planned runtime is reached |
| 187 |
while ($run) |
| 188 |
{ |
| 189 |
let $loop_run= $loop_size; |
| 190 |
while ($loop_run) |
| 191 |
{ |
| 192 |
EXECUTE create_table; |
| 193 |
EXECUTE insert_into; |
| 194 |
EXECUTE drop_table; |
| 195 |
dec $loop_run; |
| 196 |
} |
| 197 |
if (`EXECUTE stmt_break`) |
| 198 |
{ |
| 199 |
let $run= 0; |
| 200 |
} |
| 201 |
} |
| 202 |
DEALLOCATE PREPARE create_table; |
| 203 |
DEALLOCATE PREPARE insert_into; |
| 204 |
DEALLOCATE PREPARE drop_table; |
| 205 |
--enable_query_log |
| 206 |
# |
| 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 |
| 212 |
--disable_query_log |
| 213 |
connection default; |
| 214 |
let $run= 1; |
| 215 |
# Determine the current time. |
| 216 |
EXECUTE stmt_start; |
| 217 |
# Run execution loops till the planned runtime is reached |
| 218 |
while ($run) |
| 219 |
{ |
| 220 |
let $loop_run= $loop_size; |
| 221 |
while ($loop_run) |
| 222 |
{ |
| 223 |
eval $create_table; |
| 224 |
connection con2; |
| 225 |
eval $insert_into; |
| 226 |
eval $drop_table; |
| 227 |
connection default; |
| 228 |
dec $loop_run; |
| 229 |
} |
| 230 |
if (`EXECUTE stmt_break`) |
| 231 |
{ |
| 232 |
let $run= 0; |
| 233 |
} |
| 234 |
} |
| 235 |
--enable_query_log |
| 236 |
# |
| 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 |
| 242 |
--disable_query_log |
| 243 |
connection default; |
| 244 |
eval PREPARE create_table FROM "$create_table"; |
| 245 |
EXECUTE create_table; |
| 246 |
connection con2; |
| 247 |
eval PREPARE insert_into FROM "$insert_into"; |
| 248 |
eval PREPARE drop_table FROM "$drop_table"; |
| 249 |
EXECUTE drop_table; |
| 250 |
connection default; |
| 251 |
let $run= 1; |
| 252 |
# Determine the current time. |
| 253 |
EXECUTE stmt_start; |
| 254 |
# Run execution loops till the planned runtime is reached |
| 255 |
while ($run) |
| 256 |
{ |
| 257 |
let $loop_run= $loop_size; |
| 258 |
while ($loop_run) |
| 259 |
{ |
| 260 |
EXECUTE create_table; |
| 261 |
connection con2; |
| 262 |
EXECUTE insert_into; |
| 263 |
EXECUTE drop_table; |
| 264 |
connection default; |
| 265 |
dec $loop_run; |
| 266 |
} |
| 267 |
if (`EXECUTE stmt_break`) |
| 268 |
{ |
| 269 |
let $run= 0; |
| 270 |
} |
| 271 |
} |
| 272 |
DEALLOCATE PREPARE create_table; |
| 273 |
connection con2; |
| 274 |
DEALLOCATE PREPARE insert_into; |
| 275 |
DEALLOCATE PREPARE drop_table; |
| 276 |
connection default; |
| 277 |
--enable_query_log |