aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-07-31 15:44:44 +0000
committerdrh <drh@noemail.net>2014-07-31 15:44:44 +0000
commit4387006c18f99a63fffbed12ce30a0a099999c18 (patch)
tree9a684d623adc6ac28578c21da0a04087c4d4a257 /src/expr.c
parent0174ffa976f7a042a5ae1adaf58b1b125d5f0eb1 (diff)
downloadsqlite-4387006c18f99a63fffbed12ce30a0a099999c18.tar.gz
sqlite-4387006c18f99a63fffbed12ce30a0a099999c18.zip
Deactivate the DISTINCT in a SELECT on the right-hand side of an IN operator,
since it should not make any difference in the output but dues consume extra memory and CPU time. FossilOrigin-Name: f4cb53651b1e352fae7378878b830a902bcd9248
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c
index 72286dfdf..94647e514 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1624,7 +1624,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
}
if( eType==0 ){
- /* Could not found an existing table or index to use as the RHS b-tree.
+ /* Could not find an existing table or index to use as the RHS b-tree.
** We will have to generate an ephemeral table to do the job.
*/
u32 savedNQueryLoop = pParse->nQueryLoop;
@@ -1754,6 +1754,7 @@ int sqlite3CodeSubselect(
** Generate code to write the results of the select into the temporary
** table allocated and opened above.
*/
+ Select *pSelect = pExpr->x.pSelect;
SelectDest dest;
ExprList *pEList;
@@ -1761,13 +1762,15 @@ int sqlite3CodeSubselect(
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
dest.affSdst = (u8)affinity;
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
- pExpr->x.pSelect->iLimit = 0;
+ pSelect->iLimit = 0;
+ testcase( pSelect->selFlags & SF_Distinct );
+ pSelect->selFlags &= ~SF_Distinct;
testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
- if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
+ if( sqlite3Select(pParse, pSelect, &dest) ){
sqlite3KeyInfoUnref(pKeyInfo);
return 0;
}
- pEList = pExpr->x.pSelect->pEList;
+ pEList = pSelect->pEList;
assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
assert( pEList!=0 );
assert( pEList->nExpr>0 );