** CREATE TABLE v(
** event TEXT, // "xOpen", "xRead" etc.
** file TEXT, // Name of file this call applies to
+** time INTEGER, // Timestamp
** clicks INTEGER, // Time spent in call
** rc INTEGER, // Return value
** size INTEGER, // Bytes read or written
}
#endif
-static void vfslog_call(sqlite3_vfs *, int, int, sqlite3_int64, int, int, int);
+static void vfslog_call(
+sqlite3_vfs *, int, int, sqlite3_uint64, sqlite3_int64, int, int, int);
static void vfslog_string(sqlite3_vfs *, const char *);
/*
** Close an vfslog-file.
*/
static int vfslogClose(sqlite3_file *pFile){
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
int rc = SQLITE_OK;
VfslogFile *p = (VfslogFile *)pFile;
if( p->pReal->pMethods ){
rc = p->pReal->pMethods->xClose(p->pReal);
}
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_CLOSE, p->iFileId, t, rc, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_CLOSE, p->iFileId, t, t2, rc, 0, 0);
return rc;
}
sqlite_int64 iOfst
){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_READ, p->iFileId, t, rc, iAmt, (int)iOfst);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_READ, p->iFileId, t, t2, rc, iAmt, (int)iOfst);
return rc;
}
sqlite_int64 iOfst
){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_WRITE, p->iFileId, t, rc, iAmt, (int)iOfst);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_WRITE, p->iFileId, t, t2, rc, iAmt, (int)iOfst);
return rc;
}
*/
static int vfslogTruncate(sqlite3_file *pFile, sqlite_int64 size){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xTruncate(p->pReal, size);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_TRUNCATE, p->iFileId, t, rc, 0, (int)size);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_TRUNCATE, p->iFileId, t, t2, rc, 0, (int)size);
return rc;
}
*/
static int vfslogSync(sqlite3_file *pFile, int flags){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xSync(p->pReal, flags);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_SYNC, p->iFileId, t, rc, flags, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_SYNC, p->iFileId, t, t2, rc, flags, 0);
return rc;
}
*/
static int vfslogFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_FILESIZE, p->iFileId, t, rc, 0, (int)*pSize);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_FILESIZE, p->iFileId, t, t2, rc, 0, (int)*pSize);
return rc;
}
*/
static int vfslogLock(sqlite3_file *pFile, int eLock){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xLock(p->pReal, eLock);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_LOCK, p->iFileId, t, rc, eLock, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_LOCK, p->iFileId, t, t2, rc, eLock, 0);
return rc;
}
*/
static int vfslogUnlock(sqlite3_file *pFile, int eLock){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_UNLOCK, p->iFileId, t, rc, eLock, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_UNLOCK, p->iFileId, t, t2, rc, eLock, 0);
return rc;
}
*/
static int vfslogCheckReservedLock(sqlite3_file *pFile, int *pResOut){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_CHECKRESERVEDLOCK, p->iFileId, t, rc, *pResOut, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_CHECKRESERVEDLOCK, p->iFileId, t,t2,rc,*pResOut,0);
return rc;
}
*/
static int vfslogSectorSize(sqlite3_file *pFile){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xSectorSize(p->pReal);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_SECTORSIZE, p->iFileId, t, rc, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_SECTORSIZE, p->iFileId, t, t2, rc, 0, 0);
return rc;
}
*/
static int vfslogDeviceCharacteristics(sqlite3_file *pFile){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_DEVCHAR, p->iFileId, t, rc, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_DEVCHAR, p->iFileId, t, t2, rc, 0, 0);
return rc;
}
static int vfslogShmLock(sqlite3_file *pFile, int ofst, int n, int flags){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_SHMLOCK, p->iFileId, t, rc, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_SHMLOCK, p->iFileId, t, t2, rc, 0, 0);
return rc;
}
static int vfslogShmMap(
volatile void **pp
){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_SHMMAP, p->iFileId, t, rc, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_SHMMAP, p->iFileId, t, t2, rc, 0, 0);
return rc;
}
static void vfslogShmBarrier(sqlite3_file *pFile){
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
p->pReal->pMethods->xShmBarrier(p->pReal);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_SHMBARRIER, p->iFileId, t, SQLITE_OK, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_SHMBARRIER, p->iFileId, t, t2, SQLITE_OK, 0, 0);
}
static int vfslogShmUnmap(sqlite3_file *pFile, int deleteFlag){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
t = vfslog_time();
rc = p->pReal->pMethods->xShmUnmap(p->pReal, deleteFlag);
- t = vfslog_time() - t;
- vfslog_call(p->pVfslog, OS_SHMUNMAP, p->iFileId, t, rc, 0, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(p->pVfslog, OS_SHMUNMAP, p->iFileId, t, t2, rc, 0, 0);
return rc;
}
int *pOutFlags
){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
VfslogFile *p = (VfslogFile *)pFile;
VfslogVfs *pLog = (VfslogVfs *)pVfs;
t = vfslog_time();
rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags);
- t = vfslog_time() - t;
+ t2 = vfslog_time() - t;
- vfslog_call(pVfs, OS_OPEN, p->iFileId, t, rc, 0, 0);
+ vfslog_call(pVfs, OS_OPEN, p->iFileId, t, t2, rc, 0, 0);
vfslog_string(pVfs, zName);
return rc;
}
*/
static int vfslogDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
t = vfslog_time();
rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync);
- t = vfslog_time() - t;
- vfslog_call(pVfs, OS_DELETE, 0, t, rc, dirSync, 0);
+ t2 = vfslog_time() - t;
+ vfslog_call(pVfs, OS_DELETE, 0, t, t2, rc, dirSync, 0);
vfslog_string(pVfs, zPath);
return rc;
}
int *pResOut
){
int rc;
- sqlite3_uint64 t;
+ sqlite3_uint64 t, t2;
t = vfslog_time();
rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut);
- t = vfslog_time() - t;
- vfslog_call(pVfs, OS_ACCESS, 0, t, rc, flags, *pResOut);
+ t2 = vfslog_time() - t;
+ vfslog_call(pVfs, OS_ACCESS, 0, t, t2, rc, flags, *pResOut);
vfslog_string(pVfs, zPath);
return rc;
}
sqlite3_vfs *pVfs,
int eEvent,
int iFileid,
+ sqlite3_uint64 tStamp,
sqlite3_int64 nClick,
int return_code,
int size,
){
VfslogVfs *p = (VfslogVfs *)pVfs;
unsigned char *zRec;
- if( (24+p->nBuf)>sizeof(p->aBuf) ){
+ if( (32+p->nBuf)>sizeof(p->aBuf) ){
vfslog_flush(p);
}
zRec = (unsigned char *)&p->aBuf[p->nBuf];
vfslogPut32bits(&zRec[0], eEvent);
vfslogPut32bits(&zRec[4], iFileid);
- vfslogPut32bits(&zRec[8], (unsigned int)(nClick&0xffffffff));
- vfslogPut32bits(&zRec[12], return_code);
- vfslogPut32bits(&zRec[16], size);
- vfslogPut32bits(&zRec[20], offset);
- p->nBuf += 24;
+ vfslogPut32bits(&zRec[8], (unsigned int)((tStamp>>32)&0xffffffff));
+ vfslogPut32bits(&zRec[12], (unsigned int)(tStamp&0xffffffff));
+ vfslogPut32bits(&zRec[16], (unsigned int)(nClick&0xffffffff));
+ vfslogPut32bits(&zRec[20], return_code);
+ vfslogPut32bits(&zRec[24], size);
+ vfslogPut32bits(&zRec[28], offset);
+ p->nBuf += 32;
}
static void vfslog_string(sqlite3_vfs *pVfs, const char *zStr){
int sqlite3_vfslog_annotate(const char *zVfs, const char *zMsg){
sqlite3_vfs *pVfs;
+ sqlite3_uint64 t = vfslog_time();
pVfs = sqlite3_vfs_find(zVfs);
if( !pVfs || pVfs->xOpen!=vfslogOpen ){
return SQLITE_ERROR;
}
- vfslog_call(pVfs, OS_ANNOTATE, 0, 0, 0, 0, 0);
+ vfslog_call(pVfs, OS_ANNOTATE, 0, t, 0, 0, 0, 0);
vfslog_string(pVfs, zMsg);
return SQLITE_OK;
}
if( rc==SQLITE_OK ){
p->pFd->pMethods->xFileSize(p->pFd, &p->nByte);
sqlite3_declare_vtab(db,
- "CREATE TABLE xxx(event, file, click, rc, size, offset)"
+ "CREATE TABLE xxx(event, file, time, click, rc, size, offset)"
);
*ppVtab = &p->base;
}else{
sqlite3_free(pCsr->zTransient);
pCsr->zTransient = 0;
- nRead = 24;
+ nRead = 32;
if( pCsr->iOffset+nRead<=p->nByte ){
int eEvent;
rc = p->pFd->pMethods->xRead(p->pFd, pCsr->aBuf, nRead, pCsr->iOffset);
sqlite3_context *ctx,
int i
){
- unsigned int val;
VfslogCsr *pCsr = (VfslogCsr *)pCursor;
assert( i<7 );
- val = get32bits(&pCsr->aBuf[4*i]);
switch( i ){
case 0: {
+ unsigned int val = get32bits(&pCsr->aBuf[0]);
sqlite3_result_text(ctx, vfslog_eventname(val), -1, SQLITE_STATIC);
break;
}
case 1: {
+ unsigned int val = get32bits(&pCsr->aBuf[4]);
char *zStr = pCsr->zTransient;
if( val!=0 && val<(unsigned)pCsr->nFile ){
zStr = pCsr->azFile[val];
sqlite3_result_text(ctx, zStr, -1, SQLITE_TRANSIENT);
break;
}
- default:
+ case 2: {
+ unsigned int v1 = get32bits(&pCsr->aBuf[8]);
+ unsigned int v2 = get32bits(&pCsr->aBuf[12]);
+ sqlite3_result_int64(ctx,(((sqlite3_int64)v1) << 32) + (sqlite3_int64)v2);
+ break;
+ }
+ default: {
+ unsigned int val = get32bits(&pCsr->aBuf[4*(i+1)]);
sqlite3_result_int(ctx, val);
break;
+ }
}
return SQLITE_OK;