0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2024-12-16 12:38:46 +00:00
ad hoc ad79ef48a2
libsql wal tests (#1408)
* add tests

* add bench
2024-05-24 13:59:17 +00:00

79 lines
1.6 KiB
Plaintext

CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<500 )
INSERT INTO t1(b) SELECT char((i % 26) + 65) FROM s;
INSERT INTO t2 SELECT * FROM t1;
UPDATE t1 SET b = repeat(b, 100)
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<$nrow )
INSERT INTO t1(a, b) SELECT i+1, char((i % 26) + 65) FROM s;
UPDATE t1 SET b = repeat(b, 100)
SELECT * FROM t1;
CREATE TABLE t3(a PRIMARY KEY, b, c);
CREATE INDEX t3i ON t3(b);
UPDATE t3 SET c=1 WHERE b=?
UPDATE t3 SET c=1 WHERE rowid=?
CREATE TABLE t4(a PRIMARY KEY, b, c) WITHOUT ROWID;
CREATE INDEX t4c ON t4(c);
INSERT INTO t4 VALUES(1, 2, 3);
INSERT INTO t4 VALUES(2, 3, 4);
UPDATE t4 SET c=c+2 WHERE c>2;
SELECT a, c FROM t4 ORDER BY a;
CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c);
CREATE INDEX x1c ON x1(b, c);
INSERT INTO x1 VALUES(1, 'a', 1);
INSERT INTO x1 VALUES(2, 'a', 2);
INSERT INTO x1 VALUES(3, 'a', 3);
UPDATE x1 SET c=c+1 WHERE b='a';
SELECT * FROM x1;
CREATE TABLE d1(a,b);
CREATE INDEX d1b ON d1(a);
CREATE INDEX d1c ON d1(b);
INSERT INTO d1 VALUES(1,2);
UPDATE d1 SET a = a+2 WHERE a>0 OR b>0;
SELECT * FROM d1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(x,y);
CREATE UNIQUE INDEX t1x1 ON t1(x) WHERE x IS NOT NULL;
INSERT INTO t1(x) VALUES(NULL),(NULL);
CREATE INDEX t1x2 ON t1(y);
SELECT quote(x), quote(y), '|' FROM t1;
UPDATE OR REPLACE t1 SET x=1;
SELECT quote(x), quote(y), '|' FROM t1;