From: dan Date: Sat, 8 Oct 2011 14:57:07 +0000 (+0000) Subject: Add the SQLITE_DIRECT_OVERFLOW_READ compile time option. X-Git-Tag: version-3.7.9~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4ba1093568851a1320a84ce195b1dc08e8964c1;p=thirdparty%2Fsqlite.git Add the SQLITE_DIRECT_OVERFLOW_READ compile time option. FossilOrigin-Name: 2ab14a846727857175eac7961b7338c4d3b417ca --- diff --git a/manifest b/manifest index 7f9710268d..b38c1ac5fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sANALYZE\scommand\sso\sthat\sit\sno\slonger\stried\sto\sdelete\sunused\nsqlite_stat2\sand\ssqlite_stat3\stables.\s\sChange\sthe\sDROP\sTABLE\scommand\sso\nthat\sit\sis\sable\sto\sdrop\sthose\stables. -D 2011-10-07T23:52:25.818 +C Add\sthe\sSQLITE_DIRECT_OVERFLOW_READ\scompile\stime\soption. +D 2011-10-08T14:57:07.518 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 4fd4440c8f81339d8eb8e5d2df54b68d79e94f2f F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 77b09c69d4849a90361e6fe5db36d167f20600c0 +F src/btree.c b53e009bccb4cfcbcde074f586f0c1c6712a0e12 F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 F src/build.c 119937b0ae1ff4dcec8fdea53771acc95bafca51 @@ -201,7 +201,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c 6b1b69da02eb9a19330d8c2c33403c6eafbc3416 +F src/test_config.c baf4eda361adc7444bd452d352999fea351fe256 F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5 @@ -335,7 +335,7 @@ F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test cabc41f7616675df71b4fddabca3bd5d9221915a F test/corrupt.test 4aabd06cff3fe759e3e658bcc17b71789710665e F test/corrupt2.test 9c0ab4becd50e9050bc1ebb8675456a4e5587bf0 -F test/corrupt3.test e3006aaf579d2ed7f1b94bf4cc695d3c784fa5af +F test/corrupt3.test 889d7cdb811800303aa722d7813fe8a4299cf726 F test/corrupt4.test b963f9e01e0f92d15c76fb0747876fd4b96dc30a F test/corrupt5.test c23da7bfb20917cc7fdbb13ee25c7cc4e9fffeff F test/corrupt6.test 4e4161aef1f30b9f34582bb4142334b7f47eacae @@ -611,13 +611,13 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test c8f202a460ba6a1cd7a36888042ca471220bb42d +F test/pager1.test 1b630b3248c7d28862fe9e190cfe52234b502504 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 F test/pagerfault2.test 1f79ea40d1133b2683a2f811b00f2399f7ec2401 F test/pagerfault3.test f16e2efcb5fc9996d1356f7cbc44c998318ae1d7 -F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 +F test/pageropt.test 9191867ed19a2b3db6c42d1b36b6fbc657cd1ab0 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d4f95b3b6e9f4a4072606af5daa17ea7c645382e -R 4fe120270d0591d545e8a0d8aa07746c -U drh -Z 90bf796c032cc3a71272ed4f53de20b0 +P 589f3f5652e3674d3203f8bd32784a46b5ed530c +R babeecaade74546f993a47787aab0e8e +U dan +Z de8a70093b027b61b524c5ce14f74c38 diff --git a/manifest.uuid b/manifest.uuid index 0be934d7e1..a11f91efcc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -589f3f5652e3674d3203f8bd32784a46b5ed530c \ No newline at end of file +2ab14a846727857175eac7961b7338c4d3b417ca \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7e6e02f144..72d61cc268 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3938,21 +3938,55 @@ static int accessPayload( /* Need to read this page properly. It contains some of the ** range of data that is being read (eOp==0) or written (eOp!=0). */ - DbPage *pDbPage; +#ifdef SQLITE_DIRECT_OVERFLOW_READ + sqlite3_file *fd; +#endif int a = amt; - rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage); - if( rc==SQLITE_OK ){ - aPayload = sqlite3PagerGetData(pDbPage); - nextPage = get4byte(aPayload); - if( a + offset > ovflSize ){ - a = ovflSize - offset; + if( a + offset > ovflSize ){ + a = ovflSize - offset; + } + +#ifdef SQLITE_DIRECT_OVERFLOW_READ + /* If all the following are true: + ** + ** 1) this is a read operation, and + ** 2) data is required from the start of this overflow page, and + ** 3) the database is file-backed, and + ** 4) there is no open write-transaction, and + ** 5) the database is not a WAL database, + ** + ** then data can be read directly from the database file into the + ** output buffer, bypassing the page-cache altogether. This speeds + ** up loading large records that span many overflow pages. + */ + if( eOp==0 /* (1) */ + && offset==0 /* (2) */ + && pBt->inTransaction==TRANS_READ /* (4) */ + && (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */ + && pBt->pPage1->aData[19]==0x01 /* (5) */ + ){ + u8 aSave[4]; + u8 *aWrite = &pBuf[-4]; + memcpy(aSave, aWrite, 4); + rc = sqlite3OsRead(fd, aWrite, a+4, pBt->pageSize * (nextPage-1)); + nextPage = get4byte(aWrite); + memcpy(aWrite, aSave, 4); + }else +#endif + + { + DbPage *pDbPage; + rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage); + if( rc==SQLITE_OK ){ + aPayload = sqlite3PagerGetData(pDbPage); + nextPage = get4byte(aPayload); + rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage); + sqlite3PagerUnref(pDbPage); + offset = 0; } - rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage); - sqlite3PagerUnref(pDbPage); - offset = 0; - amt -= a; - pBuf += a; } + amt -= a; + pBuf += a; } } } diff --git a/src/test_config.c b/src/test_config.c index 4c4dfa3d80..b0efe23247 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -55,6 +55,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "debug", "0", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_DIRECT_OVERFLOW_READ + Tcl_SetVar2(interp, "sqlite_options", "direct_read", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "direct_read", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_DISABLE_DIRSYNC Tcl_SetVar2(interp, "sqlite_options", "dirsync", "0", TCL_GLOBAL_ONLY); #else diff --git a/test/corrupt3.test b/test/corrupt3.test index fba3ba791a..a3827227b7 100644 --- a/test/corrupt3.test +++ b/test/corrupt3.test @@ -25,7 +25,7 @@ do_not_use_codec # We must have the page_size pragma for these tests to work. # -ifcapable !pager_pragmas { +ifcapable !pager_pragmas||direct_read { finish_test return } diff --git a/test/pager1.test b/test/pager1.test index bed7d736cd..0226fe49b2 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -1766,6 +1766,10 @@ do_multiclient_test tn { # + Page 0, # + A page with a page number greater than (2^31-1). # +# These tests will not work if SQLITE_DIRECT_OVERFLOW_READ is defined. In +# that case IO errors are sometimes reported instead of SQLITE_CORRUPT. +# +ifcapable !direct_read { do_test pager1-18.1 { faultsim_delete_and_reopen db func a_string a_string @@ -1841,6 +1845,7 @@ do_test pager1-18.6 { sqlite3 db test.db catchsql { SELECT length(x) FROM t1 } } {1 {database disk image is malformed}} +} do_test pager1-19.1 { sqlite3 db "" diff --git a/test/pageropt.test b/test/pageropt.test index 1c634f6443..82311965a5 100644 --- a/test/pageropt.test +++ b/test/pageropt.test @@ -17,7 +17,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -ifcapable {!pager_pragmas||secure_delete} { +ifcapable {!pager_pragmas||secure_delete||direct_read} { finish_test return }