aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2012-09-04 21:34:26 +0000
committerdrh <drh@noemail.net>2012-09-04 21:34:26 +0000
commit37f58e99022b329ba0007bc6509675a22a151eef (patch)
tree7ccefd8417b9fa6c6a1c3172e4cacae32b48b1ce /src
parent8a7c142887077adb590cb95a46941cb5149a7287 (diff)
downloadsqlite-37f58e99022b329ba0007bc6509675a22a151eef.tar.gz
sqlite-37f58e99022b329ba0007bc6509675a22a151eef.zip
Avoid repeating calls to the sqlite3_trace() callback when the same statement
is evaluted multiple times by sqlite3_step() due to an SQLITE_SCHEMA reprepare. FossilOrigin-Name: 39f763bfc04174ee0fe2cdf6a92b7c12f726bd1b
Diffstat (limited to 'src')
-rw-r--r--src/vdbe.c5
-rw-r--r--src/vdbeInt.h22
-rw-r--r--src/vdbeapi.c2
3 files changed, 20 insertions, 9 deletions
diff --git a/src/vdbe.c b/src/vdbe.c
index 1a3c412a7..965eec2ac 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -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);
diff --git a/src/vdbeInt.h b/src/vdbeInt.h
index 1f5694a59..e559bc2bd 100644
--- a/src/vdbeInt.h
+++ b/src/vdbeInt.h
@@ -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 */
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index b9a88a6ab..b48826680 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -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) ){