Modify the FTS integrity-check so that the checksums do not depend on the results of signed integer overflow, which is undefined in C.
FossilOrigin-Name: f907fc3fb387e74bb66babcbf050748cb253a6fa
This commit is contained in:
parent
84bce14f77
commit
6f4df8ac83
@ -3611,6 +3611,7 @@ static int fts3IncrmergePush(
|
||||
}
|
||||
|
||||
assert( 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4710,7 +4711,7 @@ static int fts3DoAutoincrmerge(
|
||||
** Return a 64-bit checksum for the FTS index entry specified by the
|
||||
** arguments to this function.
|
||||
*/
|
||||
static i64 fts3ChecksumEntry(
|
||||
static u64 fts3ChecksumEntry(
|
||||
const char *zTerm, /* Pointer to buffer containing term */
|
||||
int nTerm, /* Size of zTerm in bytes */
|
||||
int iLangid, /* Language id for current row */
|
||||
@ -4720,7 +4721,7 @@ static i64 fts3ChecksumEntry(
|
||||
int iPos /* Position */
|
||||
){
|
||||
int i;
|
||||
i64 ret = iDocid;
|
||||
u64 ret = (u64)iDocid;
|
||||
|
||||
ret += (ret<<3) + iLangid;
|
||||
ret += (ret<<3) + iIndex;
|
||||
@ -4740,7 +4741,7 @@ static i64 fts3ChecksumEntry(
|
||||
** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The
|
||||
** return value is undefined in this case.
|
||||
*/
|
||||
static i64 fts3ChecksumIndex(
|
||||
static u64 fts3ChecksumIndex(
|
||||
Fts3Table *p, /* FTS3 table handle */
|
||||
int iLangid, /* Language id to return cksum for */
|
||||
int iIndex, /* Index to cksum (0..p->nIndex-1) */
|
||||
@ -4749,7 +4750,7 @@ static i64 fts3ChecksumIndex(
|
||||
Fts3SegFilter filter;
|
||||
Fts3MultiSegReader csr;
|
||||
int rc;
|
||||
i64 cksum = 0;
|
||||
u64 cksum = 0;
|
||||
|
||||
assert( *pRc==SQLITE_OK );
|
||||
|
||||
@ -4815,8 +4816,8 @@ static i64 fts3ChecksumIndex(
|
||||
*/
|
||||
static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
|
||||
int rc = SQLITE_OK; /* Return code */
|
||||
i64 cksum1 = 0; /* Checksum based on FTS index contents */
|
||||
i64 cksum2 = 0; /* Checksum based on %_content contents */
|
||||
u64 cksum1 = 0; /* Checksum based on FTS index contents */
|
||||
u64 cksum2 = 0; /* Checksum based on %_content contents */
|
||||
sqlite3_stmt *pAllLangid = 0; /* Statement to return all language-ids */
|
||||
|
||||
/* This block calculates the checksum according to the FTS index. */
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sa\scomment\sto\sexplain\show\sthe\sFTS\sintegrity-check\sworks.
|
||||
D 2012-03-26T10:47:03.798
|
||||
C Modify\sthe\sFTS\sintegrity-check\sso\sthat\sthe\schecksums\sdo\snot\sdepend\son\sthe\sresults\sof\ssigned\sinteger\soverflow,\swhich\sis\sundefined\sin\sC.
|
||||
D 2012-03-26T10:57:31.278
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -78,7 +78,7 @@ F ext/fts3/fts3_test.c 6b7cc68aef4efb084e1449f7d20c4b20d3bdf6b4
|
||||
F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce
|
||||
F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68
|
||||
F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
|
||||
F ext/fts3/fts3_write.c 554368a941e89bf556d653d72eac4ceb8c5a30ef
|
||||
F ext/fts3/fts3_write.c 6014014cf0257d314d29d7eb50e0c88d85356d65
|
||||
F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
|
||||
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
|
||||
F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
|
||||
@ -999,7 +999,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
P 40fc8804743dfb005991e9c5ef7b0ebcb3c2e731
|
||||
R a29b15091e6e8965fd03216fe1c6e4ff
|
||||
P 64e8a116f39434a3b7347f01a47f88eef3276742
|
||||
R b3b4e0fd75a1473fbbf1af679fdf9753
|
||||
U dan
|
||||
Z 4197780953b43ba749fe7b7fcb72124a
|
||||
Z df6c781d7592577597c979769aed212b
|
||||
|
@ -1 +1 @@
|
||||
64e8a116f39434a3b7347f01a47f88eef3276742
|
||||
f907fc3fb387e74bb66babcbf050748cb253a6fa
|
Loading…
x
Reference in New Issue
Block a user