Bug #717 skipped rows from result
Submitted: 25 Jun 2003 5:30 Modified: 3 Jul 2003 6:47
Reporter: Artem V. Ryabov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.0.13, 4.0.5 OS:Linux (Linux)
Assigned to: Alexey Botchkov CPU Architecture:Any

[25 Jun 2003 5:30] Artem V. Ryabov
Description:
next queries show problem:
------------------------
DROP TABLE IF EXISTS `goodtree`;
CREATE TABLE `goodtree` (
  `node` int(11) NOT NULL default '0',
  `maxchild` int(11) NOT NULL default '0',
  PRIMARY KEY  (`node`),
  KEY `maxchild` (`maxchild`)
);
INSERT INTO `goodtree` (`node`, `maxchild`) VALUES (4,4),(5,5),(1,244);
select * from goodtree g1, goodtree g2 
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
===========
Empty set (0.00 sec)
===========
select * from goodtree g1, goodtree g2 
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild 
 and g1.node=1;
===========
+------+----------+------+----------+
| node | maxchild | node | maxchild |
+------+----------+------+----------+
|    1 |      244 |    4 |        4 |
|    1 |      244 |    5 |        5 |
+------+----------+------+----------+
2 rows in set (0.00 sec)
===========
select * from goodtree g1, goodtree g2 
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
===========
+------+----------+------+----------+
| node | maxchild | node | maxchild |
+------+----------+------+----------+
|    5 |        5 |    5 |        5 |
|    1 |      244 |    5 |        5 |
+------+----------+------+----------+
2 rows in set (0.00 sec)
===========

------------------------
as you see 1-st and 3-rd select equal, but result different and both times wrong.

but if query will be this:
------------------------
select * from goodtree g2, goodtree g1
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
=========
+------+----------+------+----------+
| node | maxchild | node | maxchild |
+------+----------+------+----------+
|    4 |        4 |    1 |      244 |
|    4 |        4 |    4 |        4 |
|    5 |        5 |    5 |        5 |
|    5 |        5 |    1 |      244 |
+------+----------+------+----------+
4 rows in set (0.00 sec)
=========
all ok.

How to repeat:
DROP TABLE IF EXISTS `goodtree`;
CREATE TABLE `goodtree` (
  `node` int(11) NOT NULL default '0',
  `maxchild` int(11) NOT NULL default '0',
  PRIMARY KEY  (`node`),
  KEY `maxchild` (`maxchild`)
);
INSERT INTO `goodtree` (`node`, `maxchild`) VALUES (4,4),(5,5),(1,244);
select * from goodtree g1, goodtree g2 
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
select * from goodtree g1, goodtree g2 
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild 
 and g1.node=1;
select * from goodtree g1, goodtree g2 
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
select * from goodtree g2, goodtree g1
 where g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
[25 Jun 2003 5:33] Artem V. Ryabov
I check MyISAM, ISAM and InnoDB - all times bug present.
[2 Jul 2003 22:30] Alexey Botchkov
Well, it looks like a nasty bug
[3 Jul 2003 6:47] Alexey Botchkov
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html