mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Merge latest trunk changes.
FossilOrigin-Name: 1a72777b1279f74f212fb2f675a4594a238e5d28f048879d7f5ad5287673c3c4
This commit is contained in:
66
test/memdb2.test
Normal file
66
test/memdb2.test
Normal file
@ -0,0 +1,66 @@
|
||||
# 2022-12-05
|
||||
#
|
||||
# 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. The
|
||||
# focus of this file is the "memdb" VFS
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix memdb1
|
||||
do_not_use_codec
|
||||
|
||||
ifcapable !deserialize {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db close
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that when using a memdb database, it is not possible to upgrade
|
||||
# to an EXCLUSIVE lock if some other client is holding SHARED.
|
||||
#
|
||||
sqlite3 db file:/test.db?vfs=memdb -uri 1
|
||||
sqlite3 db2 file:/test.db?vfs=memdb -uri 1
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
}
|
||||
|
||||
do_execsql_test -db db2 1.2 {
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
} {1 2}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
}
|
||||
|
||||
do_catchsql_test 1.4 {
|
||||
COMMIT
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_execsql_test -db db2 1.5 {
|
||||
SELECT * FROM t1;
|
||||
END;
|
||||
} {1 2}
|
||||
|
||||
do_execsql_test 1.6 {
|
||||
COMMIT
|
||||
} {}
|
||||
|
||||
do_execsql_test -db db2 1.7 {
|
||||
SELECT * FROM t1
|
||||
} {1 2 3 4}
|
||||
|
||||
finish_test
|
@ -43,6 +43,7 @@ do_test 1.0 {
|
||||
(NULL, 1, 3, 'one-c'),
|
||||
(NULL, 2, 1, 'two-a'),
|
||||
(NULL, 3, 1, 'three-a');
|
||||
ANALYZE;
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
@ -180,6 +181,7 @@ do_test 2.0 {
|
||||
(1, 3, 'one-c'),
|
||||
(20, 1, 'two-a'),
|
||||
(3, 1, 'three-a');
|
||||
ANALYZE;
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
@ -327,6 +329,7 @@ do_test 3.0 {
|
||||
(NULL, 1, 3, 'one-c'),
|
||||
(NULL, 2, 1, 'two-a'),
|
||||
(NULL, 3, 1, 'three-a');
|
||||
ANALYZE;
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
|
@ -191,4 +191,16 @@ do_test shell2-1.4.7 {
|
||||
SELECT 'unclosed;
|
||||
^--- error here}}
|
||||
|
||||
# Verify that safe mode rejects certain UDFs
|
||||
# Reported at https://sqlite.org/forum/forumpost/07beac8056151b2f
|
||||
do_test shell2-1.4.8 {
|
||||
catchcmd "-safe :memory:" {
|
||||
SELECT edit('DoNotCare');}
|
||||
} {1 {line 2: cannot use the edit() function in safe mode}}
|
||||
do_test shell2-1.4.9 {
|
||||
catchcmd "-safe :memory:" {
|
||||
SELECT writefile('DoNotCare', x'');}
|
||||
} {1 {line 2: cannot use the writefile() function in safe mode}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
@ -595,4 +595,36 @@ do_execsql_test 17.1 {
|
||||
SELECT * FROM sqlite_master ORDER BY sql;
|
||||
} {}
|
||||
|
||||
# 2022-12-03 Ticket e8b674241947eb3b
|
||||
# Improve estimates for the cost of sorting relative
|
||||
# to the cost of doing an index lookup, so as to get
|
||||
# a better query plan. See the ticket for a deetailed
|
||||
# example.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 18.1 {
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
|
||||
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<50)
|
||||
-- increase to 5000 for actual test data ----^^
|
||||
INSERT INTO t1(a,b,c) SELECT x, random()%5000, random()%5000 FROM c;
|
||||
CREATE TABLE t2(d,e,f);
|
||||
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<500)
|
||||
-- increase to 50000 for actual test data -----^^^
|
||||
INSERT INTO t2(d,e,f) SELECT
|
||||
NULLIF(0, random()%2), random()%5000, random()%5000
|
||||
FROM c;
|
||||
ANALYZE;
|
||||
UPDATE sqlite_stat1 SET stat='50000' WHERE tbl='t2';
|
||||
UPDATE sqlite_stat1 SET stat='5000' WHERE tbl='t1';
|
||||
ANALYZE sqlite_schema;
|
||||
} {}
|
||||
do_execsql_test 18.2 {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1 JOIN t2
|
||||
WHERE a IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
|
||||
AND a=CASE WHEN d IS NOT NULL THEN e ELSE f END
|
||||
ORDER BY a;
|
||||
} {/.*SCAN t2.*SEARCH t1.*/}
|
||||
# ^^^^^^^--^^^^^^^^^--- t2 should be the outer loop.
|
||||
|
||||
finish_test
|
||||
|
@ -545,6 +545,7 @@ do_test where-6.1 {
|
||||
CREATE INDEX t3acb ON t3(a,c,b);
|
||||
INSERT INTO t3 SELECT w, 101-w, y FROM t1;
|
||||
SELECT count(*), sum(a), sum(b), sum(c) FROM t3;
|
||||
ANALYZE;
|
||||
}
|
||||
} {100 5050 5050 348550}
|
||||
do_test where-6.2 {
|
||||
|
Reference in New Issue
Block a user