Bug #45220 | Queries of the pattern - WHERE <col> <condition> HAVING X ORDER BY `pk` fail | ||
---|---|---|---|
Submitted: | 31 May 2009 19:02 | Modified: | 3 Sep 2009 14:46 |
Reporter: | Patrick Crews | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.4 | OS: | Any |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | engine_condition_pushdown, ICP |
[31 May 2009 19:02]
Patrick Crews
[31 May 2009 19:03]
Patrick Crews
RQG failure output for this class of queries
Attachment: bug45220_failures.txt (text/plain), 2.31 KiB.
[2 Jun 2009 12:53]
Philip Stoev
What happens is that in queries containing HAVING and ORDER BY, the HAVING part is not observed at all and all rows are returned. See previous, already closed, bug #38199, bug #38072 , bug #37977.
[16 Jun 2009 14:27]
Patrick Crews
Test case produced by RQG (this round only found 1 failure of this type from 100k queries) /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `C` ( `pk` int(11) NOT NULL AUTO_INCREMENT, `date_key` date NOT NULL, `date_nokey` date NOT NULL, PRIMARY KEY (`pk`), KEY `date_key` (`date_key`) ) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `C` VALUES (1,'2007-12-01','2007-12-01'),(2,'0000-00-00','0000-00-00'),(3,'0000-00-00','0000-00-00'),(4,'2002-05-07','2002-05-07'),(5,'0000-00-00','0000-00-00'),(6,'0000-00-00','0000-00-00'),(7,'0000-00-00','0000-00-00'),(8,'0000-00-00','0000-00-00'),(9,'0000-00-00','0000-00-00'),(10,'2000-12-18','2000-12-18'),(11,'2005-11-13','2005-11-13'),(12,'0000-00-00','0000-00-00'),(13,'2003-11-12','2003-11-12'),(14,'2006-02-20','2006-02-20'),(15,'2005-02-12','2005-02-12'),(16,'2009-07-20','2009-07-20'),(17,'2005-02-24','2005-02-24'),(18,'0000-00-00','0000-00-00'),(19,'0000-00-00','0000-00-00'),(20,'0000-00-00','0000-00-00'); /* OPTIMIZER SETTINGS: */ SET SESSION optimizer_switch = 'firstmatch=off,index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,loosescan=off,materialization=off,semijoin=off'; SET SESSION optimizer_use_mrr = 'disable'; SET SESSION engine_condition_pushdown = '1'; SET SESSION join_cache_level = '1'; SET GLOBAL optimizer_switch = 'firstmatch=off,index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,loosescan=off,materialization=off,semijoin=off'; SET GLOBAL optimizer_use_mrr = 'disable'; SET GLOBAL engine_condition_pushdown = '1'; SET GLOBAL join_cache_level = '1'; /* ORIGINAL QUERY: SELECT OUTR . `date_nokey` AS X FROM C AS OUTR WHERE ( OUTR . `pk` , OUTR . `pk` ) IN ( SELECT DISTINCT INNR . `pk` AS X , INNR . `pk` AS Y FROM BB AS INNR WHERE INNR . `varchar_key` IS NOT NULL ) AND OUTR . `date_key` BETWEEN '2005-03-10' AND '2009-03-14' HAVING X <= 3 ORDER BY OUTR . `pk` , OUTR . `pk`; ORIGINAL DIFF: --- /var/folders/Pt/PtJd7NDTGgyOk3+iDGXrQk+++TI/-Tmp-///randgen11021-server0.dump 2009-06-16 15:14:23.000000000 +0100 +++ /var/folders/Pt/PtJd7NDTGgyOk3+iDGXrQk+++TI/-Tmp-///randgen11021-server1.dump 2009-06-16 15:14:23.000000000 +0100 @@ -0,0 +1 @@ +2005-11-13 SIMPLIFIED QUERY: SELECT `date_nokey` X FROM C WHERE ( `pk` , `pk` ) IN ( SELECT `pk` , `pk` ) AND `date_key` BETWEEN '2005-03-10' AND '2009-03-14' HAVING X <= 3 ORDER BY `pk` ; SIMPLIFIED DIFF: --- /var/folders/Pt/PtJd7NDTGgyOk3+iDGXrQk+++TI/-Tmp-///randgen11021-server0.dump 2009-06-16 15:14:23.000000000 +0100 +++ /var/folders/Pt/PtJd7NDTGgyOk3+iDGXrQk+++TI/-Tmp-///randgen11021-server1.dump 2009-06-16 15:14:23.000000000 +0100 @@ -0,0 +1,3 @@ +2005-11-13 +2006-02-20 +2007-12-01 */
[14 Jul 2009 22:08]
Patrick Crews
Setting engine_condition_pushdown to 0 will produce matching result sets on 5.1 and azalea.
[3 Sep 2009 14:46]
Evgeny Potemkin
Duplicate of the bug#45227.
[3 Sep 2009 14:48]
Evgeny Potemkin
Duplicate of the bug#45227.
[3 Sep 2009 14:48]
Evgeny Potemkin
Duplicate of the bug#45227.