/ Check-in [e80b2d9f]
Login

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

Overview
Comment:Improved comments and extra assert() statements on the OP_Savepoint opcode, just to make the code a little easier to read and reason about.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e80b2d9fcbc82ae5dc8a1fc13196f9a30bdb504eb5a5c131d136a78bbd5bbe7b
User & Date: drh 2019-05-10 14:03:07
Context
2019-05-10
14:26
Treat integer values in window definition ORDER BY clauses as constants, not as references to another expression. check-in: 7e4809ea user: dan tags: trunk
14:03
Improved comments and extra assert() statements on the OP_Savepoint opcode, just to make the code a little easier to read and reason about. check-in: e80b2d9f user: drh tags: trunk
12:14
Fix the previous check-in [db9acef14d492121] so that the amalgamation build works for systems for which lack HAVE_ISNAN. check-in: 3cc55e09 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  3026   3026     break;
  3027   3027   }
  3028   3028   #endif
  3029   3029   
  3030   3030   /* Opcode: Savepoint P1 * * P4 *
  3031   3031   **
  3032   3032   ** Open, release or rollback the savepoint named by parameter P4, depending
  3033         -** on the value of P1. To open a new savepoint, P1==0. To release (commit) an
  3034         -** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.
         3033  +** on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN).
         3034  +** To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE).
         3035  +** To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK).
  3035   3036   */
  3036   3037   case OP_Savepoint: {
  3037   3038     int p1;                         /* Value of P1 operand */
  3038   3039     char *zName;                    /* Name of savepoint */
  3039   3040     int nName;
  3040   3041     Savepoint *pNew;
  3041   3042     Savepoint *pSavepoint;
................................................................................
  3095   3096           pNew->pNext = db->pSavepoint;
  3096   3097           db->pSavepoint = pNew;
  3097   3098           pNew->nDeferredCons = db->nDeferredCons;
  3098   3099           pNew->nDeferredImmCons = db->nDeferredImmCons;
  3099   3100         }
  3100   3101       }
  3101   3102     }else{
         3103  +    assert( p1==SAVEPOINT_RELEASE || p1==SAVEPOINT_ROLLBACK );
  3102   3104       iSavepoint = 0;
  3103   3105   
  3104   3106       /* Find the named savepoint. If there is no such savepoint, then an
  3105   3107       ** an error is returned to the user.  */
  3106   3108       for(
  3107   3109         pSavepoint = db->pSavepoint; 
  3108   3110         pSavepoint && sqlite3StrICmp(pSavepoint->zName, zName);
................................................................................
  3148   3150             for(ii=0; ii<db->nDb; ii++){
  3149   3151               rc = sqlite3BtreeTripAllCursors(db->aDb[ii].pBt,
  3150   3152                                          SQLITE_ABORT_ROLLBACK,
  3151   3153                                          isSchemaChange==0);
  3152   3154               if( rc!=SQLITE_OK ) goto abort_due_to_error;
  3153   3155             }
  3154   3156           }else{
         3157  +          assert( p1==SAVEPOINT_RELEASE );
  3155   3158             isSchemaChange = 0;
  3156   3159           }
  3157   3160           for(ii=0; ii<db->nDb; ii++){
  3158   3161             rc = sqlite3BtreeSavepoint(db->aDb[ii].pBt, p1, iSavepoint);
  3159   3162             if( rc!=SQLITE_OK ){
  3160   3163               goto abort_due_to_error;
  3161   3164             }
................................................................................
  3184   3187           assert( pSavepoint==db->pSavepoint );
  3185   3188           db->pSavepoint = pSavepoint->pNext;
  3186   3189           sqlite3DbFree(db, pSavepoint);
  3187   3190           if( !isTransaction ){
  3188   3191             db->nSavepoint--;
  3189   3192           }
  3190   3193         }else{
         3194  +        assert( p1==SAVEPOINT_ROLLBACK );
  3191   3195           db->nDeferredCons = pSavepoint->nDeferredCons;
  3192   3196           db->nDeferredImmCons = pSavepoint->nDeferredImmCons;
  3193   3197         }
  3194   3198   
  3195   3199         if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){
  3196   3200           rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
  3197   3201           if( rc!=SQLITE_OK ) goto abort_due_to_error;