aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-03-16 03:07:53 +0000
committerdrh <drh@noemail.net>2020-03-16 03:07:53 +0000
commit14c98a4f4016bb60679535e3d2d9fe6c49bfe04a (patch)
tree64c4dda89c9f298342b8c48d861f54c1ec3a6134 /src
parentba25c7e29f4583cf1dc3cf777b5b3e30aadf74b8 (diff)
downloadsqlite-14c98a4f4016bb60679535e3d2d9fe6c49bfe04a.tar.gz
sqlite-14c98a4f4016bb60679535e3d2d9fe6c49bfe04a.zip
At the end of the right-hand table loop of a LEFT JOIN that uses an IN
operator in the ON clause, put the OP_IfNoHope operator after the OP_IfNotOpen operator, not before, to avoid a (harmless) uninitialized register reference. Ticket [82b588d342d515d1] FossilOrigin-Name: 8b437b47266ec2d80d85eafcfdd6949556d6c28d9d67d5f43d89799f0f5b7bd0
Diffstat (limited to 'src')
-rw-r--r--src/where.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/where.c b/src/where.c
index 5cf59992e..ad309006d 100644
--- a/src/where.c
+++ b/src/where.c
@@ -5336,12 +5336,6 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
if( pIn->eEndLoopOp!=OP_Noop ){
if( pIn->nPrefix ){
assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );
- if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
- sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
- sqlite3VdbeCurrentAddr(v)+2+(pLevel->iLeftJoin!=0),
- pIn->iBase, pIn->nPrefix);
- VdbeCoverage(v);
- }
if( pLevel->iLeftJoin ){
/* For LEFT JOIN queries, cursor pIn->iCur may not have been
** opened yet. This occurs for WHERE clauses such as
@@ -5352,10 +5346,17 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
** jump over the OP_Next or OP_Prev instruction about to
** be coded. */
sqlite3VdbeAddOp2(v, OP_IfNotOpen, pIn->iCur,
- sqlite3VdbeCurrentAddr(v) + 2
+ sqlite3VdbeCurrentAddr(v) + 2 +
+ ((pLoop->wsFlags & WHERE_VIRTUALTABLE)==0)
);
VdbeCoverage(v);
}
+ if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
+ sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
+ sqlite3VdbeCurrentAddr(v)+2,
+ pIn->iBase, pIn->nPrefix);
+ VdbeCoverage(v);
+ }
}
sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
VdbeCoverage(v);