-C Add\ssome\smissing\stestcase()\smacros\sto\sthe\spushDownWhereTerms()\sroutine.
-D 2016-04-14T15:38:33.232
+C Correctly\sinterpret\snegative\s"PRAGMA\scache_size"\svalues\swhen\sdetermining\sthe\scache-size\sused\sfor\ssorting\slarge\samounts\sof\sdata\s(i.e.\sthe\sfunctionality\sin\svdbesort.c).
+D 2016-04-14T15:44:37.886
F Makefile.in eba680121821b8a60940a81454316f47a341487a
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836
F src/vdbeaux.c ace1875da40b7185e604586768d5ac90de7e4f7f
F src/vdbeblob.c c9f2f494b911c6fa34efd9803f0a10807da80f77
F src/vdbemem.c 5cfef60e60e19cab6275d1b975bf4c791d575beb
-F src/vdbesort.c 307460bfa4de4d1c3901fcd42089159131e34062
+F src/vdbesort.c 0a8f98366ae794442e6d1ef71d9553226d885d19
F src/vdbetrace.c f75c5455d8cf389ef86a8bfdfd3177e0e3692484
F src/vtab.c 23b6cdfa996152d43b390504ed4a942c8caf3a00
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F test/sort2.test cc23b7c19d684657559e8a55b02f7fcee03851d0
F test/sort3.test 1480ed7c4c157682542224e05e3b75faf4a149e5
F test/sort4.test 5c34d9623a4ae5921d956dfa2b70e77ed0fc6e5c
-F test/sort5.test d3041ce3c475aa04142a959ae56ef6593f98a99f
+F test/sort5.test e47ec7a490b9b36787755874175d8f413a3883d9
F test/sortfault.test d4ccf606a0c77498e2beb542764fd9394acb4d66
F test/speed1.test f2974a91d79f58507ada01864c0e323093065452
F test/speed1p.explain d841e650a04728b39e6740296b852dccdca9b2cb
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 5317961411695e107e8cefdeaba62280429979ca
-R 57400ecb51ad9ca239da236d61c38933
-U drh
-Z b18926ac3da54e5d3b9c23fea213722b
+P 67d7f79c5e5be41a18817c802b5c4d349e3a83a4
+R 7d2f177c9a481d6a3916beb1fe8bc290
+U dan
+Z 2305c008703672127d77c74ca18473e8
-67d7f79c5e5be41a18817c802b5c4d349e3a83a4
\ No newline at end of file
+79147dca87cfd7eb62d57baa3b70fa2a8542232a
\ No newline at end of file
){
int pgsz; /* Page size of main database */
int i; /* Used to iterate through aTask[] */
- int mxCache; /* Cache size */
VdbeSorter *pSorter; /* The new sorter */
KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */
int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */
}
if( !sqlite3TempInMemory(db) ){
+ i64 mxCache; /* Cache size in bytes*/
u32 szPma = sqlite3GlobalConfig.szPma;
pSorter->mnPmaSize = szPma * pgsz;
+
mxCache = db->aDb[0].pSchema->cache_size;
- if( mxCache<(int)szPma ) mxCache = (int)szPma;
- pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_PMASZ);
+ if( mxCache<0 ){
+ /* A negative cache-size value C indicates that the cache is abs(C)
+ ** KiB in size. */
+ mxCache = mxCache * -1024;
+ }else{
+ mxCache = mxCache * pgsz;
+ }
+ mxCache = MIN(mxCache, SQLITE_MAX_PMASZ);
+ pSorter->mxPmaSize = MAX(pSorter->mnPmaSize, (int)mxCache);
/* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
db close
tvfs delete
+
+#-------------------------------------------------------------------------
+# Test that the PMA size is determined correctly. The PMA size should be
+# roughly the same amount of memory allocated to the main pager cache, or
+# 250 pages if this is larger.
+#
+testvfs tvfs
+tvfs script tv_callback
+tvfs filter {xOpen xWrite}
+
+proc tv_callback {method args} {
+ global iTemp
+ global F
+ switch $method {
+ xOpen {
+ if {[lindex $args 0]==""} { return "temp[incr iTemp]" }
+ return "SQLITE_OK"
+ }
+
+ xWrite {
+ foreach {filename id off amt} $args {}
+ if {[info exists F($id)]==0 || $F($id)<($off + $amt)} {
+ set F($id) [expr $off+$amt]
+ }
+ }
+ }
+}
+
+catch { db close }
+forcedelete test.db
+sqlite3 db test.db -vfs tvfs
+execsql { CREATE TABLE t1(x) }
+
+# Each iteration of the following loop attempts to sort 10001 records
+# each a bit over 100 bytes in size. In total a little more than 1MiB
+# of data.
+#
+breakpoint
+foreach {tn pgsz cachesz bTemp} {
+ 2 1024 1000 1
+
+ 1 4096 1000 0
+ 2 1024 1000 1
+
+ 3 4096 -1000 1
+ 4 1024 -1000 1
+
+ 5 4096 -9000 0
+ 6 1024 -9000 0
+} {
+ do_execsql_test 2.$tn.0 "
+ PRAGMA page_size = $pgsz;
+ VACUUM;
+ PRAGMA cache_size = $cachesz;
+ "
+
+ do_test 2.$tn.1 {
+ set ::iTemp 0
+ catch { array unset F }
+ execsql {
+ WITH x(i, j) AS (
+ SELECT 1, randomblob(100)
+ UNION ALL
+ SELECT i+1, randomblob(100) FROM x WHERE i<10000
+ )
+ SELECT * FROM x ORDER BY j;
+ }
+ expr {[array names F]!=""}
+ } $bTemp
+}
+
finish_test
+