aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c10
-rw-r--r--src/select.c4
-rw-r--r--src/sqliteInt.h2
-rw-r--r--src/where.c4
4 files changed, 12 insertions, 8 deletions
diff --git a/src/expr.c b/src/expr.c
index 9ffc3bade..acd86ac1c 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2378,12 +2378,16 @@ int sqlite3ExprIsTableConstant(Expr *p, int iCur){
}
/*
-** Check pExpr to see if it is an invariant constraint on data source pSrc.
+** Check pExpr to see if it is an constraint on the single data source pSrc.
+** In other words, check to see if pExpr constrains pSrc but does not depend
+** on any other tables or data sources anywhere else in the query. Return
+** true (non-zero) if pExpr is a constraint on pSrc only.
+**
** This is an optimization. False negatives will perhaps cause slower
** queries, but false positives will yield incorrect answers. So when in
** doubt, return 0.
**
-** To be an invariant constraint, the following must be true:
+** To be an single-source constraint, the following must be true:
**
** (1) pExpr cannot refer to any table other than pSrc->iCursor.
**
@@ -2400,7 +2404,7 @@ int sqlite3ExprIsTableConstant(Expr *p, int iCur){
** operand of a RIGHT JOIN, then pExpr must be from the WHERE
** clause, not an ON clause.
*/
-int sqlite3ExprIsTableConstraint(Expr *pExpr, const SrcItem *pSrc){
+int sqlite3ExprIsSingleTableConstraint(Expr *pExpr, const SrcItem *pSrc){
if( pSrc->fg.jointype & JT_LTORJ ){
return 0; /* rule (3) */
}
diff --git a/src/select.c b/src/select.c
index 079158b4d..43dec7d20 100644
--- a/src/select.c
+++ b/src/select.c
@@ -5222,7 +5222,7 @@ static int pushDownWhereTerms(
}
}
-#if 0 /* Legacy code. Checks now done by sqlite3ExprIsTableConstraint() */
+#if 0 /* These checks now done by sqlite3ExprIsSingleTableConstraint() */
if( isLeftJoin
&& (ExprHasProperty(pWhere,EP_OuterON)==0
|| pWhere->w.iJoin!=iCursor)
@@ -5236,7 +5236,7 @@ static int pushDownWhereTerms(
}
#endif
- if( sqlite3ExprIsTableConstraint(pWhere, pSrc) ){
+ if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrc) ){
nChng++;
pSubq->selFlags |= SF_PushDown;
while( pSubq ){
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index ea12116ca..935d03805 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -4906,7 +4906,7 @@ int sqlite3ExprIsConstantNotJoin(Expr*);
int sqlite3ExprIsConstantOrFunction(Expr*, u8);
int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);
int sqlite3ExprIsTableConstant(Expr*,int);
-int sqlite3ExprIsTableConstraint(Expr*,const SrcItem*);
+int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcItem*);
#ifdef SQLITE_ENABLE_CURSOR_HINTS
int sqlite3ExprContainsSubquery(Expr*);
#endif
diff --git a/src/where.c b/src/where.c
index f517150e1..527e1a3a6 100644
--- a/src/where.c
+++ b/src/where.c
@@ -922,7 +922,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
** WHERE clause (or the ON clause of a LEFT join) that constrain which
** rows of the target table (pSrc) that can be used. */
if( (pTerm->wtFlags & TERM_VIRTUAL)==0
- && sqlite3ExprIsTableConstraint(pExpr, pSrc)
+ && sqlite3ExprIsSingleTableConstraint(pExpr, pSrc)
){
pPartial = sqlite3ExprAnd(pParse, pPartial,
sqlite3ExprDup(pParse->db, pExpr, 0));
@@ -1183,7 +1183,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
if( (pTerm->wtFlags & TERM_VIRTUAL)==0
- && sqlite3ExprIsTableConstraint(pExpr, pItem)
+ && sqlite3ExprIsSingleTableConstraint(pExpr, pItem)
){
sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
}