Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix an issue in Bloom filters on RHS subsqueries to IN operators. See forum post 792a09cb3d for a description of the problem. Also improve comments related to [baa83b460c677c21] which was origin of the problem. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
cdef486e212fe4b26605065d9cff08f6 |
User & Date: | drh 2025-04-30 12:48:20.768 |
Context
2025-04-30
| ||
14:37 | Fix a harmless problem in the CLI in which SQL errors that occur during the ".schema" command are properly ignored, yes still appear in the ".log" output. Forum post 42fe6520b8 (Leaf check-in: 20abf1ec10 user: drh tags: trunk) | |
12:48 | Fix an issue in Bloom filters on RHS subsqueries to IN operators. See forum post 792a09cb3d for a description of the problem. Also improve comments related to [baa83b460c677c21] which was origin of the problem. (check-in: cdef486e21 user: drh tags: trunk) | |
2025-04-29
| ||
17:30 | Upstream teaish for a tcl portability fix on Haiku and a much nicer impl of proj-tclConfig-sh-to-autosetup. (check-in: ca0d30a43b user: stephan tags: trunk) | |
Changes
Changes to src/expr.c.
︙ | ︙ | |||
3622 3623 3624 3625 3626 3627 3628 3629 3630 | testcase( pSelect->selFlags & SF_Distinct ); testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); sqlite3SelectDelete(pParse->db, pCopy); sqlite3DbFree(pParse->db, dest.zAffSdst); if( addrBloom ){ sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; if( dest.iSDParm2==0 ){ | > > | < | | 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 | testcase( pSelect->selFlags & SF_Distinct ); testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); 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 ){ /* If the Bloom filter won't actually be used, keep it small */ sqlite3VdbeGetOp(v, addrBloom)->p1 = 10; } } if( rc ){ sqlite3KeyInfoUnref(pKeyInfo); return; } assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ |
︙ | ︙ | |||
4073 4074 4075 4076 4077 4078 4079 | }else{ sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector); if( destIfFalse==destIfNull ){ /* Combine Step 3 and Step 5 into a single opcode */ if( ExprHasProperty(pExpr, EP_Subrtn) ){ const VdbeOp *pOp = sqlite3VdbeGetOp(v, pExpr->y.sub.iAddr); assert( pOp->opcode==OP_Once || pParse->nErr ); | | | 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 | }else{ sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector); if( destIfFalse==destIfNull ){ /* Combine Step 3 and Step 5 into a single opcode */ 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 ){ /* tag-202407032019 */ assert( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ); sqlite3VdbeAddOp4Int(v, OP_Filter, pOp->p3, destIfFalse, rLhs, nVector); VdbeCoverage(v); } } sqlite3VdbeAddOp4Int(v, OP_NotFound, iTab, destIfFalse, rLhs, nVector); VdbeCoverage(v); |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
2640 2641 2642 2643 2644 2645 2646 | if( (pIn1->flags & MEM_Null)==0 ){ pOut->flags = MEM_Int; pOut->u.i = ~sqlite3VdbeIntValue(pIn1); } break; } | | > > > > > > | 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 | if( (pIn1->flags & MEM_Null)==0 ){ pOut->flags = MEM_Int; pOut->u.i = ~sqlite3VdbeIntValue(pIn1); } break; } /* 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 ** on the second and all subsequent encounters during the same invocation. ** ** Top-level programs determine first invocation by comparing the P1 ** operand against the P1 operand on the OP_Init opcode at the beginning ** of the program. If the P1 values differ, then fall through and make ** the P1 of this opcode equal to the P1 of OP_Init. If P1 values are ** the same then take the jump. ** ** For subprograms, there is a bitmask in the VdbeFrame that determines ** 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 */ assert( p->aOp[0].opcode==OP_Init ); if( p->pFrame ){ iAddr = (int)(pOp - p->aOp); if( (p->pFrame->aOnce[iAddr/8] & (1<<(iAddr & 7)))!=0 ){ |
︙ | ︙ |
Changes to test/bloom1.test.
︙ | ︙ | |||
220 221 222 223 224 225 226 | WHERE (ref_1.c1) = (2) ORDER BY c_0 desc ) as subq_2 UNION ALL SELECT 0 as c_0 ); } {0} | | > > > > > > > > > > > > | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | WHERE (ref_1.c1) = (2) ORDER BY c_0 desc ) as subq_2 UNION ALL SELECT 0 as c_0 ); } {0} # 2025-04-30 https://sqlite.org/forum/forumpost/792a09cb3df9e69f # A continuation of the above. # do_execsql_test 6.1 { DROP TABLE IF EXISTS t1; CREATE TABLE t1(a); SELECT 111 IN ( SELECT 222 FROM (SELECT 333 ORDER BY 1) UNION ALL SELECT 444 FROM (SELECT 555 FROM t1 ORDER BY 1) ); } 0 finish_test |