Compare commits

...

2 Commits

Author SHA1 Message Date
drh caa6b01b5c Clarify the expectations for the behavior of the xFetch method on the
sqlite3_pcache_methods object for the case when the key is zero.

FossilOrigin-Name: b0810ac1b22226a0ffcf73868779d7e98b5d8263
2016-12-30 13:55:50 +00:00
drh 97d5173efe Improved detection of zero page numbers in the page cache.
FossilOrigin-Name: 5550e815dd943b15c3b08f0526280bba76976199
2016-12-30 13:40:41 +00:00
5 changed files with 25 additions and 19 deletions
+8 -8
View File
@@ -1,5 +1,5 @@
C Fix\sa\sharmless\scompiler\swarning\sin\sfuzzcheck.c
D 2016-12-30T12:10:48.960
C Clarify\sthe\sexpectations\sfor\sthe\sbehavior\sof\sthe\sxFetch\smethod\son\sthe\nsqlite3_pcache_methods\sobject\sfor\sthe\scase\swhen\sthe\skey\sis\szero.
D 2016-12-30T13:55:50.562
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
@@ -375,12 +375,12 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820
F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c 1c7a2b82b290b85b90f9275ae003f688935f70f9
F src/pager.c 71881289acefc52888c781cc1d3ea659c311a5da
F src/pager.h d1e944291030351f362a0a7da9b5c3e34e603e39
F src/parse.y 29153738a7322054359320eb00b5a4cd44389f20
F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e
F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490
F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953
F src/pcache1.c 26a72c84d7ed96d85da7910194d01da9777a3335
F src/pragma.c 5a23557e490e7ac5afef097efc4b59dce5b482c2
F src/pragma.h f9b221b2c8949ea941dbee49934299e4ed5af41c
F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a
@@ -390,7 +390,7 @@ F src/resolve.c bb070cf5f23611c44ab7e4788803684e385fc3fb
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c dfb6cadc3dcfba1b1bdbfba62ebba2b4b673413e
F src/shell.c 6095531aa900decdaa765e0f3993fba7153c92c1
F src/sqlite.h.in e8e2d108d82647f0a812fdb74accf91c1ec08ddc
F src/sqlite.h.in c50b91a917b5a78469e0910a539cf84087ba821e
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
F src/sqliteInt.h 2075e22d50833ca2d9956d0b7a6bfb845ad05dd2
@@ -1540,7 +1540,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 3e25ba6e42fba239795a465b8510386a361ee5be
R cb43d33d19adf32bebd1dfaa0e0b456a
P 5550e815dd943b15c3b08f0526280bba76976199
R 40395c430e6a26d64841635be7560ef8
U drh
Z 067d360edde333b631fbf0df03bf7c2e
Z b0285f49e100b02afd5ae0bacab221f8
+1 -1
View File
@@ -1 +1 @@
2842bc60538369f888c7df8365858c910322277d
b0810ac1b22226a0ffcf73868779d7e98b5d8263
+9 -5
View File
@@ -5376,7 +5376,11 @@ static int getPageNormal(
pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
if( pBase==0 ){
pPg = 0;
rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
if( pgno==0 ){
rc = SQLITE_CORRUPT_BKPT;
}else{
rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
}
if( rc!=SQLITE_OK ) goto pager_acquire_err;
if( pBase==0 ){
rc = SQLITE_NOMEM_BKPT;
@@ -5400,11 +5404,11 @@ static int getPageNormal(
/* The pager cache has created a new page. Its content needs to
** be initialized. But first some error checks:
**
** (1) Minimum page number is 1
** (2) The maximum page number is 2^31
** (3) Never try to fetch the locking page
** (1) The maximum page number is 2^31
** (2) Never try to fetch the locking page
*/
if( pgno==0 || pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){
assert( pgno>0 );
if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){
rc = SQLITE_CORRUPT_BKPT;
goto pager_acquire_err;
}
+1 -1
View File
@@ -997,7 +997,7 @@ static PgHdr1 *pcache1FetchNoMutex(
}else{
return pPage;
}
}else if( createFlag ){
}else if( createFlag && iKey ){
/* Steps 3, 4, and 5 implemented by this subroutine */
return pcache1FetchStage2(pCache, iKey, createFlag);
}else{
+6 -4
View File
@@ -7215,7 +7215,8 @@ struct sqlite3_pcache_page {
** for each entry in the page cache.
**
** The page to be fetched is determined by the key. ^The minimum key value
** is 1. After it has been retrieved using xFetch, the page is considered
** is 1. The xFetch() method must return NULL if passed a key of 0.
** After it has been retrieved using xFetch, the page is considered
** to be "pinned".
**
** If the requested page is already in the page cache, then the page cache
@@ -7227,10 +7228,11 @@ struct sqlite3_pcache_page {
** <table border=1 width=85% align=center>
** <tr><th> createFlag <th> Behavior when page is not already in cache
** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
** Otherwise return NULL.
** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so
** and the key is not zero. Otherwise return NULL.
** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
** NULL if allocating a new page is effectively impossible.
** NULL if the key is zero or if allocating a new page is
** effectively impossible.
** </table>
**
** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite