Hi,

The problem appears in latest amalgamation
"sqlite-amalgamation-201308152240.zip". I have attached  simple one-line
patches that fixes it.

In method sqlite3_blob_open(), the loop on line 72034 should break immediately
after "zFault" is set to "foreign key". All the iterations after "zFault"
is set to "foreign key" do not perform any useful work, at best they just set
"zFault" again to "foreign key".

There are two similar problems in the same file: 1. In method
sqlite3_blob_open(), the loop on line 72044 should break immediately after
"zFault" is set to "indexed".

2.In method sqlite3Fts3EvalPhrasePoslist(), the loop on line 125324 should
break immediately after "bOr" is set to "1".


======
Suggested patch:

--- sqlite3.c   2013-08-15 17:41:09.000000000 -0500
+++ sqlite3_patched.c   2013-08-15 21:44:22.011158211 -0500
@@ -72034,6 +72034,7 @@
           for(j=0; j<pFKey->nCol; j++){
             if( pFKey->aCol[j].iFrom==iCol ){
               zFault = "foreign key";
+              break;
             }
           }
         }
@@ -72044,6 +72045,7 @@
         for(j=0; j<pIdx->nColumn; j++){
           if( pIdx->aiColumn[j]==iCol ){
             zFault = "indexed";
+            break;
           }
         }
       }
@@ -125322,7 +125324,10 @@
     ** return NULL. Otherwise, the entry that corresponds to docid
     ** pCsr->iPrevId may lie earlier in the doclist buffer. */
     for(p=pExpr->pParent; p; p=p->pParent){
-      if( p->eType==FTSQUERY_OR ) bOr = 1;
+      if( p->eType==FTSQUERY_OR ){
+        bOr = 1;
+        break;
+      }
     }
     if( bOr==0 ) return SQLITE_OK;


-Chang
--- sqlite3.c   2013-08-15 17:41:09.000000000 -0500
+++ sqlite3_patched.c   2013-08-15 21:44:22.011158211 -0500
@@ -72034,6 +72034,7 @@
           for(j=0; j<pFKey->nCol; j++){
             if( pFKey->aCol[j].iFrom==iCol ){
               zFault = "foreign key";
+              break;
             }
           }
         }
@@ -72044,6 +72045,7 @@
         for(j=0; j<pIdx->nColumn; j++){
           if( pIdx->aiColumn[j]==iCol ){
             zFault = "indexed";
+            break;
           }
         }
       }
@@ -125322,7 +125324,10 @@
     ** return NULL. Otherwise, the entry that corresponds to docid 
     ** pCsr->iPrevId may lie earlier in the doclist buffer. */
     for(p=pExpr->pParent; p; p=p->pParent){
-      if( p->eType==FTSQUERY_OR ) bOr = 1;
+      if( p->eType==FTSQUERY_OR ){
+        bOr = 1;
+        break;
+      }
     }
     if( bOr==0 ) return SQLITE_OK;
 
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to