Add VdbeCoverage() macros. Adjust the Bloom-filter hash function so that it

correctly deals with zero-blobs.

FossilOrigin-Name: 629ee2e3e3125bfd2af435c6713d49e46691213ad15db0a5e93a63a77f1130c2
This commit is contained in:
drh 2021-12-04 18:45:08 +00:00
parent 770dade262
commit 067c60cfc9
5 changed files with 21 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Apply\sthe\sBloom\sfilter\sonly\son\sthose\sterms\sof\san\sindex\sthat\shave\sequality\nconstraints.
D 2021-12-04T14:24:30.524
C Add\sVdbeCoverage()\smacros.\s\sAdjust\sthe\sBloom-filter\shash\sfunction\sso\sthat\sit\ncorrectly\sdeals\swith\szero-blobs.
D 2021-12-04T18:45:08.377
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -622,7 +622,7 @@ F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
F src/util.c 30df8356e231dad33be10bb27897655002668343280004ba28c734489414a167
F src/vacuum.c 6c38ddc52f0619865c91dae9c441d4d48bf3040d7dc1bc5b22da1e45547ed0b3
F src/vdbe.c d4435e88e8abb076c955ee8262f548afcba77daa28b75f937ed914404bb29be7
F src/vdbe.c 94af4eba93ad9ca7dd929cd19792ce2a5feb4797a7a64ec3cb3b2277e1467a8b
F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe
F src/vdbeInt.h fd1103c7ecec8c84164038c8eacaa4a633cb3c10a2f725aae7bd865d4a4fcceb
F src/vdbeapi.c 22c79072ae7d8a01e9bcae8ba16e918d60d202eaa9553b5fda38f99f7464d99a
@ -637,9 +637,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c ed0398a7adf02c31e34aada42cc86c58f413a7afe5f741a5d373ad087abde028
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
F src/where.c d203a7acda584940eee49d80e38067ba354410ca08782792bdf4d6f56ca20aa3
F src/where.c 2607f8008b27f03003d62ed3b90e1818fda1dd5727daf020c8b3e526aff57269
F src/whereInt.h 2c9d149b1b41c59f977deb1882e95632800946fcf15c83eaffb227afece04e51
F src/wherecode.c ab83c1f7c593ab5e9268c51dde80f478e48468e8c1e25866a4f445e7b4282b78
F src/wherecode.c 2253f91bcded8932a4211238fa7dcf6ab40ff68dbd4c2d88eb4411f12b19552c
F src/whereexpr.c 19394cb463003e9cc9305730b1508b8817a22bb7247170d81234b691a7f05b89
F src/window.c 5d3b397b0c026d0ff5890244ac41359e524c01ae31e78782e1ff418c3e271a9e
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
@ -1933,7 +1933,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8e078c0e404fe4b3661dd4a11a992a8914c99e2a144cecc417421cbd68fa08cc
R a78591e6ea873c8de7a64c271c45d204
P a70429596a3c6a413b03118b0d800521b3526d99dcf88a48acc3189b51518d82
R f0b7f8e349624b23e895cc40d5e34cdd
U drh
Z 73637cbd9e62c30bcdc98bccabee0c03
Z 186d2bb7a1014e61ff9f3f3c0fb31234

View File

@ -1 +1 @@
a70429596a3c6a413b03118b0d800521b3526d99dcf88a48acc3189b51518d82
629ee2e3e3125bfd2af435c6713d49e46691213ad15db0a5e93a63a77f1130c2

View File

@ -695,6 +695,7 @@ static unsigned int filterHash(const Mem *aMem, const Op *pOp){
h += (u32)(sqlite3VdbeIntValue(p)&0xffffffff);
}else if( p->flags & (MEM_Str|MEM_Blob) ){
h += p->n;
if( p->flags & MEM_Zero ) h += p->u.nZero;
}
}
return h % (SQLITE_BLOOM_SZ*8);
@ -8229,7 +8230,12 @@ case OP_Filter: { /* jump */
}
#endif
assert( h>=0 && h<SQLITE_BLOOM_SZ*8 );
if( (pIn1->z[h/8] & (1<<(h&7)))==0 ) goto jump_to_p2;
if( (pIn1->z[h/8] & (1<<(h&7)))==0 ){
VdbeBranchTaken(1, 2);
goto jump_to_p2;
}else{
VdbeBranchTaken(0, 2);
}
break;
}

View File

@ -986,10 +986,10 @@ static SQLITE_NOINLINE void constructBloomFilter(
assert( v!=0 );
iCur = pLevel->iTabCur;
addrCont = sqlite3VdbeMakeLabel(pParse);
addrTop = sqlite3VdbeAddOp0(v, OP_Once);
addrTop = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
pLevel->regFilter = ++pParse->nMem;
sqlite3VdbeAddOp1(v, OP_FilterInit, pLevel->regFilter);
sqlite3VdbeAddOp1(v, OP_Rewind, iCur);
sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm];
for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
@ -1016,6 +1016,7 @@ static SQLITE_NOINLINE void constructBloomFilter(
}
sqlite3VdbeResolveLabel(v, addrCont);
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+3);
VdbeCoverage(v);
sqlite3VdbeJumpHere(v, addrTop);
sqlite3VdbeJumpHere(v, addrTop+2);
}

View File

@ -1517,6 +1517,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
if( pLevel->regFilter ){
sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
iRowidReg, 1);
VdbeCoverage(v);
}
sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
VdbeCoverage(v);
@ -1846,6 +1847,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
if( pLevel->regFilter ){
sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
regBase, nEq);
VdbeCoverage(v);
}
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];