Minor bugfixes for incrblob mode. (CVS 3903)
FossilOrigin-Name: db54a9466e3bea9c03740ce0b755cfa02bafaccd
diff --git a/src/btree.c b/src/btree.c
index 6e59747..4c433a0 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.368 2007/05/02 17:54:56 drh Exp $
+** $Id: btree.c,v 1.369 2007/05/03 11:43:33 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -3105,7 +3105,7 @@
iGuess++;
}
- if( iGuess<sqlite3PagerPagecount(pBt->pPager) ){
+ if( iGuess<=sqlite3PagerPagecount(pBt->pPager) ){
rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
if( rc!=SQLITE_OK ){
return rc;
@@ -5763,6 +5763,19 @@
Pgno pgnoMove; /* Move a page here to make room for the root-page */
MemPage *pPageMove; /* The page to move to. */
+#ifndef SQLITE_OMIT_INCRBLOB
+ /* Creating a new table may probably require moving an existing database
+ ** to make room for the new tables root page. In case this page turns
+ ** out to be an overflow page, delete all overflow page-map caches
+ ** held by open cursors.
+ */
+ BtCursor *pCur;
+ for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
+ sqliteFree(pCur->aOverflow);
+ pCur->aOverflow = 0;
+ }
+#endif
+
/* Read the value of meta[3] from the database to determine where the
** root page of the new table should go. meta[3] is the largest root-page
** created so far, so the new root-page is (meta[3]+1).
@@ -6943,17 +6956,6 @@
*/
int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, const void *z){
BtShared *pBt = pCsr->pBtree->pBt;
- int rc;
-
- u32 iRem = amt; /* Remaining bytes to write */
- u8 *zRem = (u8 *)z; /* Pointer to data not yet written */
- u32 iOffset = offset; /* Offset from traversal point to start of write */
-
- Pgno iIdx = 0; /* Index of overflow page in pCsr->aOverflow */
- Pgno iOvfl; /* Page number for next overflow page */
- int ovflSize; /* Bytes of data per overflow page. */
-
- CellInfo *pInfo;
/* Check some preconditions:
** (a) a write-transaction is open,
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index 711802b..7c55a63 100644
--- a/src/vdbeblob.c
+++ b/src/vdbeblob.c
@@ -10,7 +10,7 @@
**
*************************************************************************
**
-** $Id: vdbeblob.c,v 1.2 2007/05/02 16:48:37 danielk1977 Exp $
+** $Id: vdbeblob.c,v 1.3 2007/05/03 11:43:33 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -91,11 +91,17 @@
memset(&sParse, 0, sizeof(Parse));
sParse.db = db;
+ rc = sqlite3SafetyOn(db);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
+
pTab = sqlite3LocateTable(&sParse, zTable, zDb);
if( !pTab ){
sqlite3Error(db, sParse.rc, "%s", sParse.zErrMsg);
sqliteFree(sParse.zErrMsg);
rc = sParse.rc;
+ sqlite3SafetyOff(db);
goto blob_open_out;
}
@@ -109,6 +115,7 @@
sqlite3Error(db, SQLITE_ERROR, "no such column: %s", zColumn);
sqliteFree(sParse.zErrMsg);
rc = SQLITE_ERROR;
+ sqlite3SafetyOff(db);
goto blob_open_out;
}
@@ -145,6 +152,11 @@
sqlite3VdbeMakeReady(v, 1, 0, 1, 0);
}
+ rc = sqlite3SafetyOff(db);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
+
sqlite3_bind_int64((sqlite3_stmt *)v, 1, iRow);
rc = sqlite3_step((sqlite3_stmt *)v);
if( rc!=SQLITE_ROW ){