How this solve the bug? 

The function binaryCompareP5 is called (in query compile time) to know what 
affinity will be used to make the comparition between the expression "(c2 <= 
'2')", 
but that function are returning when index not exists SQLITE_AFF_INTEGER and 
not SQLITE_AFF_NONE because affinity of left expression "c2" (is a collumn) is 
INTEGER and 
rigth expression "'2'" is TEXT! 


----- Mensagem original ----- 
De: "Israel Lins Albuquerque" <israel...@polibrasnet.com.br> 
Para: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> 
Enviadas: Quarta-feira, 9 de Junho de 2010 16:34:22 
Assunto: Re: [sqlite] [BUG] Adding an index changes query result 



I make the possible soluction I did't know if this is the best but is this: 

/************************************************************************************/
 
Index: D:/FS_trunk/devpalm_01/poli_sqlite_lib/src/expr.c 
=================================================================== 
--- D:/FS_trunk/devpalm_01/poli_sqlite_lib/src/expr.c (revisão 323) 
+++ D:/FS_trunk/devpalm_01/poli_sqlite_lib/src/expr.c (cópia de trabalho) 
@@ -52,6 +52,18 @@ 
assert( pExpr->pTab && j<pExpr->pTab->nCol ); 
return pExpr->pTab->aCol[j].affinity; 
} 
+ if( op==TK_REGISTER ){ 
+ op = pExpr->op2; /* This only happens with SQLITE_ENABLE_STAT2 */ 
+ } 
+ if (op == TK_STRING) { 
+ return SQLITE_AFF_TEXT; 
+ } 
+ if (op == TK_INTEGER) { 
+ return SQLITE_AFF_NUMERIC; 
+ } 
+ if (op == TK_FLOAT) { 
+ return SQLITE_AFF_REAL; 
+ } 
return pExpr->affinity; 
} 

@@ -124,10 +136,10 @@ 
char sqlite3CompareAffinity(Expr *pExpr, char aff2){ 
char aff1 = sqlite3ExprAffinity(pExpr); 
if( aff1 && aff2 ){ 
- /* Both sides of the comparison are columns. If one has numeric 
+ /* Both sides of the comparison are columns. If both has numeric 
** affinity, use that. Otherwise use no affinity. 
*/ 
- if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){ 
+ if( sqlite3IsNumericAffinity(aff1) && sqlite3IsNumericAffinity(aff2) ){ 
return SQLITE_AFF_NUMERIC; 
}else{ 
return SQLITE_AFF_NONE; 
/************************************************************************************/
 

-- 

Atenciosamente/Regards, 

Israel Lins Albuquerque 
Desenvolvimento/Development 
Polibrás Brasil Software Ltda. 


_______________________________________________ 
sqlite-users mailing list 
sqlite-users@sqlite.org 
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 


-- 

Atenciosamente/Regards, 

Israel Lins Albuquerque 
Desenvolvimento/Development 
Polibrás Brasil Software Ltda. 


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to