diff options
author | drh <drh@noemail.net> | 2016-03-16 01:16:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-03-16 01:16:30 +0000 |
commit | 47e1842e5bd5c5f467b0290f3fde9df69fa42a25 (patch) | |
tree | 69786029a35258e2ee2a76f5d023764e19a074f0 /src/select.c | |
parent | c5c67abb9ab2c58d41f75a41a1693e4b30e00bd5 (diff) | |
parent | 32f57d4c373c8f49b59f4a40149c136ef8a5632b (diff) | |
download | sqlite-47e1842e5bd5c5f467b0290f3fde9df69fa42a25.tar.gz sqlite-47e1842e5bd5c5f467b0290f3fde9df69fa42a25.zip |
Merge all recent enhancements from trunk.
FossilOrigin-Name: 6a7ee04b0ddac36a87d5ed2ac89a53e537f4d5a3
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/select.c b/src/select.c index c9bc389b2..a62581efc 100644 --- a/src/select.c +++ b/src/select.c @@ -4970,10 +4970,24 @@ int sqlite3Select( } /* Generate code to implement the subquery + ** + ** The subquery is implemented as a co-routine if all of these are true: + ** (1) The subquery is guaranteed to be the outer loop (so that it + ** does not need to be computed more than once) + ** (2) The ALL keyword after SELECT is omitted. (Applications are + ** allowed to say "SELECT ALL" instead of just "SELECT" to disable + ** the use of co-routines.) + ** (3) Co-routines are not disabled using sqlite3_test_control() + ** with SQLITE_TESTCTRL_OPTIMIZATIONS. + ** + ** TODO: Are there other reasons beside (1) to use a co-routine + ** implementation? */ - if( pTabList->nSrc==1 - && (p->selFlags & SF_All)==0 - && OptimizationEnabled(db, SQLITE_SubqCoroutine) + if( i==0 + && (pTabList->nSrc==1 + || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0) /* (1) */ + && (p->selFlags & SF_All)==0 /* (2) */ + && OptimizationEnabled(db, SQLITE_SubqCoroutine) /* (3) */ ){ /* Implement a co-routine that will return a single row of the result ** set on each invocation. |