Bug #30672 | Wrong optimization when using a join and a function | ||
---|---|---|---|
Submitted: | 28 Aug 2007 15:49 | Modified: | 12 Oct 2007 14:12 |
Reporter: | Giorgio Calderone | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.1.20 | OS: | Linux |
Assigned to: | CPU Architecture: | Any |
[28 Aug 2007 15:49]
Giorgio Calderone
[28 Aug 2007 16:56]
Hartmut Holzgraefe
verified on 5.1.18, current 5.1bk doesn't seem to be affected anymore though attaching mysqltest formatted test case ...
[28 Aug 2007 16:57]
Hartmut Holzgraefe
mysqltest test case
Attachment: bug30672.tgz (application/x-gtar, text), 1.29 KiB.
[2 Oct 2007 21:54]
Jan Larsen
Version 5.037 does not have this bug either, but 5.045 does have it. Seemingly it is not a good idea to run a version above that if using UDF.
[12 Oct 2007 14:11]
Konstantin Osipov
mysql> SELECT * -> FROM main INNER JOIN ref USING (id) -> WHERE ( (ref.flag = 1) OR (main.f < 200)); +------+------------+------+------+ | id | c | f | flag | +------+------------+------+------+ | 0 | NORTH | 0 | 1 | | 0 | NORTH-EAST | 45 | 1 | | 1 | EAST | 90 | 0 | | 1 | SOUTH-EAST | 135 | 0 | | 2 | SOUTH | 180 | 0 | +------+------------+------+------+ 5 rows in set (0.02 sec) mysql> mysql> # mysql> #The following query uses the 'fake' function and the result is wrong mysql> #(2 records): mysql> # mysql> SELECT * -> FROM main INNER JOIN ref USING (id) -> WHERE ((ref.flag = 1) OR (fiden(main.f) < 200)); +------+------------+------+------+ | id | c | f | flag | +------+------------+------+------+ | 0 | NORTH | 0 | 1 | | 0 | NORTH-EAST | 45 | 1 | | 1 | EAST | 90 | 0 | | 1 | SOUTH-EAST | 135 | 0 | | 2 | SOUTH | 180 | 0 | +------+------------+------+------+ 5 rows in set (0.00 sec) mysql> select version(); +---------------------------+ | version() | +---------------------------+ | 5.0.50-valgrind-max-debug | +---------------------------+ 1 row in set (0.00 sec) Can't repeat in the latest tree. This is likely a duplicate of Bug#31035