-C Fix\sa\sproblem\sin\sthe\scode\sgenerator\sfor\sjoins\son\svirtual\stables\swhere\sthe\nouter\sloop\sof\sthe\sjoin\suses\sthe\sIN\soperator.
-D 2016-04-18T16:12:04.978
+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-18T16:18:13.574
F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc b00bcf0ec7001857aea81ee39fae45d20f5f4e59
F src/vdbeaux.c c8dd3e4e932bede6363b380519d05c0557ad27ce
F src/vdbeblob.c 3b570b730109e8f653d9d2081649f6e7015113db
F src/vdbemem.c fe76c1f866de362d9b8332e59d74aa44f6560d69
-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 368e86c760477f2e646f71f6135b69d40eeb82e7
-Q +6c56b3a04778bc62ca50307ad838dd301cd91ac2
-R acf6a347f3f839bd74b9fc7a6f34fbf3
+P a2cf49689642c2157288829e96c21c0de83e3a1b
+Q +79147dca87cfd7eb62d57baa3b70fa2a8542232a
+R 104c6fbe1d009b71ad568ed52ec9c95a
U drh
-Z 542d8ddb7626d61cadebfc7721d64c25
+Z 3cb8bbd587ad296a28a8ae5fa5124a04
-a2cf49689642c2157288829e96c21c0de83e3a1b
\ No newline at end of file
+39dd67afa508aea8f41387806b263b760512377f
\ 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
+