]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix error handling in sqlite3BtreePutData(). (CVS 6860)
authordanielk1977 <danielk1977@noemail.net>
Wed, 8 Jul 2009 13:55:28 +0000 (13:55 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 8 Jul 2009 13:55:28 +0000 (13:55 +0000)
FossilOrigin-Name: 86eba4f16fd9e97344ab6dfb9cb9a85cf14751dd

manifest
manifest.uuid
src/btree.c

index b4e613b36d80100d8c053d8a6baef70ad5aee573..b9255ddfc0b68eee3f5de653fbe3d045143a94c8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sALWAYS\sclause\sthat\scould\sbe\sfalse\sif\san\sIO\serror\swithin\sa\sstatement\sexecuted\sby\sa\svirtual\stable\scaused\san\semergency\srollback.\s(CVS\s6859)
-D 2009-07-08T08:05:35
+C Fix\serror\shandling\sin\ssqlite3BtreePutData().\s(CVS\s6860)
+D 2009-07-08T13:55:29
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -106,7 +106,7 @@ F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025
 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
 F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
-F src/btree.c 2fd0b5cc756b845e5a031d505862eee80b272999
+F src/btree.c 62fc49f212276891085693c47eb6c3dc0fb1b197
 F src/btree.h e761619e76a1125d2d82bd3613b5a7ac7d1ee6f7
 F src/btreeInt.h b31e5ac04181c7e2892c33ab06228c551df6233c
 F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P aab82a229a984bdd37bda2d140cf4279ab54a741
-R 1fd66cc88fe52a3982261fa55b4a3040
+P 0cc705c2c4aa06c33361b11c06423ff76d9eed7c
+R 1e0967d46dedb8b1441a379004f1ea6c
 U danielk1977
-Z 2f4cd8c2f9ff3468dfd44c1b50f9ed4f
+Z 29cd6f499d3f0d09a4b738ba4390c723
index 5cd7d19160c194a30d8c4e7412abc13ceed6d3fe..c7804502c7d11887714edb231e4aed79ca735b7a 100644 (file)
@@ -1 +1 @@
-0cc705c2c4aa06c33361b11c06423ff76d9eed7c
\ No newline at end of file
+86eba4f16fd9e97344ab6dfb9cb9a85cf14751dd
\ No newline at end of file
index 905ee428f498f9422669df8dc536eaaf6b591c9b..818eb7033a1760816cbec5be6e4b6d3fd2698747 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.659 2009/07/08 08:05:35 danielk1977 Exp $
+** $Id: btree.c,v 1.660 2009/07/08 13:55:29 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -7724,31 +7724,32 @@ int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){
 ** no modifications are made and SQLITE_CORRUPT is returned.
 */
 int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){
+  int rc;
   assert( cursorHoldsMutex(pCsr) );
   assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) );
   assert( pCsr->isIncrblobHandle );
 
-  restoreCursorPosition(pCsr);
+  rc = restoreCursorPosition(pCsr);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
   assert( pCsr->eState!=CURSOR_REQUIRESEEK );
   if( pCsr->eState!=CURSOR_VALID ){
     return SQLITE_ABORT;
   }
 
-  /* Check some preconditions: 
+  /* Check some assumptions: 
   **   (a) the cursor is open for writing,
-  **   (b) there is no read-lock on the table being modified and
-  **   (c) the cursor points at a valid row of an intKey table.
+  **   (b) there is a read/write transaction open,
+  **   (c) the connection holds a write-lock on the table (if required),
+  **   (d) there are no conflicting read-locks, and
+  **   (e) the cursor points at a valid row of an intKey table.
   */
-  if( !pCsr->wrFlag ){
-    return SQLITE_READONLY;
-  }
+  assert( pCsr->wrFlag );
   assert( !pCsr->pBt->readOnly && pCsr->pBt->inTransaction==TRANS_WRITE );
   assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) );
   assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) );
-
-  if( pCsr->eState==CURSOR_INVALID || !pCsr->apPage[pCsr->iPage]->intKey ){
-    return SQLITE_ERROR;
-  }
+  assert( pCsr->apPage[pCsr->iPage]->intKey );
 
   return accessPayload(pCsr, offset, amt, (unsigned char *)z, 0, 1);
 }