aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2025-04-30 12:48:20 +0000
committerdrh <>2025-04-30 12:48:20 +0000
commit88ed1806a4dae310ea08a9c2e6c5631e87c4fabb (patch)
tree4f263ccd3f641a744888dc0792df12d211da683b /src
parenta20c09c477da10497459093cd6fc92f097378d69 (diff)
downloadsqlite-88ed1806a4dae310ea08a9c2e6c5631e87c4fabb.tar.gz
sqlite-88ed1806a4dae310ea08a9c2e6c5631e87c4fabb.zip
Fix an issue in Bloom filters on RHS subsqueries to IN operators.
See [forum:/forumpost/792a09cb3df9e69f|forum post 792a09cb3d] for a description of the problem. Also improve comments related to [baa83b460c677c21] which was origin of the problem. FossilOrigin-Name: cdef486e212fe4b26605065d9cff08f608cb80df48ee64e4be63637769bdfacc
Diffstat (limited to 'src')
-rw-r--r--src/expr.c9
-rw-r--r--src/vdbe.c8
2 files changed, 12 insertions, 5 deletions
diff --git a/src/expr.c b/src/expr.c
index dd5ea2038..bf15811bc 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3626,11 +3626,12 @@ void sqlite3CodeRhsOfIN(
sqlite3SelectDelete(pParse->db, pCopy);
sqlite3DbFree(pParse->db, dest.zAffSdst);
if( addrBloom ){
+ /* Remember that location of the Bloom filter in the P3 operand
+ ** of the OP_Once that began this subroutine. tag-202407032019 */
sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2;
if( dest.iSDParm2==0 ){
- sqlite3VdbeChangeToNoop(v, addrBloom);
- }else{
- sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2;
+ /* If the Bloom filter won't actually be used, keep it small */
+ sqlite3VdbeGetOp(v, addrBloom)->p1 = 10;
}
}
if( rc ){
@@ -4077,7 +4078,7 @@ static void sqlite3ExprCodeIN(
if( ExprHasProperty(pExpr, EP_Subrtn) ){
const VdbeOp *pOp = sqlite3VdbeGetOp(v, pExpr->y.sub.iAddr);
assert( pOp->opcode==OP_Once || pParse->nErr );
- if( pOp->opcode==OP_Once && pOp->p3>0 ){
+ if( pOp->opcode==OP_Once && pOp->p3>0 ){ /* tag-202407032019 */
assert( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) );
sqlite3VdbeAddOp4Int(v, OP_Filter, pOp->p3, destIfFalse,
rLhs, nVector); VdbeCoverage(v);
diff --git a/src/vdbe.c b/src/vdbe.c
index d4009b70f..c9972fe16 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -2644,7 +2644,7 @@ case OP_BitNot: { /* same as TK_BITNOT, in1, out2 */
break;
}
-/* Opcode: Once P1 P2 * * *
+/* Opcode: Once P1 P2 P3 * *
**
** Fall through to the next instruction the first time this opcode is
** encountered on each invocation of the byte-code program. Jump to P2
@@ -2660,6 +2660,12 @@ case OP_BitNot: { /* same as TK_BITNOT, in1, out2 */
** whether or not the jump should be taken. The bitmask is necessary
** because the self-altering code trick does not work for recursive
** triggers.
+**
+** The P3 operand is not used directly by this opcode. However P3 is
+** used by the code generator as follows: If this opcode is the start
+** of a subroutine and that subroutine uses a Bloom filter, then P3 will
+** be the register that holds that Bloom filter. See tag-202407032019
+** in the source code for implementation details.
*/
case OP_Once: { /* jump */
u32 iAddr; /* Address of this instruction */