diff options
author | drh <drh@noemail.net> | 2005-08-29 23:00:03 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2005-08-29 23:00:03 +0000 |
commit | 19e2d37f1de2459dad62416124c26cdaa84e82db (patch) | |
tree | b158f590be274fb7ff16ddb4c9cda790ec8c3c87 /src/vdbeapi.c | |
parent | b46b57745ddf0d131843e229fc13a3dbc231f545 (diff) | |
download | sqlite-19e2d37f1de2459dad62416124c26cdaa84e82db.tar.gz sqlite-19e2d37f1de2459dad62416124c26cdaa84e82db.zip |
Increase resolution of time-of-day on unix. Add an experimental
sqlite3_profile() API. (CVS 2639)
FossilOrigin-Name: ed2ca0873fa89d6cfd123541d5d1c6b92c72b6ab
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r-- | src/vdbeapi.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c index dfe8f12c4..75af8a9b6 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -15,6 +15,7 @@ */ #include "sqliteInt.h" #include "vdbeInt.h" +#include "os.h" /* ** Return TRUE (non-zero) of the statement supplied as an argument needs @@ -173,9 +174,10 @@ int sqlite3_step(sqlite3_stmt *pStmt){ return SQLITE_MISUSE; } if( p->pc<0 ){ +#ifndef SQLITE_OMIT_TRACE /* Invoke the trace callback if there is one */ - if( (db = p->db)->xTrace && !db->init.busy ){ + if( db->xTrace && !db->init.busy ){ assert( p->nOp>0 ); assert( p->aOp[p->nOp-1].opcode==OP_Noop ); assert( p->aOp[p->nOp-1].p3!=0 ); @@ -187,6 +189,12 @@ int sqlite3_step(sqlite3_stmt *pStmt){ return SQLITE_MISUSE; } } + if( db->xProfile && !db->init.busy ){ + double rNow; + sqlite3OsCurrentTime(&rNow); + p->startTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0; + } +#endif /* Print a copy of SQL as it is executed if the SQL_TRACE pragma is turned ** on in debugging mode. @@ -213,6 +221,23 @@ int sqlite3_step(sqlite3_stmt *pStmt){ rc = SQLITE_MISUSE; } +#ifndef SQLITE_OMIT_TRACE + /* Invoke the profile callback if there is one + */ + if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy ){ + double rNow; + u64 elapseTime; + + sqlite3OsCurrentTime(&rNow); + elapseTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0 - p->startTime; + assert( p->nOp>0 ); + assert( p->aOp[p->nOp-1].opcode==OP_Noop ); + assert( p->aOp[p->nOp-1].p3!=0 ); + assert( p->aOp[p->nOp-1].p3type==P3_DYNAMIC ); + db->xProfile(db->pProfileArg, p->aOp[p->nOp-1].p3, elapseTime); + } +#endif + sqlite3Error(p->db, rc, p->zErrMsg ? "%s" : 0, p->zErrMsg); return rc; } |