From c097e122b90fceccc510049eb1cb438fc0bec5e7 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 7 Sep 2016 13:30:40 +0000 Subject: [PATCH] Simplify the affinity handling logic in codeAllEqualityTerms(). Logically the same, just a little easier to read and understand. FossilOrigin-Name: bbab9621f512b04684163b98b6fc669c68038044 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wherecode.c | 42 +++++++++++++++++++----------------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index d9dec4830b..2b16d0533f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sfixes\sfrom\strunk. -D 2016-09-07T13:12:13.158 +C Simplify\sthe\saffinity\shandling\slogic\sin\scodeAllEqualityTerms().\s\sLogically\nthe\ssame,\sjust\sa\slittle\seasier\sto\sread\sand\sunderstand. +D 2016-09-07T13:30:40.808 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5017381e4853b1472e01d5bb926be1268eba429c @@ -467,7 +467,7 @@ F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 F src/where.c edbd73a87ba2e186928e9bfc14348b1bbb2628c5 F src/whereInt.h 14dd243e13b81cbb0a66063d38b70f93a7d6e613 -F src/wherecode.c b0d4febdd9de07ad68faadeacb30df9785f9b979 +F src/wherecode.c 43522ac811e2e0374603f9fc9a3dda4e1a81f470 F src/whereexpr.c e3db778ed205e982f31960896db71c50612ae009 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1522,7 +1522,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ab3f8f193a7ec36018bf26c9231a1a6a58b6a523 d8451fe84d09db6ec7e1bd5f0708ea1b5e85f3d6 -R 9be49f79015d1d1f29328535fe4e7eb6 +P 193f036c87857bd77577ceb462af5034c7cc77da +R 5310dec13b5e77c999328204c9245316 U drh -Z 2891e6cf4d042c296a4853701a08d60f +Z 06433047ae27fe630ae84491904304f6 diff --git a/manifest.uuid b/manifest.uuid index c5b7f13bc8..e850f3a033 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -193f036c87857bd77577ceb462af5034c7cc77da \ No newline at end of file +bbab9621f512b04684163b98b6fc669c68038044 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 0524ae2771..fdb986cbdf 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -658,30 +658,26 @@ static int codeAllEqualityTerms( sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j); } } - testcase( pTerm->eOperator & WO_ISNULL ); - testcase( pTerm->eOperator & WO_IN ); - if( (pTerm->eOperator & WO_ISNULL)==0 ){ - if( pTerm->eOperator & WO_IN ){ - if( pTerm->pExpr->flags & EP_xIsSelect ){ - /* No affinity ever needs to be (or should be) applied to a value - ** from the RHS of an "? IN (SELECT ...)" expression. The - ** sqlite3FindInIndex() routine has already ensured that the - ** affinity of the comparison has been applied to the value. */ - if( zAff ) zAff[j] = SQLITE_AFF_BLOB; + if( pTerm->eOperator & WO_IN ){ + if( pTerm->pExpr->flags & EP_xIsSelect ){ + /* No affinity ever needs to be (or should be) applied to a value + ** from the RHS of an "? IN (SELECT ...)" expression. The + ** sqlite3FindInIndex() routine has already ensured that the + ** affinity of the comparison has been applied to the value. */ + if( zAff ) zAff[j] = SQLITE_AFF_BLOB; + } + }else if( (pTerm->eOperator & WO_ISNULL)==0 ){ + Expr *pRight = pTerm->pExpr->pRight; + if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){ + sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); + VdbeCoverage(v); + } + if( zAff ){ + if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){ + zAff[j] = SQLITE_AFF_BLOB; } - }else{ - Expr *pRight = pTerm->pExpr->pRight; - if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){ - sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); - VdbeCoverage(v); - } - if( zAff ){ - if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){ - zAff[j] = SQLITE_AFF_BLOB; - } - if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){ - zAff[j] = SQLITE_AFF_BLOB; - } + if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){ + zAff[j] = SQLITE_AFF_BLOB; } } }