Hi,

this problem is fixed in upstream version 3.5.9 of sqlite3. In the
meantime one could dump the attached patch in the debian/patches
directory of an unpacked source tree and build the package. I can
confirm that xmoto runs fine again with this fix applied.

Regards,
  Sebastian

--- sqlite.orig/src/select.c
+++ sqlite/src/select.c
@@ -3653,7 +3653,7 @@
 ** code base.  Then are intended to be called from within the debugger
 ** or from temporary "printf" statements inserted for debugging.
 */
-static void sqlite3PrintExpr(Expr *p){
+void sqlite3PrintExpr(Expr *p){
   if( p->token.z && p->token.n>0 ){
     sqlite3DebugPrintf("(%.*s", p->token.n, p->token.z);
   }else{
@@ -3669,7 +3669,7 @@
   }
   sqlite3DebugPrintf(")");
 }
-static void sqlite3PrintExprList(ExprList *pList){
+void sqlite3PrintExprList(ExprList *pList){
   int i;
   for(i=0; i<pList->nExpr; i++){
     sqlite3PrintExpr(pList->a[i].pExpr);
@@ -3678,7 +3678,7 @@
     }
   }
 }
-static void sqlite3PrintSelect(Select *p, int indent){
+void sqlite3PrintSelect(Select *p, int indent){
   sqlite3DebugPrintf("%*sSELECT(%p) ", indent, "", p);
   sqlite3PrintExprList(p->pEList);
   sqlite3DebugPrintf("\n");
--- sqlite.orig/src/where.c
+++ sqlite/src/where.c
@@ -718,6 +718,7 @@
   Expr *pExpr;
   Bitmask prereqLeft;
   Bitmask prereqAll;
+  Bitmask extraRight = 0;
   int nPattern;
   int isComplete;
   int noCase;
@@ -746,8 +747,8 @@
   if( ExprHasProperty(pExpr, EP_FromJoin) ){
     Bitmask x = getMask(pMaskSet, pExpr->iRightJoinTable);
     prereqAll |= x;
-    pTerm->prereqRight |= x-1; /* ON clause terms may not be used with an index
-                               ** on left table of a LEFT JOIN.  Ticket #3015 */
+    extraRight = x-1;  /* ON clause terms may not be used with an index
+                       ** on left table of a LEFT JOIN.  Ticket #3015 */
   }
   pTerm->prereqAll = prereqAll;
   pTerm->leftCursor = -1;
@@ -976,6 +977,11 @@
     }
   }
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
+
+  /* Prevent ON clause terms of a LEFT JOIN from being used to drive
+  ** an index for tables to the left of the join.
+  */
+  pTerm->prereqRight |= extraRight;
 }
 
 /*

Reply via email to