OR in sqlite3: error?

my SQL query in sqlite3 ends with an OR statement. It looks like this:

select (...) from T1, T2, .... Tn where (...) and ( (T5.v='s1' and T6.v='s2' and T7.v='s3') OR (T5.v='s4' and T6.v='s5' and T7.v='s6') ) 

the query returns no result.

However, each individual OR condition returns multiple rows (!)

 where (...) and ( (T5.v='s1' and T6.v='s2' and T7.v='s3') ) 

and

 where (...) and ( (T5.v='s4' and T6.v='s5' and T7.v='s6') ) 

Is this a bug in sqlite3 or is it me?

 $ sqlite3 -version 3.6.20 

update: I have three non-unique indexes on T5.v, T6.v and T7.v

+7
source share
1 answer

As mentioned in the comments, the sqlite 3-6-22 change log includes:

 Fix bugs that can (rarely) lead to incorrect query results when the CAST or OR operators are used in the WHERE clause of a query. 

Another OR error was fixed in 3-7-4 :

http://www.sqlite.org/src/info/80ba201079

Another in 3-7-14-1 :

 Fix a bug (ticket [d02e1406a58ea02d]]) that causes a segfault on a LEFT JOIN that includes an OR in the ON clause. 

and one more at 3-7-17 :

http://www.sqlite.org/src/info/f2369304e4

I would suggest upgrading to sqlite and see if it fixes the problem.

+1
source

All Articles