mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Merge all changes in the latest 3.8.11 beta into the sessions branch.
Changes include the rename of OTA to RBU, the WITHOUT-ROWID-OR-Skipscan fix, and improvements to pcache1. FossilOrigin-Name: 7f0ee77062d2fcb014942c7c62c163ccc801f21b
This commit is contained in:
@@ -21,6 +21,13 @@ source $testdir/tester.tcl
|
||||
# These tests deal with corrupt database files
|
||||
#
|
||||
database_may_be_corrupt
|
||||
db close
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_pagecache 0 0
|
||||
sqlite3_initialize
|
||||
autoinstall_test_functions
|
||||
sqlite3 db test.db
|
||||
|
||||
|
||||
expr srand(123)
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
#
|
||||
# $Id: malloc5.test,v 1.22 2009/04/11 19:09:54 drh Exp $
|
||||
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_pagecache 0 100
|
||||
sqlite3_initialize
|
||||
autoinstall_test_functions
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
@@ -41,6 +46,7 @@ ifcapable !memorymanage {
|
||||
|
||||
sqlite3_soft_heap_limit 0
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA cache_size=1}
|
||||
|
||||
do_test malloc5-1.1 {
|
||||
# Simplest possible test. Call sqlite3_release_memory when there is exactly
|
||||
@@ -61,15 +67,14 @@ do_test malloc5-1.2 {
|
||||
# not the case before version 3.6.2).
|
||||
#
|
||||
sqlite3 db2 test.db
|
||||
execsql { SELECT * FROM sqlite_master } db2
|
||||
execsql {PRAGMA cache_size=2; SELECT * FROM sqlite_master } db2
|
||||
} {}
|
||||
do_test malloc5-1.3 {
|
||||
# Call [sqlite3_release_memory] when there is exactly one unused page
|
||||
# in the cache belonging to db2.
|
||||
#
|
||||
set ::pgalloc [sqlite3_release_memory]
|
||||
expr $::pgalloc > 0
|
||||
} {1}
|
||||
} {0}
|
||||
|
||||
# The sizes of memory allocations from system malloc() might vary,
|
||||
# depending on the memory allocator algorithms used. The following
|
||||
@@ -231,6 +236,7 @@ do_test malloc5-4.1 {
|
||||
expr $nMaxBytes > 1000000
|
||||
} {1}
|
||||
do_test malloc5-4.2 {
|
||||
db eval {PRAGMA cache_size=1}
|
||||
db cache flush
|
||||
sqlite3_release_memory
|
||||
sqlite3_soft_heap_limit 100000
|
||||
@@ -302,7 +308,7 @@ do_test malloc5-6.1.1 {
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
PRAGMA page_size=1024;
|
||||
PRAGMA default_cache_size=10;
|
||||
PRAGMA default_cache_size=2;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA temp_store = memory;
|
||||
@@ -325,24 +331,25 @@ do_test malloc5-6.1.1 {
|
||||
}
|
||||
forcecopy test.db test2.db
|
||||
sqlite3 db2 test2.db
|
||||
db2 eval {PRAGMA cache_size=2}
|
||||
list \
|
||||
[expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20]
|
||||
} {1 1}
|
||||
do_test malloc5-6.1.2 {
|
||||
list [execsql {PRAGMA cache_size}] [execsql {PRAGMA cache_size} db2]
|
||||
} {10 10}
|
||||
} {2 2}
|
||||
|
||||
do_test malloc5-6.2.1 {
|
||||
execsql {SELECT * FROM abc} db2
|
||||
execsql {SELECT * FROM abc} db
|
||||
expr [nPage db] + [nPage db2]
|
||||
} {20}
|
||||
} {4}
|
||||
|
||||
do_test malloc5-6.2.2 {
|
||||
# If we now try to reclaim some memory, it should come from the db2 cache.
|
||||
sqlite3_release_memory 3000
|
||||
expr [nPage db] + [nPage db2]
|
||||
} {17}
|
||||
} {4}
|
||||
do_test malloc5-6.2.3 {
|
||||
# Access the db2 cache again, so that all the db2 pages have been used
|
||||
# more recently than all the db pages. Then try to reclaim 3000 bytes.
|
||||
@@ -350,7 +357,7 @@ do_test malloc5-6.2.3 {
|
||||
execsql { SELECT * FROM abc } db2
|
||||
sqlite3_release_memory 3000
|
||||
expr [nPage db] + [nPage db2]
|
||||
} {17}
|
||||
} {4}
|
||||
|
||||
do_test malloc5-6.3.1 {
|
||||
# Now open a transaction and update 2 pages in the db2 cache. Then
|
||||
@@ -367,19 +374,19 @@ do_test malloc5-6.3.1 {
|
||||
} db2
|
||||
execsql { SELECT * FROM abc } db
|
||||
expr [nPage db] + [nPage db2]
|
||||
} {20}
|
||||
} {4}
|
||||
do_test malloc5-6.3.2 {
|
||||
# Try to release 7700 bytes. This should release all the
|
||||
# non-dirty pages held by db2.
|
||||
sqlite3_release_memory [expr 7*1132]
|
||||
list [nPage db] [nPage db2]
|
||||
} {10 3}
|
||||
} {1 3}
|
||||
do_test malloc5-6.3.3 {
|
||||
# Try to release another 1000 bytes. This should come fromt the db
|
||||
# cache, since all three pages held by db2 are either in-use or diry.
|
||||
sqlite3_release_memory 1000
|
||||
list [nPage db] [nPage db2]
|
||||
} {9 3}
|
||||
} {1 3}
|
||||
do_test malloc5-6.3.4 {
|
||||
# Now release 9900 more (about 9 pages worth). This should expunge
|
||||
# the rest of the db cache. But the db2 cache remains intact, because
|
||||
@@ -390,20 +397,20 @@ do_test malloc5-6.3.4 {
|
||||
sqlite3_release_memory 9900
|
||||
}
|
||||
list [nPage db] [nPage db2]
|
||||
} {0 3}
|
||||
} {1 3}
|
||||
do_test malloc5-6.3.5 {
|
||||
# But if we are really insistent, SQLite will consent to call sync()
|
||||
# if there is no other option. UPDATE: As of 3.6.2, SQLite will not
|
||||
# call sync() in this scenario. So no further memory can be reclaimed.
|
||||
sqlite3_release_memory 1000
|
||||
list [nPage db] [nPage db2]
|
||||
} {0 3}
|
||||
} {1 3}
|
||||
do_test malloc5-6.3.6 {
|
||||
# The referenced page (page 1 of the db2 cache) will not be freed no
|
||||
# matter how much memory we ask for:
|
||||
sqlite3_release_memory 31459
|
||||
list [nPage db] [nPage db2]
|
||||
} {0 3}
|
||||
} {1 3}
|
||||
|
||||
db2 close
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ do_test pcache-1.4 {
|
||||
|
||||
do_test pcache-1.5 {
|
||||
sqlite3 db2 test.db
|
||||
execsql "PRAGMA cache_size=10" db2
|
||||
execsql "PRAGMA cache_size; PRAGMA cache_size=10" db2
|
||||
pcache_stats
|
||||
} {current 11 max 22 min 20 recyclable 1}
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ do_test pcache2-1.1 {
|
||||
do_test pcache2-1.2 {
|
||||
forcedelete test.db test.db-journal
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA cache_size=10}
|
||||
db eval {PRAGMA cache_size=10; SELECT 1 FROM sqlite_master;}
|
||||
lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
|
||||
} {2}
|
||||
do_test pcache2-1.3 {
|
||||
forcedelete test2.db test2.db-journal
|
||||
sqlite3 db2 test2.db
|
||||
db2 eval {PRAGMA cache_size=50}
|
||||
db2 eval {PRAGMA cache_size=50; SELECT 1 FROM sqlite_master;}
|
||||
lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
|
||||
} {4}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ set allquicktests [test_set $alltests -exclude {
|
||||
vtab_err.test walslow.test walcrash.test walcrash3.test
|
||||
walthread.test rtree3.test indexfault.test securedel2.test
|
||||
sort3.test sort4.test fts4growth.test fts4growth2.test
|
||||
bigsort.test ota.test
|
||||
bigsort.test rbu.test
|
||||
}]
|
||||
if {[info exists ::env(QUICKTEST_INCLUDE)]} {
|
||||
set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
|
||||
@@ -986,10 +986,10 @@ test_suite "session_strm" -description {
|
||||
set ::sqlite3session_streams 1
|
||||
}
|
||||
|
||||
test_suite "ota" -description {
|
||||
OTA tests.
|
||||
test_suite "rbu" -description {
|
||||
RBU tests.
|
||||
} -files [
|
||||
test_set [glob -nocomplain $::testdir/../ext/ota/*.test] -exclude ota.test
|
||||
test_set [glob -nocomplain $::testdir/../ext/rbu/*.test] -exclude rbu.test
|
||||
]
|
||||
|
||||
test_suite "no_optimization" -description {
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file runs all rtree related tests.
|
||||
# This file runs all RBU related tests.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/permutations.test
|
||||
|
||||
ifcapable !ota { finish_test ; return }
|
||||
ifcapable !rbu { finish_test ; return }
|
||||
|
||||
run_test_suite ota
|
||||
run_test_suite rbu
|
||||
finish_test
|
||||
|
||||
@@ -116,7 +116,7 @@ array set ::Configs [strip_comments {
|
||||
-DSQLITE_ENABLE_FTS4=1
|
||||
-DSQLITE_ENABLE_RTREE=1
|
||||
-DSQLITE_ENABLE_STAT4
|
||||
-DSQLITE_ENABLE_OTA
|
||||
-DSQLITE_ENABLE_RBU
|
||||
-DSQLITE_MAX_ATTACHED=125
|
||||
}
|
||||
"Device-One" {
|
||||
|
||||
@@ -292,4 +292,34 @@ do_execsql_test skipscan1-7.3 {
|
||||
EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;
|
||||
} {~/ANY/}
|
||||
|
||||
# Ticket 8fd39115d8f46ece70e7d4b3c481d1bd86194746 2015-07-23
|
||||
# Incorrect code generated for a skipscan within an OR optimization
|
||||
# on a WITHOUT ROWID table.
|
||||
#
|
||||
do_execsql_test skipscan1-8.1 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x, y, PRIMARY KEY(x,y)) WITHOUT ROWID;
|
||||
INSERT INTO t1(x,y) VALUES(1,'AB');
|
||||
INSERT INTO t1(x,y) VALUES(2,'CD');
|
||||
ANALYZE;
|
||||
DROP TABLE IF EXISTS sqlite_stat4;
|
||||
DELETE FROM sqlite_stat1;
|
||||
INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1','1000000 100 1');
|
||||
ANALYZE sqlite_master;
|
||||
SELECT * FROM t1
|
||||
WHERE (y = 'AB' AND x <= 4)
|
||||
OR (y = 'EF' AND x = 5);
|
||||
} {1 AB}
|
||||
do_execsql_test skipscan1-8.1eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT * FROM t1
|
||||
WHERE (y = 'AB' AND x <= 4)
|
||||
OR (y = 'EF' AND x = 5);
|
||||
} {/ANY/}
|
||||
do_execsql_test skipscan1-8.2 {
|
||||
SELECT * FROM t1
|
||||
WHERE y = 'AB' OR (y = 'CD' AND x = 2)
|
||||
ORDER BY +x;
|
||||
} {1 AB 2 CD}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -51,8 +51,8 @@ static const char zHelp[] =
|
||||
#if SQLITE_VERSION_NUMBER<3005000
|
||||
# define sqlite3_int64 sqlite_int64
|
||||
#endif
|
||||
#ifdef SQLITE_ENABLE_OTA
|
||||
# include "sqlite3ota.h"
|
||||
#ifdef SQLITE_ENABLE_RBU
|
||||
# include "sqlite3rbu.h"
|
||||
#endif
|
||||
|
||||
/* All global state is held in this structure */
|
||||
@@ -1240,10 +1240,10 @@ int main(int argc, char **argv){
|
||||
noSync = 1;
|
||||
}else if( strcmp(z,"notnull")==0 ){
|
||||
g.zNN = "NOT NULL";
|
||||
#ifdef SQLITE_ENABLE_OTA
|
||||
}else if( strcmp(z,"ota")==0 ){
|
||||
sqlite3ota_create_vfs("ota", 0);
|
||||
sqlite3_vfs_register(sqlite3_vfs_find("ota"), 1);
|
||||
#ifdef SQLITE_ENABLE_RBU
|
||||
}else if( strcmp(z,"rbu")==0 ){
|
||||
sqlite3ota_create_vfs("rbu", 0);
|
||||
sqlite3_vfs_register(sqlite3_vfs_find("rbu"), 1);
|
||||
#endif
|
||||
}else if( strcmp(z,"pagesize")==0 ){
|
||||
if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]);
|
||||
|
||||
Reference in New Issue
Block a user