aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/vfslog.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-10-18 17:42:35 +0000
committerdrh <drh@noemail.net>2013-10-18 17:42:35 +0000
commit06d6efb66155e41b303d151bebfad9cab9532ccc (patch)
tree5bee940be83ee3b16cf44f39a0986102714ae820 /ext/misc/vfslog.c
parent2eebbf699efde003afdd0e87ae330a8873350b7a (diff)
downloadsqlite-06d6efb66155e41b303d151bebfad9cab9532ccc.tar.gz
sqlite-06d6efb66155e41b303d151bebfad9cab9532ccc.zip
Further enhance the vfslog extension to record the number of freelist pages
and the first freelist page in CHNGCTR-READ and CHNGCTR-WRITE records. FossilOrigin-Name: 08157524ca816a81f3c341097e23982727eaa125
Diffstat (limited to 'ext/misc/vfslog.c')
-rw-r--r--ext/misc/vfslog.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/ext/misc/vfslog.c b/ext/misc/vfslog.c
index 7b2f99bc5..3e4fed614 100644
--- a/ext/misc/vfslog.c
+++ b/ext/misc/vfslog.c
@@ -347,6 +347,13 @@ static void vlogSignature(unsigned char *p, int n, char *zCksum){
}
/*
+** Convert a big-endian 32-bit integer into a native integer
+*/
+static int bigToNative(const unsigned char *x){
+ return (x[0]<<24) + (x[1]<<16) + (x[2]<<8) + x[3];
+}
+
+/*
** Read data from an vlog-file.
*/
static int vlogRead(
@@ -376,9 +383,16 @@ static int vlogRead(
&& iOfst+iAmt>=28
){
unsigned char *x = ((unsigned char*)zBuf)+(24-iOfst);
- unsigned iCtr;
- iCtr = (x[0]<<24) + (x[1]<<16) + (x[2]<<8) + x[3];
- vlogLogPrint(p->pLog, tStart, 0, "CHNGCTR-READ", iCtr, -1, 0, 0);
+ unsigned iCtr, nFree = -1;
+ char *zFree = 0;
+ char zStr[12];
+ iCtr = bigToNative(x);
+ if( iOfst+iAmt>=40 ){
+ zFree = zStr;
+ sqlite3_snprintf(sizeof(zStr), zStr, "%d", bigToNative(x+8));
+ nFree = bigToNative(x+12);
+ }
+ vlogLogPrint(p->pLog, tStart, 0, "CHNGCTR-READ", iCtr, nFree, zFree, 0);
}
return rc;
}
@@ -409,9 +423,16 @@ static int vlogWrite(
&& iOfst+iAmt>=28
){
unsigned char *x = ((unsigned char*)z)+(24-iOfst);
- unsigned iCtr;
- iCtr = (x[0]<<24) + (x[1]<<16) + (x[2]<<8) + x[3];
- vlogLogPrint(p->pLog, tStart, 0, "CHNGCTR-WRITE", iCtr, -1, 0, 0);
+ unsigned iCtr, nFree = -1;
+ char *zFree = 0;
+ char zStr[12];
+ iCtr = bigToNative(x);
+ if( iOfst+iAmt>=40 ){
+ zFree = zStr;
+ sqlite3_snprintf(sizeof(zStr), zStr, "%d", bigToNative(x+8));
+ nFree = bigToNative(x+12);
+ }
+ vlogLogPrint(p->pLog, tStart, 0, "CHNGCTR-WRITE", iCtr, nFree, zFree, 0);
}
return rc;
}