/ Check-in [b59f7bcb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplify the vdbeHalt logic slightly. (CVS 4459)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b59f7bcbabcccde9d2519e10e65e121343f2af7a
User & Date: drh 2007-10-03 18:45:04
Context
2007-10-03
20:15
Update documentation to talk about the response to errors within an explicit transaction. (CVS 4460) check-in: 84616a13 user: drh tags: trunk
18:45
Simplify the vdbeHalt logic slightly. (CVS 4459) check-in: b59f7bcb user: drh tags: trunk
15:30
Rollback the transaction if an SQLITE_FULL error is encountered. This is a preliminary fix for ticket #2686. More testing and analysis is needed before we close the ticket. (CVS 4458) check-in: 0fb6d5a5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  1394   1394         **
  1395   1395         ** We could do something more elegant than this static analysis (i.e.
  1396   1396         ** store the type of query as part of the compliation phase), but 
  1397   1397         ** handling malloc() or IO failure is a fairly obscure edge case so 
  1398   1398         ** this is probably easier. Todo: Might be an opportunity to reduce 
  1399   1399         ** code size a very small amount though...
  1400   1400         */
  1401         -      int isReadOnly = 1;
         1401  +      int notReadOnly = 0;
  1402   1402         int isStatement = 0;
  1403   1403         assert(p->aOp || p->nOp==0);
  1404   1404         for(i=0; i<p->nOp; i++){ 
  1405   1405           switch( p->aOp[i].opcode ){
  1406   1406             case OP_Transaction:
  1407         -            /* This is a bit strange. If we hit a malloc() or IO error and
  1408         -            ** the statement did not open a statement transaction, we will
  1409         -            ** rollback any active transaction and abort all other active
  1410         -            ** statements. Or, if this is an SQLITE_INTERRUPT error, we
  1411         -            ** will only rollback if the interrupted statement was a write.
  1412         -            **
  1413         -            ** It could be argued that read-only statements should never
  1414         -            ** rollback anything. But careful analysis is required before
  1415         -            ** making this change
  1416         -            */
  1417         -            if( p->aOp[i].p2 || mrc!=SQLITE_INTERRUPT ){
  1418         -              isReadOnly = 0;
  1419         -            }
         1407  +            notReadOnly |= p->aOp[i].p2;
  1420   1408               break;
  1421   1409             case OP_Statement:
  1422   1410               isStatement = 1;
  1423   1411               break;
  1424   1412           }
  1425   1413         }
  1426   1414   
  1427   1415      
  1428   1416         /* If the query was read-only, we need do no rollback at all. Otherwise,
  1429   1417         ** proceed with the special handling.
  1430   1418         */
  1431         -      if( !isReadOnly ){
         1419  +      if( notReadOnly || mrc!=SQLITE_INTERRUPT ){
  1432   1420           if( p->rc==SQLITE_IOERR_BLOCKED && isStatement ){
  1433   1421             xFunc = sqlite3BtreeRollbackStmt;
  1434   1422             p->rc = SQLITE_BUSY;
  1435         -        } else if( (p->rc==SQLITE_NOMEM || p->rc==SQLITE_FULL) && isStatement ){
         1423  +        } else if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && isStatement ){
  1436   1424             xFunc = sqlite3BtreeRollbackStmt;
  1437   1425           }else{
  1438   1426             /* We are forced to roll back the active transaction. Before doing
  1439   1427             ** so, abort any other statements this handle currently has active.
  1440   1428             */
  1441   1429             invalidateCursorsOnModifiedBtrees(db);
  1442   1430             sqlite3RollbackAll(db);