Bug #79203 | incorrect result set with block_nested_loop=on | ||
---|---|---|---|
Submitted: | 10 Nov 2015 11:59 | Modified: | 10 Nov 2015 13:25 |
Reporter: | Heike Reuter | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.6.25 | OS: | Debian (Debian GNU/Linux 7.8 (wheezy)) |
Assigned to: | CPU Architecture: | Any | |
Tags: | block_nested_loop |
[10 Nov 2015 11:59]
Heike Reuter
[10 Nov 2015 12:03]
Heike Reuter
Version is 5.6.25
[10 Nov 2015 13:04]
MySQL Verification Team
mysql 5.6 > select `view_object`.`id`, `view_object`.`active`, `view_object`.`activefrom`, `view_object`.`activeto`, `view_object`.`title` -> from view_object -> where (view_object.active = 1 or (view_object.activefrom < '2015-11-01 12:00:00' and view_object.activeto > '2015-11-21 12:00:00' ) ) and ( -> select -> if(EXISTS(select 1 from type2object, typeA -> where typeA.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='typeA' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeA' and type2object.typeid='firstA'), -> 1) && -> if(EXISTS(select 1 from type2object, view_typeB -> where view_typeB.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='typeB' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeB' and type2object.typeid='firstB'), -> 1) && -> if(EXISTS(select 1 from type2object, view_typeC -> where view_typeC.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='oxgroups' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeC' and type2object.typeid in ('firstC') ), -> 1) -> ); Empty set (0.01 sec) mysql 5.6 > SHOW VARIABLES LIKE "%VERSION%"; +-------------------------+---------------------------------------+ | Variable_name | Value | +-------------------------+---------------------------------------+ | innodb_version | 5.6.28 | | protocol_version | 10 | | slave_type_conversions | | | version | 5.6.28 | | version_comment | Source distribution PULL: 2015-NOV-07 | | version_compile_machine | x86_64 | | version_compile_os | Win64 | +-------------------------+---------------------------------------+ 7 rows in set (0.00 sec) mysql 5.5 > select `view_object`.`id`, `view_object`.`active`, `view_object`.`activefrom`, `view_object`.`activeto`, `view_object`.`title` -> from view_object -> where (view_object.active = 1 or (view_object.activefrom < '2015-11-01 12:00:00' and view_object.activeto > '2015-11-21 12:00:00' ) ) and ( -> select -> if(EXISTS(select 1 from type2object, typeA -> where typeA.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='typeA' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeA' and type2object.typeid='firstA'), -> 1) && -> if(EXISTS(select 1 from type2object, view_typeB -> where view_typeB.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='typeB' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeB' and type2object.typeid='firstB'), -> 1) && -> if(EXISTS(select 1 from type2object, view_typeC -> where view_typeC.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='oxgroups' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeC' and type2object.typeid in ('firstC') ), -> 1) -> ); +--------------+--------+---------------------+---------------------+---------------+ | ID | ACTIVE | ACTIVEFROM | ACTIVETO | TITLE | +--------------+--------+---------------------+---------------------+---------------+ | firstObject | 1 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | first object | | secondObject | 1 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | second object | +--------------+--------+---------------------+---------------------+---------------+ 2 rows in set (0.02 sec) mysql 5.5 > SHOW VARIABLES LIKE "%VERSION%"; +-------------------------+---------------------------------------+ | Variable_name | Value | +-------------------------+---------------------------------------+ | innodb_version | 5.5.47 | | protocol_version | 10 | | slave_type_conversions | | | version | 5.5.47 | | version_comment | Source distribution PULL: 2015-NOV-07 | | version_compile_machine | AMD64 | | version_compile_os | Win64 | +-------------------------+---------------------------------------+ 7 rows in set (0.13 sec)
[10 Nov 2015 13:25]
MySQL Verification Team
Thank you for the bug report. Only 5.6 affected. mysql 5.7 > select `view_object`.`id`, `view_object`.`active`, `view_object`.`activefrom`, `view_object`.`activeto`, `view_object`.`title` -> from view_object -> where (view_object.active = 1 or (view_object.activefrom < '2015-11-01 12:00:00' and view_object.activeto > '2015-11-21 12:00:00' ) ) and ( -> select -> if(EXISTS(select 1 from type2object, typeA -> where typeA.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='typeA' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeA' and type2object.typeid='firstA'), -> 1) && -> if(EXISTS(select 1 from type2object, view_typeB -> where view_typeB.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='typeB' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeB' and type2object.typeid='firstB'), -> 1) && -> if(EXISTS(select 1 from type2object, view_typeC -> where view_typeC.id=type2object.typeid and type2object.objectid=view_object.id and type2object.type='oxgroups' LIMIT 1), -> EXISTS(select type2object.id from type2object -> where type2object.objectid=view_object.id and type2object.type='typeC' and type2object.typeid in ('firstC') ), -> 1) -> ); +--------------+--------+---------------------+---------------------+---------------+ | ID | ACTIVE | ACTIVEFROM | ACTIVETO | TITLE | +--------------+--------+---------------------+---------------------+---------------+ | firstObject | 1 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | first object | | secondObject | 1 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | second object | +--------------+--------+---------------------+---------------------+---------------+ 2 rows in set (0.00 sec) mysql 5.7 > show variables like "version"; +---------------+--------+ | Variable_name | Value | +---------------+--------+ | version | 5.7.10 | +---------------+--------+ 1 row in set (0.00 sec) mysql 5.7 >
[2 Jun 2021 7:24]
Bernhard Scheffold
There is a regression for this bug in MySQL 5.7.29. A workaround is to set all optimizer switches to off: set global optimizer_switch = 'index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,mrr=off,mrr_cost_based=off,block_nested_loop=off,batched_key_access=off,materialization=off,semijoin=off,loosescan=off,firstmatch=off,duplicateweedout=off,subquery_materialization_cost_based=off,use_index_extensions=off,condition_fanout_filter=off,derived_merge=off';