2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library.
2N/A# This file implements tests for miscellanous features that were
2N/A# left out of other test files.
2N/Aset testdir [file dirname $argv0]
2N/A# Ticket #529. Make sure an ABORT does not damage the in-memory cache
2N/A# that will be used by subsequent statements in the same transaction.
2N/A CREATE TABLE t1(a UNIQUE,b);
2N/A VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A UPDATE t1 SET b=b||b;
2N/A INSERT INTO t1 VALUES(2,'x');
2N/A UPDATE t1 SET b=substr(b,1,500);
2N/A catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';}
2N/A CREATE TABLE t2(x,y);
2N/A PRAGMA integrity_check;
2N/A CREATE TABLE t1(a UNIQUE,b);
2N/A VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
2N/A INSERT INTO t1 SELECT a+1, b||b FROM t1;
2N/A INSERT INTO t1 SELECT a+2, b||b FROM t1;
2N/A INSERT INTO t1 SELECT a+4, b FROM t1;
2N/A INSERT INTO t1 SELECT a+8, b FROM t1;
2N/A INSERT INTO t1 SELECT a+16, b FROM t1;
2N/A INSERT INTO t1 SELECT a+32, b FROM t1;
2N/A INSERT INTO t1 SELECT a+64, b FROM t1;
2N/A catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';}
2N/A INSERT INTO t1 VALUES(200,'hello out there');
2N/A PRAGMA integrity_check;
2N/A# Tests of the sqliteAtoF() function in
util.c 2N/A execsql {SELECT 2e-25*0.5e25}
2N/A execsql {SELECT 2.0e-25*000000.500000000000000000000000000000e+00025}
2N/A execsql {SELECT 000000000002e-0000000025*0.5e25}
2N/A execsql {SELECT 2e-25*0.5e250}
2N/A execsql {SELECT 2.0e-250*0.5e25}
2N/A execsql {SELECT '-2.0e-127' * '-0.5e27'}
2N/A execsql {SELECT '+2.0e-127' * '-0.5e27'}
2N/A execsql {SELECT 2.0e-27 * '+0.5e+127'}
2N/A execsql {SELECT 2.0e-27 * '+0.000005e+132'}
2N/A# Ticket #522. Make sure integer overflow is handled properly in
2N/A execsql {PRAGMA integrity_check}
2N/A CREATE TABLE t2(a INT UNIQUE);
2N/A PRAGMA integrity_check;
2N/A INSERT INTO t2 VALUES(2147483648);
2N/A PRAGMA integrity_check;
2N/A INSERT INTO t2 VALUES(-2147483649);
2N/A PRAGMA integrity_check;
2N/A INSERT INTO t2 VALUES(+2147483649);
2N/A PRAGMA integrity_check;
2N/A INSERT INTO t2 VALUES(+2147483647);
2N/A INSERT INTO t2 VALUES(-2147483648);
2N/A INSERT INTO t2 VALUES(-2147483647);
2N/A INSERT INTO t2 VALUES(2147483646);
2N/A SELECT * FROM t2 ORDER BY a;
2N/A} {-2147483649 -2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
2N/A SELECT * FROM t2 WHERE a>=-2147483648 ORDER BY a;
2N/A} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
2N/A SELECT * FROM t2 WHERE a>-2147483648 ORDER BY a;
2N/A} {-2147483647 2147483646 2147483647 2147483648 2147483649}
2N/A SELECT * FROM t2 WHERE a>-2147483649 ORDER BY a;
2N/A} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
2N/A SELECT * FROM t2 WHERE a>=0 AND a<2147483649 ORDER BY a DESC;
2N/A} {2147483648 2147483647 2147483646}
2N/A SELECT * FROM t2 WHERE a>=0 AND a<=2147483648 ORDER BY a DESC;
2N/A} {2147483648 2147483647 2147483646}
2N/A SELECT * FROM t2 WHERE a>=0 AND a<2147483648 ORDER BY a DESC;
2N/A} {2147483647 2147483646}
2N/A SELECT * FROM t2 WHERE a>=0 AND a<=2147483647 ORDER BY a DESC;
2N/A} {2147483647 2147483646}
2N/A SELECT * FROM t2 WHERE a>=0 AND a<2147483647 ORDER BY a DESC;
2N/A# Ticket #565. A stack overflow is occurring when the subquery to the
2N/A# right of an IN operator contains many NULLs
2N/A CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
2N/A INSERT INTO t3(b) VALUES('abc');
2N/A INSERT INTO t3(b) VALUES('xyz');
2N/A INSERT INTO t3(b) VALUES(NULL);
2N/A INSERT INTO t3(b) VALUES(NULL);
2N/A INSERT INTO t3(b) SELECT b||'d' FROM t3;
2N/A INSERT INTO t3(b) SELECT b||'e' FROM t3;
2N/A INSERT INTO t3(b) SELECT b||'f' FROM t3;
2N/A INSERT INTO t3(b) SELECT b||'g' FROM t3;
2N/A INSERT INTO t3(b) SELECT b||'h' FROM t3;
2N/A SELECT count(a), count(b) FROM t3;
2N/A SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3);
2N/A SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3 ORDER BY a+1);
2N/A# Ticket #601: Putting a left join inside "SELECT * FROM (<join-here>)"
2N/A# gives different results that if the outer "SELECT * FROM ..." is omitted.
2N/A CREATE TABLE x1 (b, c);
2N/A INSERT INTO x1 VALUES('dog',3);
2N/A INSERT INTO x1 VALUES('cat',1);
2N/A INSERT INTO x1 VALUES('dog',4);
2N/A CREATE TABLE x2 (c, e);
2N/A INSERT INTO x2 VALUES(1,'one');
2N/A INSERT INTO x2 VALUES(2,'two');
2N/A INSERT INTO x2 VALUES(3,'three');
2N/A INSERT INTO x2 VALUES(4,'four');
2N/A SELECT
x2.c AS c, e, b FROM x2 LEFT JOIN
2N/A (SELECT b, max(c) AS c FROM x1 GROUP BY b)
2N/A} {1 one cat 2 two {} 3 three {} 4 four dog}
2N/A SELECT
x2.c AS c, e, b FROM x2 LEFT JOIN
2N/A (SELECT b, max(c) AS c FROM x1 GROUP BY b)
2N/A} {1 one cat 2 two {} 3 three {} 4 four dog}
2N/A# Ticket #626: make sure EXPLAIN prevents BEGIN and COMMIT from working.
2N/A execsql {EXPLAIN BEGIN}
2N/A execsql {EXPLAIN COMMIT}
2N/A execsql {BEGIN; EXPLAIN ROLLBACK}
2N/A# Ticket #640: vdbe stack overflow with a LIMIT clause on a SELECT inside
2N/A CREATE TRIGGER r1 AFTER DELETE ON y1 FOR EACH ROW BEGIN
2N/A INSERT INTO y3(c) SELECT b FROM y2 ORDER BY b LIMIT 1;
2N/A INSERT INTO y1 VALUES(1);
2N/A INSERT INTO y1 VALUES(2);
2N/A INSERT INTO y1 SELECT a+2 FROM y1;
2N/A INSERT INTO y1 SELECT a+4 FROM y1;
2N/A INSERT INTO y1 SELECT a+8 FROM y1;
2N/A INSERT INTO y1 SELECT a+16 FROM y1;
2N/A INSERT INTO y2 SELECT a FROM y1;
2N/A SELECT count(*) FROM y1;
2N/A SELECT count(*) FROM y1;
2N/A SELECT count(*) FROM y3;
2N/A# Ticket #668: VDBE stack overflow occurs when the left-hand side
2N/A# of an IN expression is NULL and the result is used as an integer, not
2N/A SELECT count(CASE WHEN b IN ('abc','xyz') THEN 'x' END) FROM t3
2N/A SELECT count(*) FROM t3 WHERE 1+(b IN ('abc','xyz'))==2