mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Update this branch with latest trunk changes.
FossilOrigin-Name: 11f4761c3a84e2cc9df62f117a003af8c57f3d226eec5a40d6241b121e78d002
This commit is contained in:
77
test/cachespill.test
Normal file
77
test/cachespill.test
Normal file
@@ -0,0 +1,77 @@
|
||||
# 2017 April 26
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix cachespill
|
||||
|
||||
ifcapable !pager_pragmas {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that "PRAGMA cache_spill = 0" completely disables cache spilling.
|
||||
#
|
||||
do_execsql_test 1.1 {
|
||||
PRAGMA auto_vacuum = 0;
|
||||
PRAGMA page_size = 1024;
|
||||
PRAGMA cache_size = 100;
|
||||
CREATE TABLE t1(a);
|
||||
}
|
||||
|
||||
do_test 1.2 {
|
||||
file size test.db
|
||||
} {2048}
|
||||
|
||||
do_test 1.3 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
|
||||
) INSERT INTO t1 SELECT randomblob(900) FROM s;
|
||||
}
|
||||
expr {[file size test.db] > 50000}
|
||||
} {1}
|
||||
|
||||
do_test 1.4 {
|
||||
execsql ROLLBACK
|
||||
file size test.db
|
||||
} {2048}
|
||||
|
||||
do_test 1.5 {
|
||||
execsql {
|
||||
PRAGMA cache_spill = 0;
|
||||
BEGIN;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
|
||||
) INSERT INTO t1 SELECT randomblob(900) FROM s;
|
||||
}
|
||||
file size test.db
|
||||
} {2048}
|
||||
|
||||
do_test 1.5 {
|
||||
execsql {
|
||||
ROLLBACK;
|
||||
PRAGMA cache_spill = 1;
|
||||
BEGIN;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200
|
||||
) INSERT INTO t1 SELECT randomblob(900) FROM s;
|
||||
}
|
||||
expr {[file size test.db] > 50000}
|
||||
} {1}
|
||||
|
||||
do_execsql_test 1.6 { ROLLBACK }
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -237,4 +237,16 @@ do_execsql_test 8.4 {
|
||||
SELECT count(*) FROM n1 WHERE a IN (SELECT +a FROM n1)
|
||||
} 3
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that ticket 61fe97454c is fixed.
|
||||
#
|
||||
do_execsql_test 9.0 {
|
||||
CREATE TABLE t9(a INTEGER PRIMARY KEY);
|
||||
INSERT INTO t9 VALUES (44), (45);
|
||||
}
|
||||
do_execsql_test 9.1 {
|
||||
SELECT * FROM t9 WHERE a IN (44, 45, 44, 45)
|
||||
} {44 45}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -32,5 +32,13 @@ do_execsql_test 1.2 {
|
||||
SELECT 'TWOX' == (b || 'x') COLLATE nocase FROM t1 WHERE (b || 'x')>'onex'
|
||||
} {0 1}
|
||||
|
||||
do_execsql_test 2.0 {
|
||||
CREATE INDEX i2 ON t1(a+1);
|
||||
}
|
||||
|
||||
do_execsql_test 2.1 {
|
||||
SELECT a+1, quote(a+1) FROM t1 ORDER BY 1;
|
||||
} {2 2 3 3 4 4}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
59
test/pushdown.test
Normal file
59
test/pushdown.test
Normal file
@@ -0,0 +1,59 @@
|
||||
# 2017 April 29
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix pushdown
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
INSERT INTO t1 VALUES(1, 'b1', 'c1');
|
||||
INSERT INTO t1 VALUES(2, 'b2', 'c2');
|
||||
INSERT INTO t1 VALUES(3, 'b3', 'c3');
|
||||
INSERT INTO t1 VALUES(4, 'b4', 'c4');
|
||||
CREATE INDEX i1 ON t1(a, c);
|
||||
}
|
||||
|
||||
proc f {val} {
|
||||
lappend ::L $val
|
||||
return 0
|
||||
}
|
||||
db func f f
|
||||
|
||||
do_test 1.1 {
|
||||
set L [list]
|
||||
execsql { SELECT * FROM t1 WHERE a=2 AND f(b) AND f(c) }
|
||||
set L
|
||||
} {c2}
|
||||
|
||||
do_test 1.2 {
|
||||
set L [list]
|
||||
execsql { SELECT * FROM t1 WHERE a=3 AND f(c) AND f(b) }
|
||||
set L
|
||||
} {c3}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
DROP INDEX i1;
|
||||
CREATE INDEX i1 ON t1(a, b);
|
||||
}
|
||||
do_test 1.4 {
|
||||
set L [list]
|
||||
execsql { SELECT * FROM t1 WHERE a=2 AND f(b) AND f(c) }
|
||||
set L
|
||||
} {b2}
|
||||
|
||||
do_test 1.5 {
|
||||
set L [list]
|
||||
execsql { SELECT * FROM t1 WHERE a=3 AND f(c) AND f(b) }
|
||||
set L
|
||||
} {b3}
|
||||
|
||||
finish_test
|
||||
Reference in New Issue
Block a user