diff options
author | drh <drh@noemail.net> | 2013-03-06 01:55:27 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-03-06 01:55:27 +0000 |
commit | 459f63e7edb1d04af7f70bb9c898929e0a188101 (patch) | |
tree | 51d0a4671bba954c29eaa2ddc5ef4b8c74e60607 /src | |
parent | a0272d82558bf28235d7e3e9f3dac7be8e06188c (diff) | |
download | sqlite-459f63e7edb1d04af7f70bb9c898929e0a188101.tar.gz sqlite-459f63e7edb1d04af7f70bb9c898929e0a188101.zip |
Fix a bug (ticket [fc7bd6358f59]) that caused incorrect query results in
three way queries that involved comparing INTEGER and TEXT columns for
equality.
FossilOrigin-Name: 7097241c1220ada318f8eda938c3e3430b94a606
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/where.c b/src/where.c index 3db76b533..aa81dabd4 100644 --- a/src/where.c +++ b/src/where.c @@ -643,9 +643,8 @@ static u16 operatorMask(int op){ ** then try for the one with no dependencies on <expr> - in other words where ** <expr> is a constant expression of some kind. Only return entries of ** the form "X <op> Y" where Y is a column in another table if no terms of -** the form "X <op> <const-expr>" exist. Other than this priority, if there -** are two or more terms that match, then the choice of which term to return -** is arbitrary. +** the form "X <op> <const-expr>" exist. If no terms with a constant RHS +** exist, try to return a term that does not use WO_EQUIV. */ static WhereTerm *findTerm( WhereClause *pWC, /* The WHERE clause to be searched */ @@ -704,8 +703,12 @@ static WhereTerm *findTerm( continue; } } - pResult = pTerm; - if( pTerm->prereqRight==0 ) goto findTerm_success; + if( pTerm->prereqRight==0 ){ + pResult = pTerm; + goto findTerm_success; + }else if( pResult==0 ){ + pResult = pTerm; + } } if( (pTerm->eOperator & WO_EQUIV)!=0 && nEquiv<ArraySize(aEquiv) @@ -4231,6 +4234,7 @@ static Bitmask codeOneLoopStart( addrNxt = pLevel->addrNxt; sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); + sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); VdbeComment((v, "pk")); pLevel->op = OP_Noop; |