e2201971ac
FossilOrigin-Name: 096312dacb9eb2f8da3cec1504aef8629b505e7f
241 lines
6.3 KiB
Plaintext
241 lines
6.3 KiB
Plaintext
# 2003 December 17
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
# This file implements regression tests for SQLite library.
|
|
#
|
|
# This file implements tests for miscellanous features that were
|
|
# left out of other test files.
|
|
#
|
|
# $Id: misc3.test,v 1.7 2004/02/09 14:35:28 drh Exp $
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
# Ticket #529. Make sure an ABORT does not damage the in-memory cache
|
|
# that will be used by subsequent statements in the same transaction.
|
|
#
|
|
do_test misc3-1.1 {
|
|
execsql {
|
|
CREATE TABLE t1(a UNIQUE,b);
|
|
INSERT INTO t1
|
|
VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
|
|
UPDATE t1 SET b=b||b;
|
|
UPDATE t1 SET b=b||b;
|
|
UPDATE t1 SET b=b||b;
|
|
UPDATE t1 SET b=b||b;
|
|
UPDATE t1 SET b=b||b;
|
|
INSERT INTO t1 VALUES(2,'x');
|
|
UPDATE t1 SET b=substr(b,1,500);
|
|
BEGIN;
|
|
}
|
|
catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';}
|
|
execsql {
|
|
CREATE TABLE t2(x,y);
|
|
COMMIT;
|
|
PRAGMA integrity_check;
|
|
}
|
|
} ok
|
|
do_test misc3-1.2 {
|
|
execsql {
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
VACUUM;
|
|
CREATE TABLE t1(a UNIQUE,b);
|
|
INSERT INTO t1
|
|
VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');
|
|
INSERT INTO t1 SELECT a+1, b||b FROM t1;
|
|
INSERT INTO t1 SELECT a+2, b||b FROM t1;
|
|
INSERT INTO t1 SELECT a+4, b FROM t1;
|
|
INSERT INTO t1 SELECT a+8, b FROM t1;
|
|
INSERT INTO t1 SELECT a+16, b FROM t1;
|
|
INSERT INTO t1 SELECT a+32, b FROM t1;
|
|
INSERT INTO t1 SELECT a+64, b FROM t1;
|
|
|
|
BEGIN;
|
|
}
|
|
catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';}
|
|
execsql {
|
|
INSERT INTO t1 VALUES(200,'hello out there');
|
|
COMMIT;
|
|
PRAGMA integrity_check;
|
|
}
|
|
} ok
|
|
|
|
# Tests of the sqliteAtoF() function in util.c
|
|
#
|
|
do_test misc3-2.1 {
|
|
execsql {SELECT 2e-25*0.5e25}
|
|
} 1
|
|
do_test misc3-2.2 {
|
|
execsql {SELECT 2.0e-25*000000.500000000000000000000000000000e+00025}
|
|
} 1
|
|
do_test misc3-2.3 {
|
|
execsql {SELECT 000000000002e-0000000025*0.5e25}
|
|
} 1
|
|
do_test misc3-2.4 {
|
|
execsql {SELECT 2e-25*0.5e250}
|
|
} 1e+225
|
|
do_test misc3-2.5 {
|
|
execsql {SELECT 2.0e-250*0.5e25}
|
|
} 1e-225
|
|
do_test misc3-2.6 {
|
|
execsql {SELECT '-2.0e-127' * '-0.5e27'}
|
|
} 1e-100
|
|
do_test misc3-2.7 {
|
|
execsql {SELECT '+2.0e-127' * '-0.5e27'}
|
|
} -1e-100
|
|
do_test misc3-2.8 {
|
|
execsql {SELECT 2.0e-27 * '+0.5e+127'}
|
|
} 1e+100
|
|
do_test misc3-2.9 {
|
|
execsql {SELECT 2.0e-27 * '+0.000005e+132'}
|
|
} 1e+100
|
|
|
|
# Ticket #522. Make sure integer overflow is handled properly in
|
|
# indices.
|
|
#
|
|
do_test misc3-3.1 {
|
|
execsql {PRAGMA integrity_check}
|
|
} ok
|
|
do_test misc3-3.2 {
|
|
execsql {
|
|
CREATE TABLE t2(a INT UNIQUE);
|
|
PRAGMA integrity_check;
|
|
}
|
|
} ok
|
|
do_test misc3-3.3 {
|
|
execsql {
|
|
INSERT INTO t2 VALUES(2147483648);
|
|
PRAGMA integrity_check;
|
|
}
|
|
} ok
|
|
do_test misc3-3.4 {
|
|
execsql {
|
|
INSERT INTO t2 VALUES(-2147483649);
|
|
PRAGMA integrity_check;
|
|
}
|
|
} ok
|
|
do_test misc3-3.5 {
|
|
execsql {
|
|
INSERT INTO t2 VALUES(+2147483649);
|
|
PRAGMA integrity_check;
|
|
}
|
|
} ok
|
|
do_test misc3-3.6 {
|
|
execsql {
|
|
INSERT INTO t2 VALUES(+2147483647);
|
|
INSERT INTO t2 VALUES(-2147483648);
|
|
INSERT INTO t2 VALUES(-2147483647);
|
|
INSERT INTO t2 VALUES(2147483646);
|
|
SELECT * FROM t2 ORDER BY a;
|
|
}
|
|
} {-2147483649 -2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
|
|
do_test misc3-3.7 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>=-2147483648 ORDER BY a;
|
|
}
|
|
} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
|
|
do_test misc3-3.8 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>-2147483648 ORDER BY a;
|
|
}
|
|
} {-2147483647 2147483646 2147483647 2147483648 2147483649}
|
|
do_test misc3-3.9 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>-2147483649 ORDER BY a;
|
|
}
|
|
} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}
|
|
do_test misc3-3.10 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>=0 AND a<2147483649 ORDER BY a DESC;
|
|
}
|
|
} {2147483648 2147483647 2147483646}
|
|
do_test misc3-3.11 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>=0 AND a<=2147483648 ORDER BY a DESC;
|
|
}
|
|
} {2147483648 2147483647 2147483646}
|
|
do_test misc3-3.12 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>=0 AND a<2147483648 ORDER BY a DESC;
|
|
}
|
|
} {2147483647 2147483646}
|
|
do_test misc3-3.13 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>=0 AND a<=2147483647 ORDER BY a DESC;
|
|
}
|
|
} {2147483647 2147483646}
|
|
do_test misc3-3.14 {
|
|
execsql {
|
|
SELECT * FROM t2 WHERE a>=0 AND a<2147483647 ORDER BY a DESC;
|
|
}
|
|
} {2147483646}
|
|
|
|
# Ticket #565. A stack overflow is occurring when the subquery to the
|
|
# right of an IN operator contains many NULLs
|
|
#
|
|
do_test misc3-4.1 {
|
|
execsql {
|
|
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
|
|
INSERT INTO t3(b) VALUES('abc');
|
|
INSERT INTO t3(b) VALUES('xyz');
|
|
INSERT INTO t3(b) VALUES(NULL);
|
|
INSERT INTO t3(b) VALUES(NULL);
|
|
INSERT INTO t3(b) SELECT b||'d' FROM t3;
|
|
INSERT INTO t3(b) SELECT b||'e' FROM t3;
|
|
INSERT INTO t3(b) SELECT b||'f' FROM t3;
|
|
INSERT INTO t3(b) SELECT b||'g' FROM t3;
|
|
INSERT INTO t3(b) SELECT b||'h' FROM t3;
|
|
SELECT count(a), count(b) FROM t3;
|
|
}
|
|
} {128 64}
|
|
do_test misc3-4.2 {
|
|
execsql {
|
|
SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3);
|
|
}
|
|
} {64}
|
|
do_test misc3-4.3 {
|
|
execsql {
|
|
SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3 ORDER BY a+1);
|
|
}
|
|
} {64}
|
|
|
|
# Ticket #601: Putting a left join inside "SELECT * FROM (<join-here>)"
|
|
# gives different results that if the outer "SELECT * FROM ..." is omitted.
|
|
#
|
|
do_test misc4-5.1 {
|
|
execsql {
|
|
CREATE TABLE x1 (b, c);
|
|
INSERT INTO x1 VALUES('dog',3);
|
|
INSERT INTO x1 VALUES('cat',1);
|
|
INSERT INTO x1 VALUES('dog',4);
|
|
CREATE TABLE x2 (c, e);
|
|
INSERT INTO x2 VALUES(1,'one');
|
|
INSERT INTO x2 VALUES(2,'two');
|
|
INSERT INTO x2 VALUES(3,'three');
|
|
INSERT INTO x2 VALUES(4,'four');
|
|
SELECT x2.c AS c, e, b FROM x2 LEFT JOIN
|
|
(SELECT b, max(c) AS c FROM x1 GROUP BY b)
|
|
USING(c);
|
|
}
|
|
} {1 one cat 2 two {} 3 three {} 4 four dog}
|
|
do_test misc4-5.2 {
|
|
execsql {
|
|
SELECT * FROM (
|
|
SELECT x2.c AS c, e, b FROM x2 LEFT JOIN
|
|
(SELECT b, max(c) AS c FROM x1 GROUP BY b)
|
|
USING(c)
|
|
);
|
|
}
|
|
} {1 one cat 2 two {} 3 three {} 4 four dog}
|
|
|
|
|
|
finish_test
|