~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/parts/t/partition_sessions.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#--------------------------------------------------
 
3
# Initialize system_3 test variables 
 
4
#--------------------------------------------------
 
5
 
 
6
--source suite/system_3/include/system_3_init.inc
 
7
 
 
8
let $NUM_VAL=`SELECT @NUM_VAL`;
 
9
let $LOAD_LINES=`SELECT @LOAD_LINES`;
 
10
let $LOG_UPPER=`SELECT @LOG_UPPER`;
 
11
let $LOG_LOWER=`SELECT @LOG_LOWER`;
 
12
#let $ENG1=`SELECT @ENG1`;
 
13
let $ENG2=`SELECT @ENG2`;
 
14
let $ENG_LOG=`SELECT @ENG_LOG`;
 
15
let $CLIENT_HOST=`SELECT @CLIENT_HOST`;
 
16
let $ENG=innodb;
 
17
let $ENG1=innodb;
 
18
#---------------------------------------------------------
 
19
# Column list with definition for all tables to be checked
 
20
#---------------------------------------------------------
 
21
 
 
22
let $column_list= f1 int,
 
23
f2 char (15),
 
24
f3 decimal (5,3),
 
25
f4 datetime;
 
26
 
 
27
let $col_access_list = f1,f2,f3,f4 ;
 
28
let $col_new_list    = new.f1,new.f2,new.f3 new.f4 ;
 
29
 
 
30
#---------------------------------------------------
 
31
# Setting the parameters to use during testing
 
32
#---------------------------------------------------
 
33
# Set number of variations of the f1 variable (used to segment the rows
 
34
# being updated/deleted by a user at a time. The higher the number, the
 
35
# more smaller segments used with each query.
 
36
--replace_result $NUM_VAL NUM_VAL
 
37
eval set @f1_nums=$NUM_VAL;
 
38
 
 
39
# The following sets the number controls the size of the log table.
 
40
# Once a size of '@threshold' is reached, the first rows are removed
 
41
# sunch that the table is down to '@shrink_to' lines
 
42
--replace_result $LOG_LOWER LOG_LOWER
 
43
eval set @shrink_to=$LOG_LOWER;
 
44
--replace_result $LOG_UPPER LOG_UPPER
 
45
eval set @threshold=$LOG_UPPER;
 
46
 
 
47
#---------------------------------------------------
 
48
# Creating the database tables and loading the data
 
49
#---------------------------------------------------
 
50
 
 
51
--disable_warnings
 
52
drop database if exists systest1;
 
53
--enable_warnings
 
54
 
 
55
create database systest1;
 
56
 
 
57
--disable_abort_on_error
 
58
--replace_result $CLIENT_HOST CLIENT_HOST
 
59
eval create user systuser@'$CLIENT_HOST';
 
60
--enable_abort_on_error
 
61
--replace_result $CLIENT_HOST CLIENT_HOST
 
62
eval set password for systuser@'$CLIENT_HOST' = password('systpass');
 
63
--replace_result $CLIENT_HOST CLIENT_HOST
 
64
eval grant ALL on systest1.* to systuser@'$CLIENT_HOST';
 
65
use systest1;
 
66
--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK
 
67
connect (systuser,localhost,systuser,systpass,systest1,$MASTER_MYPORT,$MASTER_MYSOCK);
 
68
 
 
69
create table tb1_master (
 
70
   f1 int,
 
71
   f2 char(15),
 
72
   f3 decimal (5,3),
 
73
   f4 datetime
 
74
);
 
75
 
 
76
#--replace_result $ENG_LOG ENG_LOG
 
77
eval create table tb1_logs (
 
78
   i1 int NOT NULL auto_increment, primary key (i1),
 
79
   dt1 datetime NOT NULL,
 
80
   entry_dsc char(100),
 
81
   f4 int
 
82
) engine=$ENG_LOG
 
83
;
 
84
#PARTITION BY HASH (i1) PARTITIONS 8;
 
85
 
 
86
if ($debug)
 
87
{
 
88
SHOW CREATE TABLE tb1_logs;
 
89
}
 
90
 
 
91
#--replace_result $ENG_LOG ENG_LOG
 
92
eval create table ddl_logs (
 
93
   i1 int NOT NULL auto_increment, primary key (i1),
 
94
   dt1 datetime NOT NULL,
 
95
   entry_dsc char(100),
 
96
   errno int
 
97
) engine=$ENG_LOG;
 
98
#PARTITION BY HASH (i1) PARTITIONS 8;
 
99
 
 
100
if ($debug)
 
101
{
 
102
SHOW CREATE TABLE tb1_logs;
 
103
}
 
104
create table test_stat (
 
105
   dt1 datetime,
 
106
   table_name char(20),
 
107
   row_count int,
 
108
   start_row int,
 
109
   end_row int
 
110
);
 
111
 
 
112
#----------------------------------------------------------------------
 
113
# tb3_eng1: key partitioning
 
114
#----------------------------------------------------------------------
 
115
 
 
116
#--replace_result $ENG1 ENG1
 
117
eval create table tb3_eng1 (
 
118
   i1 int NOT NULL auto_increment, primary key (i1),
 
119
   $column_list
 
120
) engine=$ENG1
 
121
PARTITION BY KEY (i1) PARTITIONS 4
 
122
(PARTITION part1,
 
123
PARTITION part2,
 
124
PARTITION part3,
 
125
PARTITION part4);
 
126
 
 
127
#--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
 
128
eval load data local infile '$MYSQL_TEST_DIR/suite/system_3/data/tb1.txt'
 
129
     into table tb3_eng1 ($col_access_list);
 
130
 
 
131
if ($WITH_TRIGGERS)
 
132
{
 
133
delimiter //;
 
134
 
 
135
Create trigger tb3_eng1_ins after insert on tb3_eng1 for each row
 
136
BEGIN
 
137
   insert into tb1_logs (dt1, entry_dsc, f4)
 
138
   values (now(), concat('Insert row ', new.f1,' ',
 
139
           new.f2, ' ', new.f3, ' (tb3_eng1)'), new.f1);
 
140
END//
 
141
 
 
142
Create trigger tb3_eng1_upd after update on tb3_eng1 for each row
 
143
BEGIN
 
144
   insert into tb1_logs (dt1, entry_dsc, f4)
 
145
   values (now(), concat('Update row ', old.f1,' ', old.f2, '->',
 
146
           new.f2, ' ', old.f3, '->', new.f3, ' (tb3_eng1)'), new.f1);
 
147
END//
 
148
 
 
149
Create trigger tb3_eng1_del after delete on tb3_eng1 for each row
 
150
BEGIN
 
151
   insert into tb1_logs (dt1, entry_dsc, f4)
 
152
   values (now(), concat('Delete row ', old.f1,' ', old.f2, ' ',
 
153
           old.f3, ' (tb3_eng1)'), old.f1);
 
154
END//
 
155
 
 
156
delimiter ;//
 
157
}
 
158
delimiter //;
 
159
 
 
160
# This functions returns a random integer number 
 
161
# between zero and 'num'
 
162
#-----------------------------------------------
 
163
create function int_rand(num int) returns int
 
164
BEGIN
 
165
   return round(num*rand()+0.5); 
 
166
END//
 
167
 
 
168
# This function returns a string in the length 'len' of 
 
169
# random letters (ascii range of 65-122)
 
170
#------------------------------------------------------
 
171
create function str_rand (len int) returns char(12)
 
172
BEGIN
 
173
  declare tmp_letter char(1);
 
174
  declare tmp_word char(12);
 
175
  declare word_str char(12) default '';
 
176
  wl_loop: WHILE len DO
 
177
     set tmp_letter=char(round(57*rand()+65)); 
 
178
     set tmp_word=concat(word_str,tmp_letter);
 
179
     set word_str=tmp_word;
 
180
     set len=len-1;
 
181
  END WHILE wl_loop;
 
182
  return word_str;
 
183
END//
 
184
 
 
185
 
 
186
# This procedure scans 'tb1_master' table for rows where f1='num_pr'
 
187
# and for each row inserts a row in 'tb3_eng1'
 
188
#------------------------------------------------------------------
 
189
eval create procedure ins_tb3_eng1 (num_pr int, str_pr char(15))
 
190
BEGIN
 
191
  declare done int default 0;
 
192
  declare v3 decimal(5,3);
 
193
  declare cur1 cursor for 
 
194
     select f3 from tb1_master where f1=num_pr;
 
195
  declare continue handler for sqlstate '01000' set done = 1;
 
196
  declare continue handler for sqlstate '02000' set done = 1;
 
197
  open cur1;
 
198
  fetch cur1 into v3;
 
199
  wl_loop: WHILE NOT done DO
 
200
     insert into tb3_eng1 ($col_access_list) values
 
201
        (int_rand(@f1_nums), concat('I:',str_pr,'-',num_pr), v3, now());
 
202
     fetch cur1 into v3;
 
203
  END WHILE wl_loop;
 
204
  close cur1;
 
205
END//
 
206
 
 
207
 
 
208
# This procedure does selects from the 'tb1_logs' and inserts the 
 
209
# count into the table
 
210
#------------------------------------------------------------------
 
211
create procedure slct_tb1_logs ()
 
212
BEGIN
 
213
  declare done int default 0;
 
214
  declare v4 int;
 
215
  declare v_count int default 0;
 
216
  declare str_val char(15) default ELT(int_rand(3), 
 
217
     'Insert', 'Update', 'Delete');
 
218
  declare cur1 cursor for 
 
219
     select f4 from tb1_logs where entry_dsc like concat('%',str_val,'%'); 
 
220
  declare continue handler for sqlstate '01000' set done = 1;
 
221
  declare continue handler for sqlstate '02000' set done = 1;
 
222
  open cur1;
 
223
  fetch cur1 into v4;
 
224
  wl_loop: WHILE NOT done DO
 
225
     set v_count=v_count+1;
 
226
     fetch cur1 into v4;
 
227
  END WHILE wl_loop;
 
228
  close cur1;
 
229
  insert into tb1_logs (dt1, entry_dsc, f4)
 
230
     values (now(), concat('Number of \'', str_val, '\' rows is: ', 
 
231
             v_count, ' (tb1_log)'),0);
 
232
END//
 
233
 
 
234
delimiter ;//
 
235
 
 
236
--disable_abort_on_error
 
237
insert into systest1.tb3_eng1 values (NULL,50,'init_val',12.345,'2005-01-01 00:00:00');
 
238
insert into systest1.tb3_eng1 values (NULL,70,'init_val',12.345,'2005-01-01 00:00:00');
 
239
--enable_abort_on_error
 
240
 
 
241
connection default;0.
 
242
--disable_abort_on_error
 
243
--replace_result $CLIENT_HOST CLIENT_HOST
 
244
eval create user syst1user@'$CLIENT_HOST';
 
245
--enable_abort_on_error
 
246
--replace_result $CLIENT_HOST CLIENT_HOST
 
247
eval set password for syst1user@'$CLIENT_HOST' = password('systpass');
 
248
--replace_result $CLIENT_HOST CLIENT_HOST
 
249
eval grant ALL on systest1.* to syst1user@'$CLIENT_HOST';
 
250
use systest1;
 
251
--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK
 
252
connect (syst1user,localhost,syst1user,systpass,systest1,$MASTER_MYPORT,$MASTER_MYSOCK);
 
253
 
 
254
--source suite/system_3/include/system_3_init.inc
 
255
use systest1;
 
256
let $NUM_VAL=`SELECT @NUM_VAL`;
 
257
eval SET @f1_nums=$NUM_VAL;
 
258
SET @tmp_num=int_rand(@f1_nums);
 
259
SET @tmp_word=str_rand(4);
 
260
 
 
261
# DEBUG select @tmp_num, @tmp_word;
 
262
 
 
263
# Insert rows replacing the deleted rows using a strored procedure
 
264
# that reads the rows from a master table
 
265
CALL ins_tb3_eng1 (@tmp_num, @tmp_word);
 
266
 
 
267
connection syst1user;
 
268
--source suite/system_3/include/system_3_init.inc
 
269
use systest1;
 
270
let $NUM_VAL=`SELECT @NUM_VAL`;
 
271
eval SET @f1_nums=$NUM_VAL;
 
272
SET @tmp_num=int_rand(@f1_nums);
 
273
SET @tmp_word=str_rand(4);
 
274
 
 
275
# DEBUG select @tmp_num, @tmp_word;
 
276
 
 
277
# Insert rows replacing the deleted rows using a strored procedure
 
278
# that reads the rows from a master table
 
279
CALL ins_tb3_eng1 (@tmp_num, @tmp_word);
 
280
 
 
281
connection systuser;
 
282
--source suite/system_3/include/system_3_init.inc
 
283
use systest1;
 
284
call slct_tb1_logs();
 
285
 
 
286
connection syst1user;
 
287
--source suite/system_3/include/system_3_init.inc
 
288
use systest1;
 
289
let $NUM_VAL=`SELECT @NUM_VAL`;
 
290
eval set @f1_nums=$NUM_VAL;
 
291
set @tmp_num=int_rand(@f1_nums);
 
292
set @tmp_word=str_rand(4);
 
293
 
 
294
select @tmp_num, @tmp_word;
 
295
 
 
296
# Update all rows in the table where f1 is one less the random number
 
297
update tb3_eng1  
 
298
   set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 
 
299
   where f1=@tmp_num-1;
 
300
 
 
301
connection systuser;
 
302
--source suite/system_3/include/system_3_init.inc
 
303
use systest1;
 
304
let $NUM_VAL=`SELECT @NUM_VAL`;
 
305
eval set @f1_nums=$NUM_VAL;
 
306
set @tmp_num=int_rand(@f1_nums);
 
307
set @tmp_word=str_rand(4);
 
308
 
 
309
select @tmp_num, @tmp_word;
 
310
 
 
311
# Update all rows in the table where f1 is one less the random number
 
312
update tb3_eng1  
 
313
   set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 
 
314
   where f1=@tmp_num-1;
 
315
 
 
316
connection syst1user;
 
317
--source suite/system_3/include/system_3_init.inc
 
318
use systest1;
 
319
call slct_tb1_logs();
 
320
 
 
321
connection systuser;
 
322
--source suite/system_3/include/system_3_init.inc
 
323
use systest1;
 
324
let $NUM_VAL=`SELECT @NUM_VAL`;
 
325
eval set @f1_nums=$NUM_VAL;
 
326
set @tmp_num=int_rand(@f1_nums);
 
327
set @tmp_word=str_rand(4);
 
328
 
 
329
select @tmp_num, @tmp_word;
 
330
 
 
331
# Update all rows in the table where f1 is one less the random number
 
332
update tb3_eng1  
 
333
   set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1 
 
334
   where f1=@tmp_num-1;
 
335
 
 
336
 
 
337
connection syst1user;
 
338
--source suite/system_3/include/system_3_init.inc
 
339
use systest1;
 
340
#--replace_result $NUM_VAL <NUM_VAL>
 
341
let $NUM_VAL=`SELECT @NUM_VAL`;
 
342
eval set @f1_nums=$NUM_VAL;
 
343
set @tmp_num=int_rand(@f1_nums);
 
344
select @tmp_num;
 
345
 
 
346
# DEBUG select @tmp_num, @tmp_word;
 
347
 
 
348
# Delete all rows from the table where f1 is equal to the above number
 
349
delete from tb3_eng1 where f1=@tmp_num;
 
350
 
 
351
connection systuser;
 
352
--source suite/system_3/include/system_3_init.inc
 
353
use systest1;
 
354
select * from tb3_eng1 where f1>40;
 
355
 
 
356
 
 
357
connection syst1user;
 
358
--source suite/system_3/include/system_3_init.inc
 
359
use systest1;
 
360
let $NUM_VAL=`SELECT @NUM_VAL`;
 
361
eval set @f1_nums=$NUM_VAL;
 
362
set @tmp_num=int_rand(@f1_nums);
 
363
select @tmp_num;
 
364
 
 
365
# DEBUG select @tmp_num, @tmp_word;
 
366
 
 
367
# Delete all rows from the table where f1 is equal to the above number
 
368
delete from tb3_eng1 where f1=@tmp_num;
 
369
 
 
370
connection systuser;
 
371
--source suite/system_3/include/system_3_init.inc
 
372
use systest1;
 
373
select * from tb3_eng1 where f1>40;
 
374
 
 
375
connection syst1user;
 
376
--source suite/system_3/include/system_3_init.inc
 
377
use systest1;
 
378
let $NUM_VAL=`SELECT @NUM_VAL`;
 
379
eval set @f1_nums=$NUM_VAL;
 
380
set @tmp_num=int_rand(@f1_nums);
 
381
select @tmp_num;
 
382
 
 
383
select @tmp_num, @tmp_word;
 
384
 
 
385
# Delete all rows from the table where f1 is equal to the above number
 
386
delete from tb3_eng1 where f1=@tmp_num;
 
387
 
 
388
connection systuser;
 
389
--source suite/system_3/include/system_3_init.inc
 
390
use systest1;
 
391
select * from tb3_eng1 where f1>40;