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