From: drh Date: Thu, 10 Oct 2013 13:38:51 +0000 (+0000) Subject: Fix the hash signature algorithm in vfslog.c. Add a utility program to X-Git-Tag: version-3.8.1~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7cd84ffc6083c480e74f14bb8a99f0191b52c275;p=thirdparty%2Fsqlite.git Fix the hash signature algorithm in vfslog.c. Add a utility program to show the hash signatures for every page of a database file. FossilOrigin-Name: eaf4de13a63b2294ae575432a022493308a4313a --- diff --git a/ext/misc/vfslog.c b/ext/misc/vfslog.c index 83fcff07d0..222a8d1fae 100644 --- a/ext/misc/vfslog.c +++ b/ext/misc/vfslog.c @@ -307,21 +307,28 @@ static int vlogClose(sqlite3_file *pFile){ /* ** Compute signature for a block of content. ** -** The signature is a hex dump of the first 8 bytes of the block -** followed by a 64bit hash (expressed in hex) of the entire content. +** For blocks of 16 or fewer bytes, the signature is just a hex dump of +** the entire block. +** +** For blocks of more than 16 bytes, the signature is a hex dump of the +** first 8 bytes followed by a 64-bit has of the entire block. */ static void vlogSignature(unsigned char *p, int n, char *zCksum){ unsigned int s0 = 0, s1 = 0; unsigned int *pI; int i; - pI = (unsigned int*)p; - for(i=0; i8 ) sqlite3_snprintf(18, zCksum+i, "-%08x08x", s0, s1); } /* @@ -660,5 +667,3 @@ int sqlite3_register_vfslog(const char *zArg){ vlog_vfs.base.szOsFile = sizeof(VLogFile) + vlog_vfs.pVfs->szOsFile; return sqlite3_vfs_register(&vlog_vfs.base, 1); } - - diff --git a/manifest b/manifest index 368a4585dc..907fe12c07 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sext/misc/vfslog.c,\sa\sVFS\sshim\sfor\sunix\sthat\skeeps\sa\slog\sof\smethod\scalls\smade\sby\sSQLite. -D 2013-10-10T13:04:46.705 +C Fix\sthe\shash\ssignature\salgorithm\sin\svfslog.c.\s\sAdd\sa\sutility\sprogram\sto\nshow\sthe\shash\ssignatures\sfor\severy\spage\sof\sa\sdatabase\sfile. +D 2013-10-10T13:38:51.770 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -115,7 +115,7 @@ F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/spellfix.c 5e1d547e9a2aed13897fa91bac924333f62fd2d9 -F ext/misc/vfslog.c 64f8ff0605ba36fd3e71c5e3b2ea00c55448cbbe +F ext/misc/vfslog.c 9e66605f1c01ec4f7c1b25d07982e1989d7e2eee F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 @@ -1100,6 +1100,7 @@ F tool/mkvsix.tcl f3312df26fd9938a27fa0a845ec96bea84b0c16b F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c +F tool/pagesig.c d8a672401b593726d5dfcadf1b04d37310e4ef94 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/showdb.c 525ecc443578647703051308ad50a93de6ba2c4b @@ -1122,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P d27b88b8c2705f444f794096c719e6f38a792165 -R 5f38dde3b9e8f121e53417dc6f4fda25 -U dan -Z f43e38212326572373f5c91a1aac8a3a +P 24a827b87666670c56d68a18685f4f712852fa92 +R 50c7090bf0272806264dd351e41bc40a +U drh +Z e3109387d8d252ace6094f69ea11a6f0 diff --git a/manifest.uuid b/manifest.uuid index bd77f508cc..9cf0644a19 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24a827b87666670c56d68a18685f4f712852fa92 \ No newline at end of file +eaf4de13a63b2294ae575432a022493308a4313a \ No newline at end of file diff --git a/tool/pagesig.c b/tool/pagesig.c new file mode 100644 index 0000000000..f4205c86fb --- /dev/null +++ b/tool/pagesig.c @@ -0,0 +1,92 @@ +/* +** 2013-10-01 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Compute hash signatures for every page of a database file. This utility +** program is useful for analyzing the output logs generated by the +** ext/misc/vfslog.c extension. +*/ +#include +#include +#include +#include + +/* +** Compute signature for a block of content. +** +** For blocks of 16 or fewer bytes, the signature is just a hex dump of +** the entire block. +** +** For blocks of more than 16 bytes, the signature is a hex dump of the +** first 8 bytes followed by a 64-bit has of the entire block. +*/ +static void vlogSignature(unsigned char *p, int n, char *zCksum){ + unsigned int s0 = 0, s1 = 0; + unsigned int *pI; + int i; + if( n<=16 ){ + for(i=0; i