1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Fix a bug in where.c where a non-temp register was being incorrectly deallocated. Ticket #3408. (CVS 5758)

FossilOrigin-Name: 59d2e89e2181c26b18eac68ccc80ea3018f70a5e
This commit is contained in:
danielk1977
2008-10-01 08:43:03 +00:00
parent f94a173a95
commit 2d60549926
4 changed files with 59 additions and 16 deletions

View File

@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.322 2008/09/06 14:19:11 danielk1977 Exp $
** $Id: where.c,v 1.323 2008/10/01 08:43:03 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -1784,9 +1784,7 @@ static int codeEqualityTerm(
Vdbe *v = pParse->pVdbe;
int iReg; /* Register holding results */
if( iTarget<=0 ){
iReg = iTarget = sqlite3GetTempReg(pParse);
}
assert( iTarget>0 );
if( pX->op==TK_EQ ){
iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);
}else if( pX->op==TK_ISNULL ){
@@ -2414,16 +2412,17 @@ WhereInfo *sqlite3WhereBegin(
** construct.
*/
int r1;
int rtmp = sqlite3GetTempReg(pParse);
pTerm = findTerm(&wc, iCur, -1, notReady, WO_EQ|WO_IN, 0);
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
assert( pTerm->leftCursor==iCur );
assert( omitTable==0 );
r1 = codeEqualityTerm(pParse, pTerm, pLevel, 0);
r1 = codeEqualityTerm(pParse, pTerm, pLevel, rtmp);
nxt = pLevel->nxt;
sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, nxt);
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, nxt, r1);
sqlite3ReleaseTempReg(pParse, r1);
sqlite3ReleaseTempReg(pParse, rtmp);
VdbeComment((v, "pk"));
pLevel->op = OP_Noop;
}else if( pLevel->flags & WHERE_ROWID_RANGE ){