diff options
author | drh <drh@noemail.net> | 2016-09-06 17:13:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-09-06 17:13:40 +0000 |
commit | c7a77ae1c61f66a2ec94de49a4a92872faf4f0c9 (patch) | |
tree | 7e216aa7cbf4c1eef25f742e5c8a7dad1545bae6 /src/wherecode.c | |
parent | aaf8a0643e46e6c4a7ca5b83f0b779c21499b542 (diff) | |
download | sqlite-c7a77ae1c61f66a2ec94de49a4a92872faf4f0c9.tar.gz sqlite-c7a77ae1c61f66a2ec94de49a4a92872faf4f0c9.zip |
Avoid unnecessary memory allocations for aiMap in codeEqualityConstraints.
FossilOrigin-Name: 70319c3d76abd1e403fcf2a62668736b92a5f3d5
Diffstat (limited to 'src/wherecode.c')
-rw-r--r-- | src/wherecode.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/wherecode.c b/src/wherecode.c index 0b1165f02..0524ae277 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -442,11 +442,6 @@ static int codeEqualityTerm( if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++; } - if( nEq>1 ){ - aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq); - if( !aiMap ) return 0; - } - if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0); }else{ @@ -475,9 +470,12 @@ static int codeEqualityTerm( pX->pLeft = pLhs->a[0].pExpr; }else{ pLeft->x.pList = pLhs; + aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq); + testcase( aiMap==0 ); } pX->x.pSelect->pEList = pRhs; eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap); + testcase( aiMap!=0 && aiMap[0]!=0 ); pX->x.pSelect->pEList = pOrigRhs; pLeft->x.pList = pOrigLhs; pX->pLeft = pLeft; |