Change the way checksums are calculated.

FossilOrigin-Name: 84955c2e9ce526c5a3ed479aa09f093a7e37c7d0
This commit is contained in:
dan 2010-04-15 10:58:51 +00:00
parent ce2f88d95b
commit 39c79f587c
3 changed files with 32 additions and 38 deletions

View File

@ -1,8 +1,5 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Bring\sover\sthe\srecent\squery\splanner\senhancements\sfrom\sthe\strunk.
D 2010-04-15T02:37:11
C Change\sthe\sway\schecksums\sare\scalculated.
D 2010-04-15T10:58:52
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -134,7 +131,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
F src/log.c 165addfd51fa9581936ec04914b17a3b274c49bd
F src/log.c bf7ce56249b2a08d26b4029430c32a01efc4a64e
F src/log.h a2654af46ce7b5732f4d5a731abfdd180f0a06d9
F src/main.c c0e7192bad5b90544508b241eb2487ac661de890
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
@ -807,14 +804,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P c18077f2465fc34830f11c9832e76be5746eaeea defaf0d99a807027f8883bf821b6482025f9f54e
R 5f5abc6d19fbeba7fb34263a5662faa7
U drh
Z 9dfe9b346dd22ca03d0d17a2ddbb8a3c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLxnvaoxKgR168RlERAkpHAJ9umCCf7Sfy2xa1T3mJ1bqzrPY7tgCgjEA2
oN5S7m+hWn0GMbvXKOIs1cY=
=ADT1
-----END PGP SIGNATURE-----
P 82969f27e5ea843cb379666d8a02e4a3fddc03b2
R b356f412a9c351edeb3f07a632ecce9f
U dan
Z 01a21dba5524ff578c531f4245d5f626

View File

@ -1 +1 @@
82969f27e5ea843cb379666d8a02e4a3fddc03b2
84955c2e9ce526c5a3ed479aa09f093a7e37c7d0

View File

@ -141,23 +141,21 @@ static LogSummary *pLogSummary = 0;
*/
#define LOG_CKSM_BYTES 8
static void logChecksumBytes(u8 *aByte, int nByte, u32 *aCksum){
u32 *z32 = (u32 *)aByte;
int n32 = nByte / sizeof(u32);
int i;
u64 sum1 = aCksum[0];
u64 sum2 = aCksum[1];
u32 *a32 = (u32 *)aByte;
u32 *aEnd = (u32 *)&aByte[nByte];
assert( LOG_CKSM_BYTES==2*sizeof(u32) );
assert( (nByte&0x00000003)==0 );
u32 cksum0 = aCksum[0];
u32 cksum1 = aCksum[1];
do {
sum1 += (*a32++);
sum2 += sum1;
} while( a32<aEnd );
for(i=0; i<n32; i++){
cksum0 = (cksum0 >> 8) + (cksum0 ^ z32[i]);
cksum1 = (cksum1 >> 8) + (cksum1 ^ z32[i]);
}
aCksum[0] = cksum0;
aCksum[1] = cksum1;
aCksum[0] = sum1 + (sum1>>24);
aCksum[1] = sum2 + (sum2>>24);
}
/*
@ -1259,8 +1257,6 @@ void sqlite3LogCloseSnapshot(Log *pLog){
pLog->isLocked = 0;
}
/*
** Read a page from the log, if it is present.
*/
@ -1269,6 +1265,8 @@ int sqlite3LogRead(Log *pLog, Pgno pgno, int *pInLog, u8 *pOut){
u32 *aData = pLog->pSummary->aData;
int iFrame = (pLog->hdr.iLastPg & 0xFFFFFF00);
assert( pLog->isLocked );
/* Do a linear search of the unindexed block of page-numbers (if any)
** at the end of the log-summary. An alternative to this would be to
** build an index in private memory each time a read transaction is
@ -1349,11 +1347,11 @@ int sqlite3LogWriteLock(Log *pLog, int op){
return rc;
}
/* If this is connection is a region D, then the SHARED lock on region
** D has just been upgraded to EXCLUSIVE. But no lock at all is held on
** region A. This means that if the write-transaction is committed
/* If this is connection is a region D reader, then the SHARED lock on
** region D has just been upgraded to EXCLUSIVE. But no lock at all is
** held on region A. This means that if the write-transaction is committed
** and this connection downgrades to a reader, it will be left with no
** lock at all. And its snapshot could get clobbered by a checkpoint
** lock at all. And so its snapshot could get clobbered by a checkpoint
** operation.
**
** To stop this from happening, grab a SHARED lock on region A now.
@ -1367,6 +1365,10 @@ int sqlite3LogWriteLock(Log *pLog, int op){
pLog->isLocked = LOG_REGION_A;
}
/* If this connection is not reading the most recent database snapshot,
** it is not possible to write to the database. In this case release
** the write locks and return SQLITE_BUSY.
*/
if( memcmp(&pLog->hdr, pLog->pSummary->aData, sizeof(pLog->hdr)) ){
logLockRegion(pLog, LOG_REGION_C|LOG_REGION_D, LOG_UNLOCK);
return SQLITE_BUSY;
@ -1535,13 +1537,15 @@ int sqlite3LogCheckpoint(
){
int rc; /* Return code */
/* Wait for a write-lock on regions B and C. */
assert( !pLog->isLocked );
/* Wait for an EXCLUSIVE lock on regions B and C. */
do {
rc = logLockRegion(pLog, LOG_REGION_B|LOG_REGION_C, LOG_WRLOCK);
}while( rc==SQLITE_BUSY && xBusyHandler(pBusyHandlerArg) );
if( rc!=SQLITE_OK ) return rc;
/* Wait for a write-lock on region A. */
/* Wait for an EXCLUSIVE lock on region A. */
do {
rc = logLockRegion(pLog, LOG_REGION_A, LOG_WRLOCK);
}while( rc==SQLITE_BUSY && xBusyHandler(pBusyHandlerArg) );