~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
######## include/ddl7.inc ######
2
#
3
# Stress the storage engine with rapid CREATE/DROP TABLE/INDEX
4
# and following SELECT/INSERT/SHOW etc.
5
# Subtest 7 variants (7A - 7D)
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 7 variants
26
# Scenario: CREATE INDEX/INSERT(F)/DROP INDEX/INSERT/CREATE INDEX(F)/DELETE
27
let $create_index=   CREATE UNIQUE INDEX IDX1 ON t1 (f2);
28
let $insert_record=  INSERT INTO t1 VALUES(1,1);
29
let $drop_index=     DROP INDEX IDX1 ON t1;
30
let $delete_record=  DELETE FROM t1 WHERE f1 = 1;
31
eval CREATE TABLE t1 (f1 BIGINT, f2 BIGINT, PRIMARY KEY(f1)) ENGINE=$engine_type;
32
INSERT INTO t1 VALUES(0,1);
33
#----------------------------------------------------------------------
34
35
#
36
--echo # Subtest 7A (one connection, no PREPARE/EXECUTE)
37
--echo #    connection  action
38
--echo #    default:    $create_index
39
--echo #    default:    $insert_record (expect to get ER_DUP_ENTRY)
40
--echo #    default:    $drop_index
41
--echo #    default:    $insert_record
42
--echo #    default:    $create_index  (expect to get ER_DUP_ENTRY)
43
--echo #    default:    $delete_record
44
--disable_query_log
45
--disable_result_log
46
connection default;
47
let $run= 1;
48
let $counter= 1;
49
# Determine the current time.
50
EXECUTE stmt_start;
51
# Run execution loops till the planned runtime is reached
52
while ($run)
53
{
54
   let $loop_run= $loop_size;
55
   while ($loop_run)
56
   {
57
      eval $create_index;
58
      --error 0,ER_DUP_ENTRY
59
      eval $insert_record;
60
      if (!$mysql_errno)
61
      {
62
         --echo # Error: INSERT was successful though we expected ER_DUP_ENTRY
63
         --echo # abort
64
         exit;
65
      }
66
      eval $drop_index;
67
      eval $insert_record;
68
      # NDB: ER_DUP_UNIQUE, others: ER_DUP_ENTRY
69
      --error 0,ER_DUP_ENTRY,ER_DUP_UNIQUE
70
      eval $create_index;
71
      if (!$mysql_errno)
72
      {
73
         --echo # Error: CREATE INDEX was successful though we expected ER_DUP_ENTRY
74
         --echo # Error: or ER_DUP_UNIQUE (NDB only)
75
         --echo # abort
76
         exit;
77
      }
78
      eval $delete_record;
79
      dec $loop_run;
80
   }
81
   if (`EXECUTE stmt_break`)
82
   {
83
      let $run= 0;
84
   }
85
}
86
--enable_result_log
87
--enable_query_log
88
#
89
--echo # Subtest 7B (one connection, use PREPARE/EXECUTE)
90
--echo #    connection  action
91
--echo #    default:    $create_index
92
--echo #    default:    $insert_record (expect to get ER_DUP_ENTRY)
93
--echo #    default:    $drop_index
94
--echo #    default:    $insert_record
95
--echo #    default:    $create_index  (expect to get ER_DUP_ENTRY)
96
--echo #    default:    $delete_record
97
--disable_query_log
98
--disable_result_log
99
connection default;
100
eval PREPARE create_index FROM "$create_index";
101
eval PREPARE insert_record FROM "$insert_record";
102
eval PREPARE delete_record FROM "$delete_record";
103
eval PREPARE drop_index FROM "$drop_index";
104
let $run= 1;
105
let $counter= 1;
106
# Determine the current time.
107
EXECUTE stmt_start;
108
# Run execution loops till the planned runtime is reached
109
while ($run)
110
{
111
   let $loop_run= $loop_size;
112
   while ($loop_run)
113
   {
114
      EXECUTE create_index;
115
      --error 0,ER_DUP_ENTRY
116
      EXECUTE insert_record;
117
      if (!$mysql_errno)
118
      {
119
         --echo # Error: INSERT was successful though we expected ER_DUP_ENTRY
120
         --echo # abort
121
         exit;
122
      }
123
      EXECUTE drop_index;
124
      EXECUTE insert_record;
125
      --error 0,ER_DUP_ENTRY
126
      EXECUTE create_index;
127
      if (!$mysql_errno)
128
      {
129
         --echo # Error: CREATE INDEX was successful though we expected ER_DUP_ENTRY
130
         --echo # abort
131
         exit;
132
      }
133
      EXECUTE delete_record;
134
      dec $loop_run;
135
   }
136
   if (`EXECUTE stmt_break`)
137
   {
138
      let $run= 0;
139
   }
140
}
141
DEALLOCATE PREPARE create_index;
142
DEALLOCATE PREPARE insert_record;
143
DEALLOCATE PREPARE delete_record;
144
DEALLOCATE PREPARE drop_index;
145
--enable_result_log
146
--enable_query_log
147
#
148
--echo # Subtest 7C (two connections, no PREPARE/EXECUTE)
149
--echo #    connection  action
150
--echo #    default:    $create_index
151
--echo #    default:    $insert_record (expect to get ER_DUP_ENTRY)
152
--echo #    con2:       $drop_index
153
--echo #    default:    $insert_record
154
--echo #    con2:       $create_index  (expect to get ER_DUP_ENTRY)
155
--echo #    con2:       $delete_record
156
--disable_query_log
157
--disable_result_log
158
connection default;
159
let $run= 1;
160
let $counter= 1;
161
# Determine the current time.
162
EXECUTE stmt_start;
163
# Run execution loops till the planned runtime is reached
164
while ($run)
165
{
166
   let $loop_run= $loop_size;
167
   while ($loop_run)
168
   {
169
      eval $create_index;
170
      --error 0,ER_DUP_ENTRY
171
      eval $insert_record;
172
      if (!$mysql_errno)
173
      {
174
         --echo # Error: INSERT was successful though we expected ER_DUP_ENTRY
175
         --echo # abort
176
         exit;
177
      }
178
      connection con2;
179
      eval $drop_index;
180
      connection default;
181
      eval $insert_record;
182
      connection con2;
183
      --error 0,ER_DUP_ENTRY
184
      eval $create_index;
185
      if (!$mysql_errno)
186
      {
187
         --echo # Error: CREATE INDEX was successful though we expected ER_DUP_ENTRY
188
         --echo # abort
189
         exit;
190
      }
191
      eval $delete_record;
192
      connection default;
193
      dec $loop_run;
194
   }
195
   if (`EXECUTE stmt_break`)
196
   {
197
      let $run= 0;
198
   }
199
}
200
--enable_result_log
201
--enable_query_log
202
#
203
--echo # Subtest 7D (two connections, use PREPARE/EXECUTE)
204
--echo #    connection  action
205
--echo #    default:    $create_index
206
--echo #    default:    $insert_record (expect to get ER_DUP_ENTRY)
207
--echo #    con2:       $drop_index
208
--echo #    default:    $insert_record
209
--echo #    con2:       $create_index  (expect to get ER_DUP_ENTRY)
210
--echo #    con2:       $delete_record
211
--disable_query_log
212
--disable_result_log
213
connection default;
214
eval PREPARE create_index FROM "$create_index";
215
eval PREPARE insert_record FROM "$insert_record";
216
EXECUTE create_index;
217
connection con2;
218
eval PREPARE create_index FROM "$create_index";
219
eval PREPARE drop_index FROM "$drop_index";
220
eval PREPARE delete_record FROM "$delete_record";
221
EXECUTE drop_index;
222
connection default;
223
let $run= 1;
224
let $counter= 1;
225
# Determine the current time.
226
EXECUTE stmt_start;
227
# Run execution loops till the planned runtime is reached
228
while ($run)
229
{
230
   let $loop_run= $loop_size;
231
   while ($loop_run)
232
   {
233
      EXECUTE create_index;
234
      --error 0,ER_DUP_ENTRY
235
      EXECUTE insert_record;
236
      if (!$mysql_errno)
237
      {
238
         --echo # Error: INSERT was successful though we expected ER_DUP_ENTRY
239
         --echo # abort
240
         exit;
241
      }
242
      connection con2;
243
      EXECUTE drop_index;
244
      connection default;
245
      EXECUTE insert_record;
246
      connection con2;
247
      --error 0,ER_DUP_ENTRY
248
      EXECUTE create_index;
249
      if (!$mysql_errno)
250
      {
251
         --echo # Error: CREATE INDEX was successful though we expected ER_DUP_ENTRY
252
         --echo # abort
253
         exit;
254
      }
255
      EXECUTE delete_record;
256
      connection default;
257
      dec $loop_run;
258
   }
259
   if (`EXECUTE stmt_break`)
260
   {
261
      let $run= 0;
262
   }
263
}
264
DEALLOCATE PREPARE create_index;
265
DEALLOCATE PREPARE insert_record;
266
connection con2;
267
DEALLOCATE PREPARE create_index;
268
DEALLOCATE PREPARE drop_index;
269
DEALLOCATE PREPARE delete_record;
270
connection default;
271
--enable_result_log
272
--enable_query_log
273
274
DROP TABLE t1;