mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Fix handling of "continue" and "break" from inside the loop for the right
operand of a RIGHT JOIN. FossilOrigin-Name: b6e773a26c2c6ee76ea61acb059b4e676d07ea62f6db9c513638f8986557cf04
This commit is contained in:
10
src/vdbe.c
10
src/vdbe.c
@@ -993,8 +993,12 @@ jump_to_p2:
|
||||
|
||||
/* Opcode: Return P1 P2 P3 * *
|
||||
**
|
||||
** Jump to the next instruction after the address in register P1. After
|
||||
** the jump, register P1 becomes undefined.
|
||||
** Jump to the next instruction after the address stored in register P1.
|
||||
**
|
||||
** It used to be that after the jump, register P1 would become undefined.
|
||||
** However, for the subroutine used for the inner loop of a RIGHT JOIN,
|
||||
** it is useful for R1 register to be unchanged, so that is what happens
|
||||
** now.
|
||||
**
|
||||
** P2 is not used by the byte-code engine. However, if P2 is positive
|
||||
** and also less than the current address, then the "EXPLAIN" output
|
||||
@@ -1012,7 +1016,7 @@ case OP_Return: { /* in1 */
|
||||
pIn1 = &aMem[pOp->p1];
|
||||
assert( pIn1->flags==MEM_Int );
|
||||
pOp = &aOp[pIn1->u.i];
|
||||
pIn1->flags = MEM_Undefined;
|
||||
/* pIn1->flags = MEM_Undefined; */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
11
src/where.c
11
src/where.c
@@ -5880,6 +5880,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
pRJ->regBloom = ++pParse->nMem;
|
||||
sqlite3VdbeAddOp2(v, OP_Blob, 65536, pRJ->regBloom);
|
||||
pRJ->regReturn = ++pParse->nMem;
|
||||
pRJ->addrInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, pRJ->regReturn);
|
||||
assert( pTab==pTabItem->pTab );
|
||||
if( HasRowid(pTab) ){
|
||||
KeyInfo *pInfo;
|
||||
@@ -6013,7 +6014,11 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
/* Terminate the subroutine that forms the interior of the loop of
|
||||
** the RIGHT JOIN table */
|
||||
WhereRightJoin *pRJ = pLevel->pRJ;
|
||||
sqlite3VdbeChangeP1(v, pRJ->addrSubrtn-1, sqlite3VdbeCurrentAddr(v));
|
||||
int addrHere = sqlite3VdbeCurrentAddr(v);
|
||||
sqlite3VdbeChangeP1(v, pRJ->addrSubrtn-1, addrHere);
|
||||
sqlite3VdbeChangeP1(v, pRJ->addrInit, addrHere);
|
||||
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
|
||||
pLevel->addrCont = 0;
|
||||
sqlite3VdbeAddOp2(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn);
|
||||
}
|
||||
pLoop = pLevel->pWLoop;
|
||||
@@ -6043,7 +6048,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
}
|
||||
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
|
||||
/* The common case: Advance to the next row */
|
||||
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
|
||||
if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont);
|
||||
sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
|
||||
sqlite3VdbeChangeP5(v, pLevel->p5);
|
||||
VdbeCoverage(v);
|
||||
@@ -6058,7 +6063,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
|
||||
if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);
|
||||
#endif
|
||||
}else{
|
||||
}else if( pLevel->addrCont ){
|
||||
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
|
||||
}
|
||||
if( (pLoop->wsFlags & WHERE_IN_ABLE)!=0 && pLevel->u.in.nIn>0 ){
|
||||
|
||||
@@ -52,6 +52,7 @@ struct WhereRightJoin {
|
||||
int regBloom; /* Bloom filter for iRJMatch */
|
||||
int regReturn; /* Return register for the interior subroutine */
|
||||
int addrSubrtn; /* Starting address for the interior subroutine */
|
||||
int addrInit; /* OP_Integer used for early init of regReturn */
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user