aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c28
-rw-r--r--src/vdbeblob.c14
2 files changed, 28 insertions, 14 deletions
diff --git a/src/btree.c b/src/btree.c
index 6e5974778..4c433a085 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 @@ static int getOverflowPage(
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 @@ int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
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 sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){
*/
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 711802b9f..7c55a635b 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 @@ int sqlite3_blob_open(
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 @@ int sqlite3_blob_open(
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 @@ int sqlite3_blob_open(
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 ){