Fixed bug#6601, thanks to S7.
Added test cases for SQL queries with large IN conditions.