mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Merge trunk changes into sessions branch.
FossilOrigin-Name: b91b4c31fe311b292044c9c747feba294ffce25c
This commit is contained in:
316
test/exists.test
316
test/exists.test
@@ -17,175 +17,181 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
|
||||
set testprefix exists
|
||||
|
||||
# This block of tests is targeted at CREATE XXX IF NOT EXISTS statements.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
foreach jm {rollback wal} {
|
||||
|
||||
# TABLE objects.
|
||||
set testprefix exists-$jm
|
||||
|
||||
# This block of tests is targeted at CREATE XXX IF NOT EXISTS statements.
|
||||
#
|
||||
do_test 1.$tn.1.1 {
|
||||
sql2 { CREATE TABLE t1(x) }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
|
||||
sql2 { DROP TABLE t1 }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
|
||||
} {t1}
|
||||
do_multiclient_test tn {
|
||||
|
||||
do_test 1.$tn.1.2 {
|
||||
sql2 { CREATE TABLE t2(x) }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
|
||||
sql2 { DROP TABLE t2 }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
|
||||
} {t1 t2}
|
||||
# TABLE objects.
|
||||
#
|
||||
do_test 1.$tn.1.1 {
|
||||
if {$jm == "wal"} { sql2 { PRAGMA journal_mode = WAL } }
|
||||
sql2 { CREATE TABLE t1(x) }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
|
||||
sql2 { DROP TABLE t1 }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
|
||||
} {t1}
|
||||
|
||||
do_test 1.$tn.1.2 {
|
||||
sql2 { CREATE TABLE t2(x) }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
|
||||
sql2 { DROP TABLE t2 }
|
||||
sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
|
||||
} {t1 t2}
|
||||
|
||||
|
||||
# INDEX objects.
|
||||
# INDEX objects.
|
||||
#
|
||||
do_test 1.$tn.2 {
|
||||
sql2 { CREATE INDEX i1 ON t1(a) }
|
||||
sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
|
||||
sql2 { DROP INDEX i1 }
|
||||
sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
|
||||
} {i1}
|
||||
|
||||
# VIEW objects.
|
||||
#
|
||||
do_test 1.$tn.3 {
|
||||
sql2 { CREATE VIEW v1 AS SELECT * FROM t1 }
|
||||
sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
|
||||
sql2 { DROP VIEW v1 }
|
||||
sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
|
||||
} {v1}
|
||||
|
||||
# TRIGGER objects.
|
||||
#
|
||||
do_test $tn.4 {
|
||||
sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
|
||||
sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
|
||||
sql2 { DROP TRIGGER tr1 }
|
||||
sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
|
||||
} {tr1}
|
||||
}
|
||||
|
||||
# This block of tests is targeted at DROP XXX IF EXISTS statements.
|
||||
#
|
||||
do_test 1.$tn.2 {
|
||||
sql2 { CREATE INDEX i1 ON t1(a) }
|
||||
sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
|
||||
sql2 { DROP INDEX i1 }
|
||||
sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
|
||||
} {i1}
|
||||
do_multiclient_test tn {
|
||||
|
||||
# VIEW objects.
|
||||
# TABLE objects.
|
||||
#
|
||||
do_test 2.$tn.1 {
|
||||
if {$jm == "wal"} { sql1 { PRAGMA journal_mode = WAL } }
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { CREATE TABLE t1(x) }
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
|
||||
} {}
|
||||
|
||||
# INDEX objects.
|
||||
#
|
||||
do_test 2.$tn.2 {
|
||||
sql1 { CREATE TABLE t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { CREATE INDEX i2 ON t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
|
||||
} {}
|
||||
|
||||
# VIEW objects.
|
||||
#
|
||||
do_test 2.$tn.3 {
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { CREATE VIEW v1 AS SELECT * FROM t2 }
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
|
||||
} {}
|
||||
|
||||
# TRIGGER objects.
|
||||
#
|
||||
do_test 2.$tn.4 {
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
|
||||
} {}
|
||||
}
|
||||
|
||||
# This block of tests is targeted at DROP XXX IF EXISTS statements with
|
||||
# attached databases.
|
||||
#
|
||||
do_test 1.$tn.3 {
|
||||
sql2 { CREATE VIEW v1 AS SELECT * FROM t1 }
|
||||
sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
|
||||
sql2 { DROP VIEW v1 }
|
||||
sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
|
||||
} {v1}
|
||||
do_multiclient_test tn {
|
||||
|
||||
# TRIGGER objects.
|
||||
#
|
||||
do_test $tn.4 {
|
||||
sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
|
||||
sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
|
||||
sql2 { DROP TRIGGER tr1 }
|
||||
sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
|
||||
} {tr1}
|
||||
}
|
||||
forcedelete test.db2
|
||||
do_test 3.$tn.0 {
|
||||
sql1 { ATTACH 'test.db2' AS aux }
|
||||
sql2 { ATTACH 'test.db2' AS aux }
|
||||
} {}
|
||||
|
||||
# This block of tests is targeted at DROP XXX IF EXISTS statements.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
# TABLE objects.
|
||||
#
|
||||
do_test 3.$tn.1.1 {
|
||||
sql1 { DROP TABLE IF EXISTS aux.t1 }
|
||||
sql2 { CREATE TABLE aux.t1(x) }
|
||||
sql1 { DROP TABLE IF EXISTS aux.t1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
|
||||
} {}
|
||||
do_test 3.$tn.1.2 {
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { CREATE TABLE aux.t1(x) }
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
|
||||
} {}
|
||||
|
||||
# TABLE objects.
|
||||
#
|
||||
do_test 2.$tn.1 {
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { CREATE TABLE t1(x) }
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }
|
||||
} {}
|
||||
# INDEX objects.
|
||||
#
|
||||
do_test 3.$tn.2.1 {
|
||||
sql1 { CREATE TABLE aux.t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS aux.i2 }
|
||||
sql2 { CREATE INDEX aux.i2 ON t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS aux.i2 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
|
||||
} {}
|
||||
do_test 3.$tn.2.2 {
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { CREATE INDEX aux.i2 ON t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
|
||||
} {}
|
||||
|
||||
# INDEX objects.
|
||||
#
|
||||
do_test 2.$tn.2 {
|
||||
sql1 { CREATE TABLE t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { CREATE INDEX i2 ON t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }
|
||||
} {}
|
||||
# VIEW objects.
|
||||
#
|
||||
do_test 3.$tn.3.1 {
|
||||
sql1 { DROP VIEW IF EXISTS aux.v1 }
|
||||
sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
|
||||
sql1 { DROP VIEW IF EXISTS aux.v1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
|
||||
} {}
|
||||
do_test 3.$tn.3.2 {
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
|
||||
} {}
|
||||
|
||||
# VIEW objects.
|
||||
#
|
||||
do_test 2.$tn.3 {
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { CREATE VIEW v1 AS SELECT * FROM t2 }
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }
|
||||
} {}
|
||||
|
||||
# TRIGGER objects.
|
||||
#
|
||||
do_test 2.$tn.4 {
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }
|
||||
} {}
|
||||
}
|
||||
|
||||
# This block of tests is targeted at DROP XXX IF EXISTS statements with
|
||||
# attached databases.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
|
||||
forcedelete test.db2
|
||||
do_test 3.$tn.0 {
|
||||
sql1 { ATTACH 'test.db2' AS aux }
|
||||
sql2 { ATTACH 'test.db2' AS aux }
|
||||
} {}
|
||||
|
||||
# TABLE objects.
|
||||
#
|
||||
do_test 3.$tn.1.1 {
|
||||
sql1 { DROP TABLE IF EXISTS aux.t1 }
|
||||
sql2 { CREATE TABLE aux.t1(x) }
|
||||
sql1 { DROP TABLE IF EXISTS aux.t1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
|
||||
} {}
|
||||
do_test 3.$tn.1.2 {
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { CREATE TABLE aux.t1(x) }
|
||||
sql1 { DROP TABLE IF EXISTS t1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }
|
||||
} {}
|
||||
|
||||
# INDEX objects.
|
||||
#
|
||||
do_test 3.$tn.2.1 {
|
||||
sql1 { CREATE TABLE aux.t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS aux.i2 }
|
||||
sql2 { CREATE INDEX aux.i2 ON t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS aux.i2 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
|
||||
} {}
|
||||
do_test 3.$tn.2.2 {
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { CREATE INDEX aux.i2 ON t2(x) }
|
||||
sql1 { DROP INDEX IF EXISTS i2 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }
|
||||
} {}
|
||||
|
||||
# VIEW objects.
|
||||
#
|
||||
do_test 3.$tn.3.1 {
|
||||
sql1 { DROP VIEW IF EXISTS aux.v1 }
|
||||
sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
|
||||
sql1 { DROP VIEW IF EXISTS aux.v1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
|
||||
} {}
|
||||
do_test 3.$tn.3.2 {
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }
|
||||
sql1 { DROP VIEW IF EXISTS v1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }
|
||||
} {}
|
||||
|
||||
# TRIGGER objects.
|
||||
#
|
||||
do_test 3.$tn.4.1 {
|
||||
sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
|
||||
sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
|
||||
sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
|
||||
} {}
|
||||
do_test 3.$tn.4.2 {
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
|
||||
} {}
|
||||
# TRIGGER objects.
|
||||
#
|
||||
do_test 3.$tn.4.1 {
|
||||
sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
|
||||
sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
|
||||
sql1 { DROP TRIGGER IF EXISTS aux.tr1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
|
||||
} {}
|
||||
do_test 3.$tn.4.2 {
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }
|
||||
sql1 { DROP TRIGGER IF EXISTS tr1 }
|
||||
sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }
|
||||
} {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -202,6 +202,9 @@ do_test quota-3.2.9 {
|
||||
set ::quota [list]
|
||||
proc quota_callback {file limitvar size} {
|
||||
upvar $limitvar limit
|
||||
if {$::tcl_platform(platform)=="windows"} {
|
||||
set file [ lindex [string map {\\ \/} $file] 0 ]
|
||||
}
|
||||
lappend ::quota $file $size
|
||||
set limit 0
|
||||
}
|
||||
|
||||
@@ -19,19 +19,27 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
#
|
||||
# These tests are only applicable on unix when pager pragma are
|
||||
# These tests are only applicable when pager pragma are
|
||||
# enabled. Also, since every test uses an ATTACHed database, they
|
||||
# are only run when ATTACH is enabled.
|
||||
#
|
||||
if {$::tcl_platform(platform)!="unix"} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
ifcapable !pager_pragmas||!attach {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
set sqlite_sync_count 0
|
||||
proc cond_incr_sync_count {adj} {
|
||||
global sqlite_sync_count
|
||||
if {$::tcl_platform(platform) == "windows"} {
|
||||
incr sqlite_sync_count $adj
|
||||
} {
|
||||
ifcapable !dirsync {
|
||||
incr sqlite_sync_count $adj
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do_test sync-1.1 {
|
||||
set sqlite_sync_count 0
|
||||
file delete -force test2.db
|
||||
@@ -42,9 +50,7 @@ do_test sync-1.1 {
|
||||
ATTACH DATABASE 'test2.db' AS db2;
|
||||
CREATE TABLE db2.t2(x,y);
|
||||
}
|
||||
ifcapable !dirsync {
|
||||
incr sqlite_sync_count 2
|
||||
}
|
||||
cond_incr_sync_count 2
|
||||
set sqlite_sync_count
|
||||
} 8
|
||||
ifcapable pager_pragmas {
|
||||
@@ -58,9 +64,7 @@ ifcapable pager_pragmas {
|
||||
INSERT INTO t2 VALUES(3,4);
|
||||
COMMIT;
|
||||
}
|
||||
ifcapable !dirsync {
|
||||
incr sqlite_sync_count 3
|
||||
}
|
||||
cond_incr_sync_count 3
|
||||
set sqlite_sync_count
|
||||
} 8
|
||||
}
|
||||
@@ -74,9 +78,7 @@ do_test sync-1.3 {
|
||||
INSERT INTO t2 VALUES(5,6);
|
||||
COMMIT;
|
||||
}
|
||||
ifcapable !dirsync {
|
||||
incr sqlite_sync_count 3
|
||||
}
|
||||
cond_incr_sync_count 3
|
||||
set sqlite_sync_count
|
||||
} 10
|
||||
ifcapable pager_pragmas {
|
||||
|
||||
@@ -246,7 +246,7 @@ do_test triggerC-2.2 {
|
||||
} {100}
|
||||
|
||||
do_test triggerC-2.3 {
|
||||
execsql {
|
||||
execsql "
|
||||
CREATE TABLE t23(x PRIMARY KEY);
|
||||
|
||||
CREATE TRIGGER t23a AFTER INSERT ON t23 BEGIN
|
||||
@@ -254,15 +254,15 @@ do_test triggerC-2.3 {
|
||||
END;
|
||||
|
||||
CREATE TRIGGER t23b BEFORE INSERT ON t23 BEGIN
|
||||
SELECT CASE WHEN new.x>500
|
||||
SELECT CASE WHEN new.x>[expr $SQLITE_MAX_TRIGGER_DEPTH / 2]
|
||||
THEN RAISE(IGNORE)
|
||||
ELSE NULL END;
|
||||
END;
|
||||
|
||||
INSERT INTO t23 VALUES(1);
|
||||
SELECT count(*) FROM t23;
|
||||
}
|
||||
} {500}
|
||||
"
|
||||
} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@@ -288,12 +288,12 @@ do_test triggerC-3.1.3 {
|
||||
} {}
|
||||
|
||||
do_test triggerC-3.2.1 {
|
||||
execsql {
|
||||
execsql "
|
||||
CREATE TABLE t3b(x);
|
||||
CREATE TRIGGER t3bi AFTER INSERT ON t3b WHEN new.x<2000 BEGIN
|
||||
CREATE TRIGGER t3bi AFTER INSERT ON t3b WHEN new.x<[expr $SQLITE_MAX_TRIGGER_DEPTH * 2] BEGIN
|
||||
INSERT INTO t3b VALUES(new.x+1);
|
||||
END;
|
||||
}
|
||||
"
|
||||
catchsql {
|
||||
INSERT INTO t3b VALUES(1);
|
||||
}
|
||||
@@ -303,39 +303,39 @@ do_test triggerC-3.2.2 {
|
||||
} {}
|
||||
|
||||
do_test triggerC-3.3.1 {
|
||||
catchsql {
|
||||
INSERT INTO t3b VALUES(1001);
|
||||
}
|
||||
catchsql "
|
||||
INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH + 1]);
|
||||
"
|
||||
} {0 {}}
|
||||
do_test triggerC-3.3.2 {
|
||||
db eval {SELECT count(*), max(x), min(x) FROM t3b}
|
||||
} {1000 2000 1001}
|
||||
} [list $SQLITE_MAX_TRIGGER_DEPTH [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr $SQLITE_MAX_TRIGGER_DEPTH + 1]]
|
||||
|
||||
do_test triggerC-3.4.1 {
|
||||
catchsql {
|
||||
catchsql "
|
||||
DELETE FROM t3b;
|
||||
INSERT INTO t3b VALUES(999);
|
||||
}
|
||||
INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH - 1]);
|
||||
"
|
||||
} {1 {too many levels of trigger recursion}}
|
||||
do_test triggerC-3.4.2 {
|
||||
db eval {SELECT count(*), max(x), min(x) FROM t3b}
|
||||
} {0 {} {}}
|
||||
|
||||
do_test triggerC-3.5.1 {
|
||||
sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 100
|
||||
catchsql {
|
||||
INSERT INTO t3b VALUES(1901);
|
||||
}
|
||||
sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH [expr $SQLITE_MAX_TRIGGER_DEPTH / 10]
|
||||
catchsql "
|
||||
INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10) + 1]);
|
||||
"
|
||||
} {0 {}}
|
||||
do_test triggerC-3.5.2 {
|
||||
db eval {SELECT count(*), max(x), min(x) FROM t3b}
|
||||
} {100 2000 1901}
|
||||
} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 10] [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10) + 1]]
|
||||
|
||||
do_test triggerC-3.5.3 {
|
||||
catchsql {
|
||||
catchsql "
|
||||
DELETE FROM t3b;
|
||||
INSERT INTO t3b VALUES(1900);
|
||||
}
|
||||
INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10)]);
|
||||
"
|
||||
} {1 {too many levels of trigger recursion}}
|
||||
do_test triggerC-3.5.4 {
|
||||
db eval {SELECT count(*), max(x), min(x) FROM t3b}
|
||||
@@ -343,25 +343,25 @@ do_test triggerC-3.5.4 {
|
||||
|
||||
do_test triggerC-3.6.1 {
|
||||
sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1
|
||||
catchsql {
|
||||
INSERT INTO t3b VALUES(2000);
|
||||
}
|
||||
catchsql "
|
||||
INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH * 2]);
|
||||
"
|
||||
} {0 {}}
|
||||
do_test triggerC-3.6.2 {
|
||||
db eval {SELECT count(*), max(x), min(x) FROM t3b}
|
||||
} {1 2000 2000}
|
||||
} [list 1 [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr $SQLITE_MAX_TRIGGER_DEPTH * 2]]
|
||||
|
||||
do_test triggerC-3.6.3 {
|
||||
catchsql {
|
||||
catchsql "
|
||||
DELETE FROM t3b;
|
||||
INSERT INTO t3b VALUES(1999);
|
||||
}
|
||||
INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - 1]);
|
||||
"
|
||||
} {1 {too many levels of trigger recursion}}
|
||||
do_test triggerC-3.6.4 {
|
||||
db eval {SELECT count(*), max(x), min(x) FROM t3b}
|
||||
} {0 {} {}}
|
||||
sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000
|
||||
|
||||
sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH $SQLITE_MAX_TRIGGER_DEPTH
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# This next block of tests, triggerC-4.*, checks that affinity
|
||||
|
||||
68
test/unordered.test
Normal file
68
test/unordered.test
Normal file
@@ -0,0 +1,68 @@
|
||||
# 2011 April 9
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
set testprefix unordered
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE INDEX i1 ON t1(a);
|
||||
INSERT INTO t1 VALUES(1, 'xxx');
|
||||
INSERT INTO t1 SELECT a+1, b FROM t1;
|
||||
INSERT INTO t1 SELECT a+2, 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;
|
||||
ANALYZE;
|
||||
} {}
|
||||
|
||||
foreach idxmode {ordered unordered} {
|
||||
if {$idxmode == "unordered"} {
|
||||
execsql { UPDATE sqlite_stat1 SET stat = stat || ' unordered' }
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
}
|
||||
foreach {tn sql r(ordered) r(unordered)} {
|
||||
1 "SELECT * FROM t1 ORDER BY a"
|
||||
{0 0 0 {SCAN TABLE t1 USING INDEX i1 (~128 rows)}}
|
||||
{0 0 0 {SCAN TABLE t1 (~128 rows)} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
|
||||
2 "SELECT * FROM t1 WHERE a >?"
|
||||
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~32 rows)}}
|
||||
{0 0 0 {SCAN TABLE t1 (~42 rows)}}
|
||||
3 "SELECT * FROM t1 WHERE a = ? ORDER BY rowid"
|
||||
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
|
||||
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}
|
||||
0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
|
||||
4 "SELECT max(a) FROM t1"
|
||||
{0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (~1 rows)}}
|
||||
{0 0 0 {SEARCH TABLE t1 (~1 rows)}}
|
||||
5 "SELECT group_concat(b) FROM t1 GROUP BY a"
|
||||
{0 0 0 {SCAN TABLE t1 USING INDEX i1 (~128 rows)}}
|
||||
{0 0 0 {SCAN TABLE t1 (~128 rows)} 0 0 0 {USE TEMP B-TREE FOR GROUP BY}}
|
||||
|
||||
6 "SELECT * FROM t1 WHERE a = ?"
|
||||
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
|
||||
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
|
||||
7 "SELECT count(*) FROM t1"
|
||||
{0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1(~128 rows)}}
|
||||
{0 0 0 {SCAN TABLE t1 (~128 rows)}}
|
||||
} {
|
||||
do_eqp_test 1.$idxmode.$tn $sql $r($idxmode)
|
||||
}
|
||||
}
|
||||
|
||||
finish_test
|
||||
@@ -23,6 +23,18 @@ set testprefix wal2
|
||||
|
||||
ifcapable !wal {finish_test ; return }
|
||||
|
||||
set sqlite_sync_count 0
|
||||
proc cond_incr_sync_count {adj} {
|
||||
global sqlite_sync_count
|
||||
if {$::tcl_platform(platform) == "windows"} {
|
||||
incr sqlite_sync_count $adj
|
||||
} {
|
||||
ifcapable !dirsync {
|
||||
incr sqlite_sync_count $adj
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc set_tvfs_hdr {file args} {
|
||||
|
||||
# Set $nHdr to the number of bytes in the wal-index header:
|
||||
@@ -1189,6 +1201,7 @@ foreach {tn sql reslist} {
|
||||
} {10 0 5 5 0 2 2}
|
||||
|
||||
do_test wal2-14.$tn.3 {
|
||||
cond_incr_sync_count 1
|
||||
list $sqlite_sync_count $sqlite_fullsync_count
|
||||
} [lrange $reslist 0 1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user