1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix error handling in sqlite3BtreePutData(). (CVS 6860)

FossilOrigin-Name: 86eba4f16fd9e97344ab6dfb9cb9a85cf14751dd
This commit is contained in:
danielk1977
2009-07-08 13:55:28 +00:00
parent ecaecf929e
commit c9000e60c6
3 changed files with 20 additions and 19 deletions

View File

@@ -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) C Fix\serror\shandling\sin\ssqlite3BtreePutData().\s(CVS\s6860)
D 2009-07-08T08:05:35 D 2009-07-08T13:55:29
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -106,7 +106,7 @@ F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025
F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
F src/btree.c 2fd0b5cc756b845e5a031d505862eee80b272999 F src/btree.c 62fc49f212276891085693c47eb6c3dc0fb1b197
F src/btree.h e761619e76a1125d2d82bd3613b5a7ac7d1ee6f7 F src/btree.h e761619e76a1125d2d82bd3613b5a7ac7d1ee6f7
F src/btreeInt.h b31e5ac04181c7e2892c33ab06228c551df6233c F src/btreeInt.h b31e5ac04181c7e2892c33ab06228c551df6233c
F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4 F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
P aab82a229a984bdd37bda2d140cf4279ab54a741 P 0cc705c2c4aa06c33361b11c06423ff76d9eed7c
R 1fd66cc88fe52a3982261fa55b4a3040 R 1e0967d46dedb8b1441a379004f1ea6c
U danielk1977 U danielk1977
Z 2f4cd8c2f9ff3468dfd44c1b50f9ed4f Z 29cd6f499d3f0d09a4b738ba4390c723

View File

@@ -1 +1 @@
0cc705c2c4aa06c33361b11c06423ff76d9eed7c 86eba4f16fd9e97344ab6dfb9cb9a85cf14751dd

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give. ** 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. ** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information. ** 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. ** no modifications are made and SQLITE_CORRUPT is returned.
*/ */
int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){ int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){
int rc;
assert( cursorHoldsMutex(pCsr) ); assert( cursorHoldsMutex(pCsr) );
assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) ); assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) );
assert( pCsr->isIncrblobHandle ); assert( pCsr->isIncrblobHandle );
restoreCursorPosition(pCsr); rc = restoreCursorPosition(pCsr);
if( rc!=SQLITE_OK ){
return rc;
}
assert( pCsr->eState!=CURSOR_REQUIRESEEK ); assert( pCsr->eState!=CURSOR_REQUIRESEEK );
if( pCsr->eState!=CURSOR_VALID ){ if( pCsr->eState!=CURSOR_VALID ){
return SQLITE_ABORT; return SQLITE_ABORT;
} }
/* Check some preconditions: /* Check some assumptions:
** (a) the cursor is open for writing, ** (a) the cursor is open for writing,
** (b) there is no read-lock on the table being modified and ** (b) there is a read/write transaction open,
** (c) the cursor points at a valid row of an intKey table. ** (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 ){ assert( pCsr->wrFlag );
return SQLITE_READONLY;
}
assert( !pCsr->pBt->readOnly && pCsr->pBt->inTransaction==TRANS_WRITE ); assert( !pCsr->pBt->readOnly && pCsr->pBt->inTransaction==TRANS_WRITE );
assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) ); assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) );
assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) ); assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) );
assert( pCsr->apPage[pCsr->iPage]->intKey );
if( pCsr->eState==CURSOR_INVALID || !pCsr->apPage[pCsr->iPage]->intKey ){
return SQLITE_ERROR;
}
return accessPayload(pCsr, offset, amt, (unsigned char *)z, 0, 1); return accessPayload(pCsr, offset, amt, (unsigned char *)z, 0, 1);
} }