/ Check-in [d80077ae]
Login

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

Overview
Comment:Another minor optimization to OP_Transaction.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d80077aee3904e5d93164b342cae14d813de8e84e567462412751e06c7487d41
User & Date: drh 2018-06-06 17:45:51
Context
2018-06-06
18:50
Fix the sqlite3BeginTrans() calls within the snapshot extension. check-in: 1fef7ad2 user: drh tags: trunk
17:45
Another minor optimization to OP_Transaction. check-in: d80077ae user: drh tags: trunk
16:28
Change sqlite3BtreeBeginTrans() to return the BTREE_SCHEMA_COOKIE, for a small speed improvement when starting new transactions. check-in: a10662aa user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  3199   3199   ** generation counter, then an SQLITE_SCHEMA error is raised and execution
  3200   3200   ** halts.  The sqlite3_step() wrapper function might then reprepare the
  3201   3201   ** statement and rerun it from the beginning.
  3202   3202   */
  3203   3203   case OP_Transaction: {
  3204   3204     Btree *pBt;
  3205   3205     int iMeta = 0;
  3206         -  int iGen = 0;
  3207   3206   
  3208   3207     assert( p->bIsReader );
  3209   3208     assert( p->readOnly==0 || pOp->p2==0 );
  3210   3209     assert( pOp->p1>=0 && pOp->p1<db->nDb );
  3211   3210     assert( DbMaskTest(p->btreeMask, pOp->p1) );
  3212   3211     if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){
  3213   3212       rc = SQLITE_READONLY;
................................................................................
  3245   3244   
  3246   3245         /* Store the current value of the database handles deferred constraint
  3247   3246         ** counter. If the statement transaction needs to be rolled back,
  3248   3247         ** the value of this counter needs to be restored too.  */
  3249   3248         p->nStmtDefCons = db->nDeferredCons;
  3250   3249         p->nStmtDefImmCons = db->nDeferredImmCons;
  3251   3250       }
  3252         -
  3253         -    /* Gather the schema version number for checking:
         3251  +  }
         3252  +  assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
         3253  +  if( pOp->p5
         3254  +   && (iMeta!=pOp->p3
         3255  +      || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i)
         3256  +  ){
         3257  +    /*
  3254   3258       ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema
  3255   3259       ** version is checked to ensure that the schema has not changed since the
  3256   3260       ** SQL statement was prepared.
  3257   3261       */
  3258         -    iGen = db->aDb[pOp->p1].pSchema->iGeneration;
  3259         -  }
  3260         -  assert( pOp->p5==0 || pOp->p4type==P4_INT32 );
  3261         -  if( pOp->p5 && (iMeta!=pOp->p3 || iGen!=pOp->p4.i) ){
  3262   3262       sqlite3DbFree(db, p->zErrMsg);
  3263   3263       p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed");
  3264   3264       /* If the schema-cookie from the database file matches the cookie 
  3265   3265       ** stored with the in-memory representation of the schema, do
  3266   3266       ** not reload the schema from the database file.
  3267   3267       **
  3268   3268       ** If virtual-tables are in use, this is not just an optimization.