pkubat / rpms / sqlite

Forked from rpms/sqlite 4 years ago
Clone
Debarshi Ray f78f730
From c098d918e1e19088be9659c409f1a6fa32b0efe6 Mon Sep 17 00:00:00 2001
Debarshi Ray f78f730
From: "D. Richard Hipp" <drh@hwaci.com>
Debarshi Ray f78f730
Date: Mon, 28 Oct 2013 20:15:56 +0000
Debarshi Ray f78f730
Subject: [PATCH] Do not use transitive WHERE-clause constraints on LEFT JOINs.
Debarshi Ray f78f730
 Fix for ticket [c620261b5b5dc].
Debarshi Ray f78f730
Debarshi Ray f78f730
---
Debarshi Ray f78f730
 src/where.c | 5 ++++-
Debarshi Ray f78f730
 1 file changed, 4 insertions(+), 1 deletion(-)
Debarshi Ray f78f730
Debarshi Ray f78f730
diff --git a/src/where.c b/src/where.c
Debarshi Ray f78f730
index 266dc92..4868a7a 100644
Debarshi Ray f78f730
--- a/src/where.c
Debarshi Ray f78f730
+++ b/src/where.c
Debarshi Ray f78f730
@@ -878,7 +878,10 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
Debarshi Ray f78f730
     iColumn = pScan->aEquiv[pScan->iEquiv-1];
Debarshi Ray f78f730
     while( (pWC = pScan->pWC)!=0 ){
Debarshi Ray f78f730
       for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
Debarshi Ray f78f730
-        if( pTerm->leftCursor==iCur && pTerm->u.leftColumn==iColumn ){
Debarshi Ray f78f730
+        if( pTerm->leftCursor==iCur
Debarshi Ray f78f730
+         && pTerm->u.leftColumn==iColumn
Debarshi Ray f78f730
+         && (pScan->iEquiv<=2 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
Debarshi Ray f78f730
+        ){
Debarshi Ray f78f730
           if( (pTerm->eOperator & WO_EQUIV)!=0
Debarshi Ray f78f730
            && pScan->nEquiv<ArraySize(pScan->aEquiv)
Debarshi Ray f78f730
           ){
Debarshi Ray f78f730
-- 
Debarshi Ray f78f730
1.8.4.2
Debarshi Ray f78f730