]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Avoid repeating calls to the sqlite3_trace() callback when the same statement
authordrh <drh@noemail.net>
Tue, 4 Sep 2012 21:34:26 +0000 (21:34 +0000)
committerdrh <drh@noemail.net>
Tue, 4 Sep 2012 21:34:26 +0000 (21:34 +0000)
is evaluted multiple times by sqlite3_step() due to an SQLITE_SCHEMA
reprepare.

FossilOrigin-Name: 39f763bfc04174ee0fe2cdf6a92b7c12f726bd1b

manifest
manifest.uuid
src/vdbe.c
src/vdbeInt.h
src/vdbeapi.c

index 033d6654a313fa57cdce234ba86074920a4d5106..deddb04066d551f9c92d5b9d77c55199bbe9c179 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s3.7.14
-D 2012-09-03T15:42:36.217
+C Avoid\srepeating\scalls\sto\sthe\ssqlite3_trace()\scallback\swhen\sthe\ssame\sstatement\nis\sevaluted\smultiple\stimes\sby\ssqlite3_step()\sdue\sto\san\sSQLITE_SCHEMA\nreprepare.
+D 2012-09-04T21:34:26.807
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -238,10 +238,10 @@ F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef
 F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84
 F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455
 F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd
-F src/vdbe.c 9c524bded348fd0a53adc19f2d7cad76ba3442b2
+F src/vdbe.c 64de1142b9f3a84f500a6ce964175c828f1e41da
 F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb
-F src/vdbeInt.h 986b6b11a13c517337355009e5438703ba5b0a40
-F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1
+F src/vdbeInt.h a668b303644377433e31a18d3d9efb87eefb6332
+F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c
 F src/vdbeaux.c 9c293fd3040211687e83d5d27bef2382933146c2
 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb
 F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74
@@ -1014,10 +1014,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
-P ebb08d0b4d1ed674e4a23c3754206ca2df9063ff
-R 8bdf9ef517616ac5a5043f12bec4acdb
-T +bgcolor * #d0c0ff
-T +sym-release *
-T +sym-version-3.7.14 *
+P c0d89d4a9752922f9e367362366efde4f1b06f2a
+R f99616c13334ce584a8b1ebfcd476fa4
 U drh
-Z 126ab1aaea0f3a8cb5c4792cf0a82989
+Z 2084e672100937502093a8dd98a48d0f
index 05cc345a307f5b17172071cf618b07d7603a2ed5..28881c5c1862565010838e603f579c6e3704846c 100644 (file)
@@ -1 +1 @@
-c0d89d4a9752922f9e367362366efde4f1b06f2a
\ No newline at end of file
+39f763bfc04174ee0fe2cdf6a92b7c12f726bd1b
\ No newline at end of file
index 1a3c412a7891089f56f18be69f80992e68b99778..965eec2acc3341fdd4b16696e7ebf67864f5f3e3 100644 (file)
@@ -6075,7 +6075,10 @@ case OP_Trace: {
   char *zTrace;
   char *z;
 
-  if( db->xTrace && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 ){
+  if( db->xTrace
+   && !p->doingRerun
+   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
+  ){
     z = sqlite3VdbeExpandSql(p, zTrace);
     db->xTrace(db->pTraceArg, z);
     sqlite3DbFree(db, z);
index 1f5694a595f55c155c58b2575f563145d2a9710b..e559bc2bd286fe888a1989876b3393fec2c6d1f7 100644 (file)
@@ -273,6 +273,11 @@ struct Explain {
   char zBase[100];   /* Initial space */
 };
 
+/* A bitfield type for use inside of structures.  Always follow with :N where
+** N is the number of bits.
+*/
+typedef unsigned bft;  /* Bit Field Type */
+
 /*
 ** An instance of the virtual machine.  This structure contains the complete
 ** state of the virtual machine.
@@ -314,15 +319,16 @@ struct Vdbe {
   int pc;                 /* The program counter */
   int rc;                 /* Value to return */
   u8 errorAction;         /* Recovery action to do in case of an error */
-  u8 explain;             /* True if EXPLAIN present on SQL command */
-  u8 changeCntOn;         /* True to update the change-counter */
-  u8 expired;             /* True if the VM needs to be recompiled */
-  u8 runOnlyOnce;         /* Automatically expire on reset */
   u8 minWriteFileFormat;  /* Minimum file format for writable database files */
-  u8 inVtabMethod;        /* See comments above */
-  u8 usesStmtJournal;     /* True if uses a statement journal */
-  u8 readOnly;            /* True for read-only statements */
-  u8 isPrepareV2;         /* True if prepared with prepare_v2() */
+  bft explain:2;          /* True if EXPLAIN present on SQL command */
+  bft inVtabMethod:2;     /* See comments above */
+  bft changeCntOn:1;      /* True to update the change-counter */
+  bft expired:1;          /* True if the VM needs to be recompiled */
+  bft runOnlyOnce:1;      /* Automatically expire on reset */
+  bft usesStmtJournal:1;  /* True if uses a statement journal */
+  bft readOnly:1;         /* True for read-only statements */
+  bft isPrepareV2:1;      /* True if prepared with prepare_v2() */
+  bft doingRerun:1;       /* True if rerunning after an auto-reprepare */
   int nChange;            /* Number of db changes made since last reset */
   yDbMask btreeMask;      /* Bitmask of db->aDb[] entries referenced */
   yDbMask lockMask;       /* Subset of btreeMask that requires a lock */
index b9a88a6ab8f444531c932f423bc9209666be4131..b48826680a3c87babd8ae4fbd0acc59d7f0117b2 100644 (file)
@@ -478,10 +478,12 @@ int sqlite3_step(sqlite3_stmt *pStmt){
   }
   db = v->db;
   sqlite3_mutex_enter(db->mutex);
+  v->doingRerun = 0;
   while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
          && cnt++ < SQLITE_MAX_SCHEMA_RETRY
          && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){
     sqlite3_reset(pStmt);
+    v->doingRerun = 1;
     assert( v->expired==0 );
   }
   if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){