~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/t/ndb_dd_sql_features.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################
 
2
# Author: Nikolay
 
3
# Date: 2006-04-01
 
4
# Purpose: Specific Blob and Varchar testing using disk tables.
 
5
##############################################################
 
6
#    Create Stored procedures that use disk based tables.
 
7
#    Create function that operate on disk based tables.
 
8
#    Create triggers that operate on disk based tables.
 
9
#    Create views that operate on disk based tables.
 
10
#    Try to create FK constraints on disk based tables.
 
11
#    Create and use disk based table that use auto inc.
 
12
#    Create test that use transaction (commit, rollback)
 
13
#    Create large disk base table, do random queries, check cache hits, 
 
14
#    do same query 10 times check cache hits.
 
15
#    Create test that uses COUNT(), SUM(), MAX(), MIN(), 
 
16
#    NOW(), USER(), ... other built in #    SQL functions
 
17
#    Create test that uses locks.
 
18
#    Create test using truncate.
 
19
##############################################################
 
20
# Author: Jonathan
 
21
# Date: 2006-08-28
 
22
# Change: Remove all the create and drop LFG and TS except
 
23
#         The first create and the last drop to make test 
 
24
#         run faster. 
 
25
#         In addition, renamed test to be to a name that 
 
26
#         gives a better idea of what the test is about
 
27
########################################################### 
 
28
-- source include/have_ndb.inc
 
29
 
 
30
--disable_warnings
 
31
DROP TABLE IF EXISTS test.t1;
 
32
DROP TABLE IF EXISTS test.t2;
 
33
DROP TABLE IF EXISTS test.t3;
 
34
--enable_warnings
 
35
 
 
36
#### Copy data from table in one table space to table in ###
 
37
#### different table space. ####
 
38
--echo *****
 
39
--echo **** Copy data from table in one table space to table 
 
40
--echo **** in different table space
 
41
--echo *****
 
42
 
 
43
 CREATE LOGFILE GROUP lg
 
44
 ADD UNDOFILE './lg_group/undofile.dat'
 
45
 INITIAL_SIZE 16M
 
46
 UNDO_BUFFER_SIZE = 1M
 
47
 ENGINE=NDB;
 
48
 
 
49
 CREATE TABLESPACE ts1
 
50
 ADD DATAFILE './table_space1/datafile.dat'
 
51
 USE LOGFILE GROUP lg
 
52
 INITIAL_SIZE 25M
 
53
 ENGINE NDB;
 
54
 
 
55
 CREATE TABLESPACE ts2
 
56
 ADD DATAFILE './table_space2/datafile.dat'
 
57
 USE LOGFILE GROUP lg
 
58
 INITIAL_SIZE 20M
 
59
 ENGINE NDB;
 
60
 
 
61
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) 
 
62
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
63
 CREATE TABLE test.t2 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) 
 
64
 TABLESPACE ts2 STORAGE DISK  ENGINE=NDB;
 
65
 
 
66
 SHOW CREATE TABLE test.t1;
 
67
 SHOW CREATE TABLE test.t2;
 
68
 
 
69
 INSERT INTO test.t1 VALUES (1,'111111','aaaaaaaa');
 
70
 INSERT INTO test.t1 VALUES (2,'222222','bbbbbbbb');
 
71
 SELECT * FROM test.t1 ORDER BY a1;
 
72
 INSERT INTO test.t2(a1,a2,a3) SELECT * FROM test.t1;  
 
73
 SELECT * FROM test.t2 ORDER BY a1;
 
74
 
 
75
 DROP TABLE test.t1, test.t2;
 
76
 
 
77
 # populate BLOB field with large data
 
78
 
 
79
set @vc1 = repeat('a', 200);
 
80
set @vc2 = repeat('b', 500);
 
81
set @vc3 = repeat('c', 1000);
 
82
set @vc4 = repeat('d', 4000);
 
83
 
 
84
# x0 size 256
 
85
set @x0 = '01234567012345670123456701234567';
 
86
set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0);
 
87
 
 
88
# b1 length 2000+256
 
89
set @b1 = 'b1';
 
90
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
 
91
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
 
92
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
 
93
set @b1 = concat(@b1,@x0);
 
94
# d1 length 3000
 
95
set @d1 = 'dd1';
 
96
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
 
97
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
 
98
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
 
99
 
 
100
# b2 length 20000
 
101
set @b2 = 'b2';
 
102
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
103
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
104
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
105
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
106
# d2 length 30000
 
107
set @d2 = 'dd2';
 
108
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
109
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
110
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
111
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
112
 
 
113
select length(@x0),length(@b1),length(@d1) from dual;
 
114
select length(@x0),length(@b2),length(@d2) from dual;
 
115
 
 
116
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) 
 
117
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
118
 CREATE TABLE test.t2 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) 
 
119
 TABLESPACE ts2 STORAGE DISK  ENGINE=NDB;
 
120
 
 
121
 SHOW CREATE TABLE test.t1;
 
122
 SHOW CREATE TABLE test.t2;
 
123
 
 
124
 INSERT INTO test.t1 VALUES (1,@vc1,@d1);
 
125
 INSERT INTO test.t1 VALUES (2,@vc2,@b1);
 
126
 INSERT INTO test.t1 VALUES (3,@vc3,@d2);
 
127
 INSERT INTO test.t1 VALUES (4,@vc4,@b2);
 
128
 
 
129
 SELECT a1,length(a2),substr(a2,180,2),length(a3),substr(a3,1+3*900,3)
 
130
 FROM test.t1 WHERE a1=1;
 
131
 SELECT a1,length(a2),substr(a2,480,2),length(a3),substr(a3,1+2*900,3)
 
132
 FROM test.t1 where a1=2;
 
133
 
 
134
 INSERT INTO test.t2(a1,a2,a3) SELECT * FROM test.t1;  
 
135
 SELECT a1,length(a2),substr(a2,180,2),length(a3),substr(a3,1+3*900,3)
 
136
 FROM test.t2 WHERE a1=1;
 
137
 SELECT a1,length(a2),substr(a2,480,2),length(a3),substr(a3,1+2*900,3)
 
138
 FROM test.t2 where a1=2;
 
139
 
 
140
 
 
141
 DROP TABLE test.t1, test.t2;
 
142
 
 
143
#### Insert, Update, Delete from NDB table with BLOB fields ####
 
144
--echo *****
 
145
--echo **** Insert, Update, Delete from NDB table with BLOB fields
 
146
--echo *****
 
147
 
 
148
set @vc1 = repeat('a', 200);
 
149
set @vc2 = repeat('b', 500);
 
150
set @vc3 = repeat('c', 1000);
 
151
set @vc4 = repeat('d', 4000);
 
152
set @vc5 = repeat('d', 5000);
 
153
 
 
154
set @bb1 = repeat('1', 2000);
 
155
set @bb2 = repeat('2', 5000);
 
156
set @bb3 = repeat('3', 10000);
 
157
set @bb4 = repeat('4', 40000);
 
158
set @bb5 = repeat('5', 50000);
 
159
 
 
160
select length(@vc1),length(@vc2),length(@vc3),length(@vc4),length(@vc5) 
 
161
from dual;
 
162
select length(@bb1),length(@bb2),length(@bb3),length(@bb4),length(@bb5) 
 
163
from dual;
 
164
 
 
165
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) 
 
166
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
167
# CREATE TABLE test.t2 (a1 int NOT NULL, a2 VARCHAR(5000), a3 BLOB) 
 
168
# TABLESPACE ts2 STORAGE DISK  ENGINE=NDB;
 
169
 
 
170
 INSERT INTO test.t1 VALUES (1,@vc1,@bb1);
 
171
 INSERT INTO test.t1 VALUES (2,@vc2,@bb2);
 
172
 INSERT INTO test.t1 VALUES (3,@vc3,@bb3);
 
173
 INSERT INTO test.t1 VALUES (4,@vc4,@bb4);
 
174
 INSERT INTO test.t1 VALUES (5,@vc5,@bb5);
 
175
 
 
176
 UPDATE test.t1 SET a2=@vc5, a3=@bb5 WHERE a1=1;
 
177
 SELECT a1,length(a2),substr(a2,4998,2),length(a3),substr(a3,49997,3)
 
178
 FROM test.t1 WHERE a1=1;
 
179
 
 
180
 UPDATE test.t1 SET a2=@vc4, a3=@bb4 WHERE a1=2;
 
181
 SELECT a1,length(a2),substr(a2,3998,2),length(a3),substr(a3,39997,3)
 
182
 FROM test.t1 WHERE a1=2;
 
183
 
 
184
 UPDATE test.t1 SET a2=@vc2, a3=@bb2 WHERE a1=3;
 
185
 SELECT a1,length(a2),substr(a2,498,2),length(a3),substr(a3,3997,3)
 
186
 FROM test.t1 WHERE a1=3;
 
187
 
 
188
 UPDATE test.t1 SET a2=@vc3, a3=@bb3 WHERE a1=4;
 
189
 SELECT a1,length(a2),substr(a2,998,2),length(a3),substr(a3,9997,3)
 
190
 FROM test.t1 WHERE a1=4;
 
191
 
 
192
 UPDATE test.t1 SET a2=@vc1, a3=@bb1 WHERE a1=5;
 
193
 SELECT a1,length(a2),substr(a2,198,2),length(a3),substr(a3,1997,3)
 
194
 FROM test.t1 WHERE a1=5;
 
195
 
 
196
 DELETE FROM test.t1 where a1=5;
 
197
 SELECT count(*) from test.t1; 
 
198
 DELETE FROM test.t1 where a1=4;
 
199
 SELECT count(*) from test.t1; 
 
200
 DELETE FROM test.t1 where a1=3;
 
201
 SELECT count(*) from test.t1; 
 
202
 DELETE FROM test.t1 where a1=2;
 
203
 SELECT count(*) from test.t1; 
 
204
 DELETE FROM test.t1 where a1=1;
 
205
 SELECT count(*) from test.t1; 
 
206
 
 
207
 DROP TABLE test.t1;
 
208
 
 
209
##### Create Stored procedures that use disk based tables #####
 
210
--echo *****
 
211
--echo **** Create Stored procedures that use disk based tables
 
212
--echo *****
 
213
 
 
214
delimiter //;
 
215
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB)
 
216
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB//
 
217
 CREATE PROCEDURE test.sp1()
 
218
 BEGIN
 
219
 INSERT INTO test.t1 values (1,'111111','aaaaaaaa');
 
220
 END//
 
221
delimiter ;//
 
222
 
 
223
 CALL test.sp1();
 
224
 SELECT * FROM test.t1;
 
225
 
 
226
delimiter //;
 
227
 CREATE PROCEDURE test.sp2(n INT, vc VARCHAR(256), blb BLOB)
 
228
 BEGIN
 
229
 UPDATE test.t1 SET a2=vc, a3=blb where a1=n;
 
230
 END//
 
231
delimiter ;//
 
232
 
 
233
 CALL test.sp2(1,'222222','bbbbbbbb');
 
234
 SELECT * FROM test.t1;
 
235
 
 
236
 DELETE FROM test.t1;
 
237
 DROP PROCEDURE test.sp1;
 
238
 DROP PROCEDURE test.sp2;
 
239
 DROP TABLE test.t1;
 
240
 
 
241
 
 
242
#### Create function that operate on disk based tables ####
 
243
--echo *****
 
244
--echo ***** Create function that operate on disk based tables
 
245
--echo *****
 
246
 
 
247
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB)
 
248
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
249
 let $1=100;
 
250
 disable_query_log;
 
251
 while ($1)
 
252
 {
 
253
  eval insert into test.t1 values($1, "aaaaa$1", "bbbbb$1");
 
254
  dec $1;
 
255
 }
 
256
 enable_query_log;
 
257
 
 
258
 delimiter //;
 
259
 CREATE FUNCTION test.fn1(n INT) RETURNS INT
 
260
 BEGIN
 
261
 DECLARE v INT;
 
262
 SELECT a1 INTO v FROM test.t1 WHERE a1=n;
 
263
 RETURN v;
 
264
 END//
 
265
 delimiter ;//
 
266
 
 
267
delimiter //;
 
268
 CREATE FUNCTION test.fn2(n INT, blb BLOB) RETURNS BLOB
 
269
 BEGIN
 
270
 DECLARE vv BLOB;
 
271
 UPDATE test.t1 SET a3=blb where a1=n;
 
272
 SELECT a3 INTO vv FROM test.t1 WHERE a1=n;
 
273
 RETURN vv;
 
274
 END//
 
275
 delimiter ;//
 
276
 
 
277
 SELECT test.fn1(10) FROM DUAL;
 
278
 SELECT test.fn2(50, 'new BLOB content') FROM DUAL;
 
279
 
 
280
 DELETE FROM test.t1;
 
281
 DROP FUNCTION test.fn1;
 
282
 DROP FUNCTION test.fn2;
 
283
 DROP TABLE test.t1;
 
284
 
 
285
#### Create triggers that operate on disk based tables ####
 
286
--echo *****
 
287
--echo ***** Create triggers that operate on disk based tables
 
288
--echo *****
 
289
 
 
290
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB)
 
291
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
292
 
 
293
 delimiter //;
 
294
 CREATE TRIGGER test.trg1 BEFORE INSERT ON test.t1 FOR EACH ROW 
 
295
 BEGIN 
 
296
  if isnull(new.a2) then
 
297
    set new.a2:= 'trg1 works on a2 field';
 
298
  end if;
 
299
  if isnull(new.a3) then
 
300
    set new.a3:= 'trg1 works on a3 field';
 
301
  end if;
 
302
 end//
 
303
 insert into test.t1 (a1) values (1)//
 
304
 insert into test.t1 (a1,a2) values (2, 'ccccccc')//
 
305
 select * from test.t1 order by a1//
 
306
 delimiter ;//
 
307
 
 
308
 DELETE FROM test.t1;
 
309
 DROP TRIGGER test.trg1;
 
310
 DROP TABLE test.t1;
 
311
 
 
312
#### Create, update views that operate on disk based tables ####
 
313
--echo *****
 
314
--echo ***** Create, update views that operate on disk based tables
 
315
--echo *****
 
316
 
 
317
 
 
318
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB)
 
319
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
320
 let $1=10;
 
321
 disable_query_log;
 
322
 while ($1)
 
323
 {
 
324
  eval insert into test.t1 values($1, "aaaaa$1", "bbbbb$1");
 
325
  dec $1;
 
326
 }
 
327
 enable_query_log; 
 
328
 CREATE VIEW test.v1 AS SELECT * FROM test.t1;
 
329
 SELECT * FROM test.v1 order by a1;
 
330
 CHECK TABLE test.v1, test.t1;
 
331
 
 
332
 UPDATE test.v1 SET a2='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' WHERE a1=5;
 
333
 SELECT * FROM test.v1 order by a1;
 
334
 
 
335
 DROP VIEW test.v1;
 
336
 DELETE FROM test.t1;
 
337
 DROP TABLE test.t1;
 
338
 
 
339
#### Create and use disk based table that use auto inc ####
 
340
--echo *****
 
341
--echo ***** Create and use disk based table that use auto inc
 
342
--echo *****
 
343
 
 
344
 CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 
345
                       a2 VARCHAR(256), a3 BLOB) 
 
346
                       TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
347
 let $1=10;
 
348
 disable_query_log;
 
349
 while ($1)
 
350
 {
 
351
  eval insert into test.t1 values(NULL, "aaaaa$1", "bbbbb$1");
 
352
  dec $1;
 
353
 }
 
354
 enable_query_log; 
 
355
 SELECT * FROM test.t1 ORDER BY a1;
 
356
 DELETE FROM test.t1;
 
357
 DROP TABLE test.t1;
 
358
 
 
359
 
 
360
#### Create test that use transaction (commit, rollback) ####
 
361
--echo *****
 
362
--echo ***** Create test that use transaction (commit, rollback)
 
363
--echo *****
 
364
 
 
365
 SET AUTOCOMMIT=0;
 
366
 CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 
367
                       a2 VARCHAR(256), a3 BLOB) 
 
368
                       TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
369
 
 
370
 INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1");
 
371
 COMMIT; 
 
372
 SELECT * FROM test.t1 ORDER BY a1;
 
373
 INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2");
 
374
 ROLLBACK; 
 
375
 SELECT * FROM test.t1 ORDER BY a1;
 
376
 
 
377
 DELETE FROM test.t1;
 
378
 DROP TABLE test.t1;
 
379
 SET AUTOCOMMIT=1;
 
380
 
 
381
# Now do the same thing with START TRANSACTION without using AUTOCOMMIT.
 
382
 
 
383
 CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 
384
                       a2 VARCHAR(256), a3 BLOB) 
 
385
                       TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
386
 
 
387
 START TRANSACTION;
 
388
 INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1");
 
389
 COMMIT;
 
390
 SELECT * FROM test.t1 ORDER BY a1;
 
391
 
 
392
 START TRANSACTION;
 
393
 INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2");
 
394
 ROLLBACK; 
 
395
 SELECT * FROM test.t1 ORDER BY a1;
 
396
 
 
397
 DELETE FROM test.t1;
 
398
 DROP TABLE test.t1;
 
399
 
 
400
#### Create test that uses locks ####
 
401
--echo *****
 
402
--echo ***** Create test that uses locks
 
403
--echo *****
 
404
 
 
405
 connect (con1,localhost,root,,);
 
406
 connect (con2,localhost,root,,);
 
407
 
 
408
# connection con1;
 
409
--disable_warnings
 
410
 drop table if exists test.t1;
 
411
 CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 
412
                       a2 VARCHAR(256), a3 BLOB) 
 
413
                       TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
414
--enable_warnings
 
415
 
 
416
 LOCK TABLES test.t1 write;
 
417
 INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1");
 
418
 INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2");
 
419
 SELECT * FROM test.t1 ORDER BY a1;
 
420
 
 
421
 connection con2;
 
422
 SELECT * FROM test.t1 ORDER BY a1;
 
423
 INSERT INTO test.t1 VALUES(NULL, "aaaaa3", "bbbbb3");  
 
424
 
 
425
 connection con1;
 
426
 UNLOCK TABLES;
 
427
 
 
428
 connection con2;
 
429
 INSERT INTO test.t1 VALUES(NULL, "aaaaa3", "bbbbb3"); 
 
430
 SELECT * FROM test.t1 ORDER BY a1;
 
431
 DELETE FROM test.t1;
 
432
 DROP TABLE test.t1;
 
433
 
 
434
 #connection defualt;
 
435
 
 
436
#### Create large disk base table, do random queries, check cache hits ####
 
437
--echo *****
 
438
--echo ***** Create large disk base table, do random queries, check cache hits
 
439
--echo *****
 
440
 
 
441
set @vc1 = repeat('a', 200);
 
442
SELECT @vc1 FROM DUAL; 
 
443
set @vc2 = repeat('b', 500);
 
444
set @vc3 = repeat('b', 998);
 
445
 
 
446
# x0 size 256
 
447
set @x0 = '01234567012345670123456701234567';
 
448
set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0);
 
449
 
 
450
# b1 length 2000+256 (blob part aligned)
 
451
set @b1 = 'b1';
 
452
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
 
453
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
 
454
set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
 
455
set @b1 = concat(@b1,@x0);
 
456
# d1 length 3000
 
457
set @d1 = 'dd1';
 
458
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
 
459
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
 
460
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
 
461
 
 
462
# b2 length 20000
 
463
set @b2 = 'b2';
 
464
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
465
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
466
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
467
set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
 
468
# d2 length 30000
 
469
set @d2 = 'dd2';
 
470
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
471
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
472
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
473
set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
 
474
 
 
475
select length(@x0),length(@b1),length(@d1) from dual;
 
476
select length(@x0),length(@b2),length(@d2) from dual;
 
477
 
 
478
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(1000), a3 BLOB)
 
479
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
480
 
 
481
 INSERT INTO test.t1 values(1,@vc1,@d1);
 
482
 INSERT INTO test.t1 values(2,@vc2,@d2);
 
483
 --replace_column 9 #
 
484
 explain SELECT * from test.t1 WHERE a1 = 1;
 
485
 
 
486
 SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3)
 
487
 FROM test.t1 WHERE a1=1 ORDER BY a1;
 
488
 SELECT a1,length(a2),substr(a2,1+2*9000,2),length(a3),substr(a3,1+3*9000,3)
 
489
 FROM test.t1 where a1=2 ORDER BY a1;
 
490
 
 
491
 UPDATE test.t1 set a2=@vc2,a3=@d2 where a1=1;
 
492
 UPDATE test.t1 set a2=@vc1,a3=@d1 where a1=2;
 
493
 
 
494
 SELECT a1,length(a2),substr(a2,1+2*9000,2),length(a3),substr(a3,1+3*9000,3)
 
495
 FROM test.t1 where a1=1;
 
496
 SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3)
 
497
 FROM test.t1 where a1=2;
 
498
 
 
499
 #SHOW VARIABLES LIKE 'have_query_cache';
 
500
 #SHOW STATUS LIKE 'Qcache%';
 
501
 
 
502
 DELETE FROM test.t1;
 
503
 DROP TABLE test.t1;
 
504
 
 
505
#### Create test that uses COUNT(), SUM(), MAX(), ####
 
506
##### MIN(), NOW(), USER(), TRUNCATE ####
 
507
--echo *****
 
508
--echo ***** Create test that uses COUNT(), SUM(), MAX(), MIN(), NOW(), 
 
509
--echo ***** USER(), TRUNCATE
 
510
--echo *****
 
511
 
 
512
 CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256),
 
513
                       a3 BLOB, a4 DATE, a5 CHAR(250))
 
514
 TABLESPACE ts1 STORAGE DISK  ENGINE=NDB;
 
515
 let $1=100;
 
516
 disable_query_log;
 
517
 while ($1)
 
518
 {
 
519
  eval insert into test.t1 values($1, "aaaaaaaaaaaaaaaa$1", 
 
520
            "bbbbbbbbbbbbbbbbbb$1", '2006-06-20' , USER());
 
521
  dec $1;
 
522
 }
 
523
 enable_query_log;
 
524
 
 
525
 SELECT COUNT(*) from test.t1;
 
526
 SELECT SUM(a1) from test.t1;
 
527
 SELECT MIN(a1) from test.t1;
 
528
 SELECT MAX(a1) from test.t1;
 
529
 SELECT a5 from test.t1 where a1=50;
 
530
 
 
531
 
 
532
 SELECT * from test.t1 order by a1;
 
533
 
 
534
 DROP TABLE test.t1;
 
535
 
 
536
 ALTER TABLESPACE ts1
 
537
 DROP DATAFILE './table_space1/datafile.dat'
 
538
 ENGINE=NDB;
 
539
 DROP TABLESPACE ts1 ENGINE=NDB;
 
540
 
 
541
 ALTER TABLESPACE ts2
 
542
 DROP DATAFILE './table_space2/datafile.dat'
 
543
 ENGINE=NDB;
 
544
 DROP TABLESPACE ts2 ENGINE=NDB;
 
545
 
 
546
 DROP LOGFILE GROUP lg
 
547
 ENGINE=NDB;
 
548
 
 
549
 
 
550
#End 5.1 test case
 
551