~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
######## include/ddl2.inc ######
2
#
3
# Stress the storage engine with rapid CREATE/DROP TABLE/INDEX
4
# and following SELECT/INSERT/SHOW etc.
5
# Subtest 2 variants (2A - 2D)
6
#
7
# The variables
8
#     $loop_size -- number of rounds till we look at the clock again
9
#     $runtime   -- rough intended runtime per subtest variant
10
#     $engine_type -- storage engine to be used in CREATE TABLE
11
# must be set within the routine sourcing this script.
12
#
13
# Other stuff which must already exist:
14
# - connection con2
15
# - stmt_start and stmt_break prepared by the default connection
16
#
17
# Please look for more details within include/ddl1.inc.
18
#
19
# Creation of this test:
20
# 2007-07-04 mleich
21
#
22
23
24
#----------------------------------------------------------------------
25
# Settings for Subtest 2 variants
26
# Scenario: CREATE TABLE AS SELECT/SELECT/DROP/SELECT(F)
27
let $create_table=  CREATE TABLE t1 ENGINE = $engine_type AS SELECT 1 AS f1;
28
let $select_record= SELECT COUNT(*) <> 1 FROM t1 WHERE f1 = 1;
29
let $drop_table=    DROP TABLE t1;
30
#----------------------------------------------------------------------
31
32
#
33
--echo # Subtest 2A (one connection, no PREPARE/EXECUTE)
34
--echo #    connection  action
35
--echo #    default:    $create_table
36
--echo #    default:    $select_record
37
--echo #    default:    $drop_table
38
--echo #    default:    $select_record (expect to get ER_NO_SUCH_TABLE)
39
--disable_query_log
40
--disable_result_log
41
connection default;
42
let $run= 1;
43
# Determine the current time.
44
EXECUTE stmt_start;
45
# Run execution loops till the planned runtime is reached
46
while ($run)
47
{
48
   let $loop_run= $loop_size;
49
   while ($loop_run)
50
   {
51
      eval $create_table;
52
      if (`$select_record`)
53
      {
54
         --enable_result_log
55
         --enable_query_log
56
         --echo # Error: Unexpected content within t1.
57
         --echo # Expected: 0
58
         --echo # Got:
59
         eval $select_record;
60
         SELECT * FROM t1;
61
         --echo # abort
62
         exit;
63
      }
64
      eval $drop_table;
65
      --error 0,ER_NO_SUCH_TABLE
66
      eval $select_record;
67
      if (!$mysql_errno)
68
      {
69
         --echo # Error: SELECT was successful though we expected ER_NO_SUCH_TABLE
70
         --echo # abort
71
         exit;
72
      }
73
      dec $loop_run;
74
   }
75
   if (`EXECUTE stmt_break`)
76
   {
77
      let $run= 0;
78
   }
79
}
80
--enable_result_log
81
--enable_query_log
82
#
83
--echo # Subtest 2B (one connection, use PREPARE/EXECUTE)
84
--echo #    connection  action
85
--echo #    default:    $create_table
86
--echo #    default:    $select_record
87
--echo #    default:    $drop_table
88
--echo #    default:    $select_record (expect to get ER_NO_SUCH_TABLE)
89
--disable_query_log
90
--disable_result_log
91
connection default;
92
eval PREPARE create_table FROM "$create_table";
93
EXECUTE create_table;
94
eval PREPARE select_record FROM "$select_record";
95
eval PREPARE drop_table FROM "$drop_table";
96
EXECUTE drop_table;
97
let $run= 1;
98
# Determine the current time.
99
EXECUTE stmt_start;
100
# Run execution loops till the planned runtime is reached
101
while ($run)
102
{
103
   let $loop_run= $loop_size;
104
   while ($loop_run)
105
   {
106
      EXECUTE create_table;
107
      if (`EXECUTE select_record`)
108
      {
109
         --enable_result_log
110
         --enable_query_log
111
         --echo # Error: Unexpected content within t1.
112
         --echo # Expected: 0
113
         --echo # Got:
114
         EXECUTE select_record;
115
         SELECT * FROM t1;
116
         --echo # abort
117
         exit;
118
      }
119
      EXECUTE drop_table;
120
      --error 0,ER_NO_SUCH_TABLE
121
      EXECUTE select_record;
122
      if (!$mysql_errno)
123
      {
124
         --echo # Error: SELECT was successful though we expected ER_NO_SUCH_TABLE
125
         --echo # abort
126
         exit;
127
      }
128
      dec $loop_run;
129
   }
130
   if (`EXECUTE stmt_break`)
131
   {
132
      let $run= 0;
133
   }
134
}
135
DEALLOCATE PREPARE create_table;
136
DEALLOCATE PREPARE select_record;
137
DEALLOCATE PREPARE drop_table;
138
--enable_result_log
139
--enable_query_log
140
#
141
--echo # Subtest 2C (two connections, no PREPARE/EXECUTE)
142
--echo #    connection  action
143
--echo #    default:    $create_table
144
--echo #    con2:       $select_record
145
--echo #    default:    $drop_table
146
--echo #    con2:       $select_record (expect to get ER_NO_SUCH_TABLE)
147
--disable_query_log
148
--disable_result_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
      connection con2;
161
      if (`$select_record`)
162
      {
163
         --enable_result_log
164
         --enable_query_log
165
         --echo # Error: Unexpected content within t1.
166
         --echo # Expected: 0
167
         --echo # Got:
168
         eval $select_record;
169
         SELECT * FROM t1;
170
         --echo # abort
171
         exit;
172
      }
173
      connection default;
174
      eval $drop_table;
175
      connection con2;
176
      --error 0,ER_NO_SUCH_TABLE
177
      eval $select_record;
178
      if (!$mysql_errno)
179
      {
180
         --echo # Error: SELECT was successful though we expected ER_NO_SUCH_TABLE
181
         --echo # abort
182
         exit;
183
      }
184
      connection default;
185
      dec $loop_run;
186
   }
187
   if (`EXECUTE stmt_break`)
188
   {
189
      let $run= 0;
190
   }
191
}
192
--enable_result_log
193
--enable_query_log
194
#
195
--echo # Subtest 2D (two connections, use PREPARE/EXECUTE)
196
--echo #    connection  action
197
--echo #    default:    $create_table
198
--echo #    con2:       $select_record
199
--echo #    default:    $drop_table
200
--echo #    con2:       $select_record (expect to get ER_NO_SUCH_TABLE)
201
--disable_query_log
202
--disable_result_log
203
connection default;
204
eval PREPARE create_table FROM "$create_table";
205
eval PREPARE drop_table FROM "$drop_table";
206
EXECUTE create_table;
207
connection con2;
208
eval PREPARE select_record FROM "$select_record";
209
connection default;
210
EXECUTE drop_table;
211
let $run= 1;
212
# Determine the current time.
213
EXECUTE stmt_start;
214
# Run execution loops till the planned runtime is reached
215
while ($run)
216
{
217
   let $loop_run= $loop_size;
218
   while ($loop_run)
219
   {
220
      EXECUTE create_table;
221
      connection con2;
222
      if (`EXECUTE select_record`)
223
      {
224
         --enable_result_log
225
         --enable_query_log
226
         --echo # Error: Unexpected content within t1.
227
         --echo # Expected: 0
228
         --echo # Got:
229
         EXECUTE select_record;
230
         SELECT * FROM t1;
231
         --echo # abort
232
         exit;
233
      }
234
      connection default;
235
      EXECUTE drop_table;
236
      connection con2;
237
      --error 0,ER_NO_SUCH_TABLE
238
      EXECUTE select_record;
239
      if (!$mysql_errno)
240
      {
241
         --echo # Error: SELECT was successful though we expected ER_NO_SUCH_TABLE
242
         --echo # abort
243
         exit;
244
      }
245
      connection default;
246
      dec $loop_run;
247
   }
248
   if (`EXECUTE stmt_break`)
249
   {
250
      let $run= 0;
251
   }
252
}
253
DEALLOCATE PREPARE create_table;
254
DEALLOCATE PREPARE drop_table;
255
connection con2;
256
DEALLOCATE PREPARE select_record;
257
connection default;
258
--enable_result_log
259
--enable_query_log