2
#--------------------------------------------------
3
# Initialize system_3 test variables
4
#--------------------------------------------------
6
--source suite/system_3/include/system_3_init.inc
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`;
18
#---------------------------------------------------------
19
# Column list with definition for all tables to be checked
20
#---------------------------------------------------------
22
let $column_list= f1 int,
27
let $col_access_list = f1,f2,f3,f4 ;
28
let $col_new_list = new.f1,new.f2,new.f3 new.f4 ;
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;
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;
47
#---------------------------------------------------
48
# Creating the database tables and loading the data
49
#---------------------------------------------------
52
drop database if exists systest1;
55
create database systest1;
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';
66
--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK
67
connect (systuser,localhost,systuser,systpass,systest1,$MASTER_MYPORT,$MASTER_MYSOCK);
69
create table tb1_master (
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,
84
#PARTITION BY HASH (i1) PARTITIONS 8;
88
SHOW CREATE TABLE tb1_logs;
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,
98
#PARTITION BY HASH (i1) PARTITIONS 8;
102
SHOW CREATE TABLE tb1_logs;
104
create table test_stat (
112
#----------------------------------------------------------------------
113
# tb3_eng1: key partitioning
114
#----------------------------------------------------------------------
116
#--replace_result $ENG1 ENG1
117
eval create table tb3_eng1 (
118
i1 int NOT NULL auto_increment, primary key (i1),
121
PARTITION BY KEY (i1) PARTITIONS 4
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);
135
Create trigger tb3_eng1_ins after insert on tb3_eng1 for each row
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);
142
Create trigger tb3_eng1_upd after update on tb3_eng1 for each row
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);
149
Create trigger tb3_eng1_del after delete on tb3_eng1 for each row
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);
160
# This functions returns a random integer number
161
# between zero and 'num'
162
#-----------------------------------------------
163
create function int_rand(num int) returns int
165
return round(num*rand()+0.5);
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)
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;
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))
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;
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());
208
# This procedure does selects from the 'tb1_logs' and inserts the
209
# count into the table
210
#------------------------------------------------------------------
211
create procedure slct_tb1_logs ()
213
declare done int default 0;
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;
224
wl_loop: WHILE NOT done DO
225
set v_count=v_count+1;
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);
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
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';
251
--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK
252
connect (syst1user,localhost,syst1user,systpass,systest1,$MASTER_MYPORT,$MASTER_MYSOCK);
254
--source suite/system_3/include/system_3_init.inc
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);
261
# DEBUG select @tmp_num, @tmp_word;
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);
267
connection syst1user;
268
--source suite/system_3/include/system_3_init.inc
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);
275
# DEBUG select @tmp_num, @tmp_word;
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);
282
--source suite/system_3/include/system_3_init.inc
284
call slct_tb1_logs();
286
connection syst1user;
287
--source suite/system_3/include/system_3_init.inc
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);
294
select @tmp_num, @tmp_word;
296
# Update all rows in the table where f1 is one less the random number
298
set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1
302
--source suite/system_3/include/system_3_init.inc
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);
309
select @tmp_num, @tmp_word;
311
# Update all rows in the table where f1 is one less the random number
313
set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1
316
connection syst1user;
317
--source suite/system_3/include/system_3_init.inc
319
call slct_tb1_logs();
322
--source suite/system_3/include/system_3_init.inc
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);
329
select @tmp_num, @tmp_word;
331
# Update all rows in the table where f1 is one less the random number
333
set f2=concat('U:',@tmp_word,'-',@tmp_num), f3=f3+1
337
connection syst1user;
338
--source suite/system_3/include/system_3_init.inc
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);
346
# DEBUG select @tmp_num, @tmp_word;
348
# Delete all rows from the table where f1 is equal to the above number
349
delete from tb3_eng1 where f1=@tmp_num;
352
--source suite/system_3/include/system_3_init.inc
354
select * from tb3_eng1 where f1>40;
357
connection syst1user;
358
--source suite/system_3/include/system_3_init.inc
360
let $NUM_VAL=`SELECT @NUM_VAL`;
361
eval set @f1_nums=$NUM_VAL;
362
set @tmp_num=int_rand(@f1_nums);
365
# DEBUG select @tmp_num, @tmp_word;
367
# Delete all rows from the table where f1 is equal to the above number
368
delete from tb3_eng1 where f1=@tmp_num;
371
--source suite/system_3/include/system_3_init.inc
373
select * from tb3_eng1 where f1>40;
375
connection syst1user;
376
--source suite/system_3/include/system_3_init.inc
378
let $NUM_VAL=`SELECT @NUM_VAL`;
379
eval set @f1_nums=$NUM_VAL;
380
set @tmp_num=int_rand(@f1_nums);
383
select @tmp_num, @tmp_word;
385
# Delete all rows from the table where f1 is equal to the above number
386
delete from tb3_eng1 where f1=@tmp_num;
389
--source suite/system_3/include/system_3_init.inc
391
select * from tb3_eng1 where f1>40;