aboutsummaryrefslogtreecommitdiff
path: root/src/vdbeaux.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-10-14 13:41:32 +0000
committerdrh <drh@noemail.net>2014-10-14 13:41:32 +0000
commit92fe38ece56c01929b8ad949c94a8b7732db496c (patch)
tree14273daa821b50e1da797883ca36de3a78329512 /src/vdbeaux.c
parent78aad7cd1d026afa649460cf0ed6508c3d88a16e (diff)
parent8dd8362d6446e8d83fd621122987f048216197c2 (diff)
downloadsqlite-92fe38ece56c01929b8ad949c94a8b7732db496c.tar.gz
sqlite-92fe38ece56c01929b8ad949c94a8b7732db496c.zip
Merge recent trunk micro-optimizations and the DESC index GROUP BY ORDER BY
bug fix into the sessions branch. FossilOrigin-Name: 83d4114f2aa404e670ced33511183baacd813a01
Diffstat (limited to 'src/vdbeaux.c')
-rw-r--r--src/vdbeaux.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 33f17c7fd..876e525eb 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -1746,7 +1746,7 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
sqlite3BtreeCloseCursor(pCx->pCursor);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
- if( pCx->pVtabCursor ){
+ else if( pCx->pVtabCursor ){
sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor;
const sqlite3_module *pModule = pVtabCursor->pVtab->pModule;
p->inVtabMethod = 1;
@@ -1789,9 +1789,10 @@ static void closeAllCursors(Vdbe *p){
VdbeFrame *pFrame;
for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);
sqlite3VdbeFrameRestore(pFrame);
+ p->pFrame = 0;
+ p->nFrame = 0;
}
- p->pFrame = 0;
- p->nFrame = 0;
+ assert( p->nFrame==0 );
if( p->apCsr ){
int i;
@@ -1813,7 +1814,7 @@ static void closeAllCursors(Vdbe *p){
}
/* Delete any auxdata allocations made by the VM */
- sqlite3VdbeDeleteAuxData(p, -1, 0);
+ if( p->pAuxData ) sqlite3VdbeDeleteAuxData(p, -1, 0);
assert( p->pAuxData==0 );
}
@@ -2719,9 +2720,7 @@ static int SQLITE_NOINLINE handleDeferredMoveto(VdbeCursor *p){
assert( p->isTable );
rc = sqlite3BtreeMovetoUnpacked(p->pCursor, 0, p->movetoTarget, 0, &res);
if( rc ) return rc;
- p->lastRowid = p->movetoTarget;
if( res!=0 ) return SQLITE_CORRUPT_BKPT;
- p->rowidIsValid = 1;
#ifdef SQLITE_TEST
sqlite3_search_count++;
#endif
@@ -2748,6 +2747,17 @@ static int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){
}
/*
+** Check to ensure that the cursor is valid. Restore the cursor
+** if need be. Return any I/O error from the restore operation.
+*/
+int sqlite3VdbeCursorRestore(VdbeCursor *p){
+ if( sqlite3BtreeCursorHasMoved(p->pCursor) ){
+ return handleMovedCursor(p);
+ }
+ return SQLITE_OK;
+}
+
+/*
** Make sure the cursor p is ready to read or write the row to which it
** was last positioned. Return an error code if an OOM fault or I/O error
** prevents us from positioning the cursor to its correct position.
@@ -2764,7 +2774,7 @@ int sqlite3VdbeCursorMoveto(VdbeCursor *p){
if( p->deferredMoveto ){
return handleDeferredMoveto(p);
}
- if( sqlite3BtreeCursorHasMoved(p->pCursor) ){
+ if( p->pCursor && sqlite3BtreeCursorHasMoved(p->pCursor) ){
return handleMovedCursor(p);
}
return SQLITE_OK;