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:
25
src/btree.c
25
src/btree.c
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user