diff options
author | drh <drh@noemail.net> | 2016-05-04 14:45:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-05-04 14:45:30 +0000 |
commit | 91da70728092c246963b7521c51361e4d007f3cf (patch) | |
tree | 9085b0ccbed9b6126ab233a29343a27790aae8a4 /src | |
parent | 582c080289f2152eea2e0dc5ae33fff38a571e9f (diff) | |
download | sqlite-91da70728092c246963b7521c51361e4d007f3cf.tar.gz sqlite-91da70728092c246963b7521c51361e4d007f3cf.zip |
Only disable the one-pass DELETE optimization if the WHERE clause contains
a correlated subquery. Uncorrelated subqueries are allowed. This is a
refinement of check-in [3f221f592a9a1] that is the fix for
ticket [dc6ebeda9396087].
FossilOrigin-Name: aae389692a2ed2cc92151d51fb2cd5a16921c469
Diffstat (limited to 'src')
-rw-r--r-- | src/delete.c | 2 | ||||
-rw-r--r-- | src/resolve.c | 1 | ||||
-rw-r--r-- | src/sqliteInt.h | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/src/delete.c b/src/delete.c index 258b39cc3..06a016438 100644 --- a/src/delete.c +++ b/src/delete.c @@ -374,7 +374,7 @@ void sqlite3DeleteFrom( #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ { u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; - if( pWhere && ExprHasProperty(pWhere, EP_Subquery) ) bComplex = 1; + if( sNC.ncFlags & NC_VarSelect ) bComplex = 1; wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW); if( HasRowid(pTab) ){ /* For a rowid table, initialize the RowSet to an empty set */ diff --git a/src/resolve.c b/src/resolve.c index 8e290af12..77ce37f6d 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -763,6 +763,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ assert( pNC->nRef>=nRef ); if( nRef!=pNC->nRef ){ ExprSetProperty(pExpr, EP_VarSelect); + pNC->ncFlags |= NC_VarSelect; } } break; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 76bf80962..783f0f56c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2597,6 +2597,7 @@ struct NameContext { #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ #define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ +#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ /* |