Index: src/insert.c ================================================================== --- src/insert.c +++ src/insert.c @@ -645,10 +645,11 @@ rc = sqlite3Select(pParse, pSelect, &dest); regFromSelect = dest.iSdst; assert( pParse->nErr==0 || rc ); if( rc || db->mallocFailed ) goto insert_cleanup; sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield); + sqlite3ClearTempRegCache(pParse); sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */ assert( pSelect->pEList ); nColumn = pSelect->pEList->nExpr; /* Set useTempTable to TRUE if the result of the SELECT statement Index: src/select.c ================================================================== --- src/select.c +++ src/select.c @@ -2749,10 +2749,11 @@ VdbeComment((v, "left SELECT")); pPrior->iLimit = regLimitA; explainSetInteger(iSub1, pParse->iNextSelectId); sqlite3Select(pParse, pPrior, &destA); sqlite3VdbeAddOp1(v, OP_EndCoroutine, regAddrA); + sqlite3ClearTempRegCache(pParse); sqlite3VdbeJumpHere(v, j1); /* Generate a coroutine to evaluate the SELECT statement on ** the right - the "B" select */ @@ -2766,10 +2767,11 @@ explainSetInteger(iSub2, pParse->iNextSelectId); sqlite3Select(pParse, p, &destB); p->iLimit = savedLimit; p->iOffset = savedOffset; sqlite3VdbeAddOp1(v, OP_EndCoroutine, regAddrB); + sqlite3ClearTempRegCache(pParse); /* Generate a subroutine that outputs the current row of the A ** select as the next output row of the compound select. */ VdbeNoopComment((v, "Output routine for A"));