142 lines
3.9 KiB
Plaintext
142 lines
3.9 KiB
Plaintext
|
/*
|
||
|
** This script sets up five different tasks all writing and updating
|
||
|
** the database at the same time, but each in its own table.
|
||
|
*/
|
||
|
--task 1
|
||
|
DROP TABLE IF EXISTS t1;
|
||
|
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||
|
--sleep 1
|
||
|
INSERT INTO t1 VALUES(1, randomblob(2000));
|
||
|
INSERT INTO t1 VALUES(2, randomblob(1000));
|
||
|
--sleep 1
|
||
|
INSERT INTO t1 SELECT a+2, randomblob(1500) FROM t1;
|
||
|
INSERT INTO t1 SELECT a+4, randomblob(1500) FROM t1;
|
||
|
INSERT INTO t1 SELECT a+8, randomblob(1500) FROM t1;
|
||
|
--sleep 1
|
||
|
INSERT INTO t1 SELECT a+16, randomblob(1500) FROM t1;
|
||
|
--sleep 1
|
||
|
INSERT INTO t1 SELECT a+32, randomblob(1500) FROM t1;
|
||
|
SELECT count(*) FROM t1;
|
||
|
--match 64
|
||
|
SELECT avg(length(b)) FROM t1;
|
||
|
--match 1500.0
|
||
|
--sleep 2
|
||
|
UPDATE t1 SET b='x'||a||'y';
|
||
|
SELECT total(length(b)) FROM t1;
|
||
|
--match 247
|
||
|
--end
|
||
|
|
||
|
|
||
|
--task 2
|
||
|
DROP TABLE IF EXISTS t2;
|
||
|
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
|
||
|
--sleep 1
|
||
|
INSERT INTO t2 VALUES(1, randomblob(2000));
|
||
|
INSERT INTO t2 VALUES(2, randomblob(1000));
|
||
|
--sleep 1
|
||
|
INSERT INTO t2 SELECT a+2, randomblob(1500) FROM t2;
|
||
|
INSERT INTO t2 SELECT a+4, randomblob(1500) FROM t2;
|
||
|
INSERT INTO t2 SELECT a+8, randomblob(1500) FROM t2;
|
||
|
--sleep 1
|
||
|
INSERT INTO t2 SELECT a+16, randomblob(1500) FROM t2;
|
||
|
--sleep 1
|
||
|
INSERT INTO t2 SELECT a+32, randomblob(1500) FROM t2;
|
||
|
SELECT count(*) FROM t2;
|
||
|
--match 64
|
||
|
SELECT avg(length(b)) FROM t2;
|
||
|
--match 1500.0
|
||
|
--sleep 2
|
||
|
UPDATE t2 SET b='x'||a||'y';
|
||
|
SELECT total(length(b)) FROM t2;
|
||
|
--match 247
|
||
|
--end
|
||
|
|
||
|
--task 3
|
||
|
DROP TABLE IF EXISTS t3;
|
||
|
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
|
||
|
--sleep 1
|
||
|
INSERT INTO t3 VALUES(1, randomblob(2000));
|
||
|
INSERT INTO t3 VALUES(2, randomblob(1000));
|
||
|
--sleep 1
|
||
|
INSERT INTO t3 SELECT a+2, randomblob(1500) FROM t3;
|
||
|
INSERT INTO t3 SELECT a+4, randomblob(1500) FROM t3;
|
||
|
INSERT INTO t3 SELECT a+8, randomblob(1500) FROM t3;
|
||
|
--sleep 1
|
||
|
INSERT INTO t3 SELECT a+16, randomblob(1500) FROM t3;
|
||
|
--sleep 1
|
||
|
INSERT INTO t3 SELECT a+32, randomblob(1500) FROM t3;
|
||
|
SELECT count(*) FROM t3;
|
||
|
--match 64
|
||
|
SELECT avg(length(b)) FROM t3;
|
||
|
--match 1500.0
|
||
|
--sleep 2
|
||
|
UPDATE t3 SET b='x'||a||'y';
|
||
|
SELECT total(length(b)) FROM t3;
|
||
|
--match 247
|
||
|
--end
|
||
|
|
||
|
--task 4
|
||
|
DROP TABLE IF EXISTS t4;
|
||
|
CREATE TABLE t4(a INTEGER PRIMARY KEY, b);
|
||
|
--sleep 1
|
||
|
INSERT INTO t4 VALUES(1, randomblob(2000));
|
||
|
INSERT INTO t4 VALUES(2, randomblob(1000));
|
||
|
--sleep 1
|
||
|
INSERT INTO t4 SELECT a+2, randomblob(1500) FROM t4;
|
||
|
INSERT INTO t4 SELECT a+4, randomblob(1500) FROM t4;
|
||
|
INSERT INTO t4 SELECT a+8, randomblob(1500) FROM t4;
|
||
|
--sleep 1
|
||
|
INSERT INTO t4 SELECT a+16, randomblob(1500) FROM t4;
|
||
|
--sleep 1
|
||
|
INSERT INTO t4 SELECT a+32, randomblob(1500) FROM t4;
|
||
|
SELECT count(*) FROM t4;
|
||
|
--match 64
|
||
|
SELECT avg(length(b)) FROM t4;
|
||
|
--match 1500.0
|
||
|
--sleep 2
|
||
|
UPDATE t4 SET b='x'||a||'y';
|
||
|
SELECT total(length(b)) FROM t4;
|
||
|
--match 247
|
||
|
--end
|
||
|
|
||
|
--task 5
|
||
|
DROP TABLE IF EXISTS t5;
|
||
|
CREATE TABLE t5(a INTEGER PRIMARY KEY, b);
|
||
|
--sleep 1
|
||
|
INSERT INTO t5 VALUES(1, randomblob(2000));
|
||
|
INSERT INTO t5 VALUES(2, randomblob(1000));
|
||
|
--sleep 1
|
||
|
INSERT INTO t5 SELECT a+2, randomblob(1500) FROM t5;
|
||
|
INSERT INTO t5 SELECT a+4, randomblob(1500) FROM t5;
|
||
|
INSERT INTO t5 SELECT a+8, randomblob(1500) FROM t5;
|
||
|
--sleep 1
|
||
|
INSERT INTO t5 SELECT a+16, randomblob(1500) FROM t5;
|
||
|
--sleep 1
|
||
|
INSERT INTO t5 SELECT a+32, randomblob(1500) FROM t5;
|
||
|
SELECT count(*) FROM t5;
|
||
|
--match 64
|
||
|
SELECT avg(length(b)) FROM t5;
|
||
|
--match 1500.0
|
||
|
--sleep 2
|
||
|
UPDATE t5 SET b='x'||a||'y';
|
||
|
SELECT total(length(b)) FROM t5;
|
||
|
--match 247
|
||
|
--end
|
||
|
|
||
|
--wait all
|
||
|
SELECT count(*), total(length(b)) FROM t1;
|
||
|
--match 64 247
|
||
|
SELECT count(*), total(length(b)) FROM t2;
|
||
|
--match 64 247
|
||
|
SELECT count(*), total(length(b)) FROM t3;
|
||
|
--match 64 247
|
||
|
SELECT count(*), total(length(b)) FROM t4;
|
||
|
--match 64 247
|
||
|
SELECT count(*), total(length(b)) FROM t5;
|
||
|
--match 64 247
|
||
|
DROP TABLE t1;
|
||
|
DROP TABLE t2;
|
||
|
DROP TABLE t3;
|
||
|
DROP TABLE t4;
|
||
|
DROP TABLE t5;
|