From: Tor Didriksen Date: February 2 2011 9:18am Subject: bzr commit into mysql-5.5 branch (tor.didriksen:3295) Bug#52123 List-Archive: http://lists.mysql.com/commits/130188 X-Bug: 52123 Message-Id: <20110202091847.A105F3768@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7324187081242617768==" --===============7324187081242617768== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///export/home/didrik/repo/5.5/ based on revid:ole.john.aske@stripped 3295 Tor Didriksen 2011-02-02 Backport of fix for Bug#52123 modified: mysql-test/r/func_group.result mysql-test/t/func_group.test sql/item_sum.cc sql/item_sum.h === modified file 'mysql-test/r/func_group.result' --- a/mysql-test/r/func_group.result 2010-12-21 12:32:15 +0000 +++ b/mysql-test/r/func_group.result 2011-02-02 09:18:44 +0000 @@ -1739,6 +1739,16 @@ SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa') # End of 5.1 tests # +# Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(), +# file .\item_sum.cc, line 587 +# +CREATE TABLE t1(a int, KEY(a)); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 FROM t1 ORDER BY AVG(DISTINCT a); +1 +1 +DROP TABLE t1; +# # Bug#55648: Server crash on MIN/MAX on maximum time value # CREATE TABLE t1(c1 TIME NOT NULL); === modified file 'mysql-test/t/func_group.test' --- a/mysql-test/t/func_group.test 2010-12-21 12:32:15 +0000 +++ b/mysql-test/t/func_group.test 2011-02-02 09:18:44 +0000 @@ -1120,6 +1120,17 @@ SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa') --echo # --echo End of 5.1 tests +### +--echo # +--echo # Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(), +--echo # file .\item_sum.cc, line 587 +--echo # + +CREATE TABLE t1(a int, KEY(a)); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 FROM t1 ORDER BY AVG(DISTINCT a); +DROP TABLE t1; + --echo # --echo # Bug#55648: Server crash on MIN/MAX on maximum time value --echo # === modified file 'sql/item_sum.cc' --- a/sql/item_sum.cc 2010-12-29 00:26:31 +0000 +++ b/sql/item_sum.cc 2011-02-02 09:18:44 +0000 @@ -556,24 +556,27 @@ Item *Item_sum::set_arg(uint i, THD *thd int Item_sum::set_aggregator(Aggregator::Aggregator_type aggregator) { - if (aggr) + /* + Dependent subselects may be executed multiple times, making + set_aggregator to be called multiple times. The aggregator type + will be the same, but it needs to be reset so that it is + reevaluated with the new dependent data. + This function may also be called multiple times during query optimization. + In this case, the type may change, so we delete the old aggregator, + and create a new one. + */ + if (aggr && aggregator == aggr->Aggrtype()) { - /* - Dependent subselects may be executed multiple times, making - set_aggregator to be called multiple times. The aggregator type - will be the same, but it needs to be reset so that it is - reevaluated with the new dependent data. - */ - DBUG_ASSERT(aggregator == aggr->Aggrtype()); aggr->clear(); return FALSE; } + + delete aggr; switch (aggregator) { case Aggregator::DISTINCT_AGGREGATOR: aggr= new Aggregator_distinct(this); break; - case Aggregator::SIMPLE_AGGREGATOR: aggr= new Aggregator_simple(this); break; === modified file 'sql/item_sum.h' --- a/sql/item_sum.h 2011-01-17 09:39:59 +0000 +++ b/sql/item_sum.h 2011-02-02 09:18:44 +0000 @@ -461,10 +461,9 @@ public: */ virtual void no_rows_in_result() { - if (!aggr) - set_aggregator(with_distinct ? - Aggregator::DISTINCT_AGGREGATOR : - Aggregator::SIMPLE_AGGREGATOR); + set_aggregator(with_distinct ? + Aggregator::DISTINCT_AGGREGATOR : + Aggregator::SIMPLE_AGGREGATOR); aggregator_clear(); } virtual void make_unique() { force_copy_fields= TRUE; } @@ -515,11 +514,10 @@ public: quick_group= with_distinct ? 0 : 1; } - /** + /* Set the type of aggregation : DISTINCT or not. - Called when the final determination is done about the aggregation - type and the object is about to be used. + May be called multiple times. */ int set_aggregator(Aggregator::Aggregator_type aggregator); --===============7324187081242617768== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/tor.didriksen@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: tor.didriksen@stripped\ # kt1gsyymbonb8fwi # target_branch: file:///export/home/didrik/repo/5.5/ # testament_sha1: 844390b8e49d3b19b2eeb696c2cd2d15c7d0b43b # timestamp: 2011-02-02 10:18:47 +0100 # source_branch: file:///export/home/didrik/repo/trunk/ # base_revision_id: ole.john.aske@stripped\ # ppx2z4tn6vv0u8q9 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWbEJkOwABAZfgECQ2Xf///+v 3yS////wYAjPvL1usegCQxtuMNCgBSQ1wlJT0Q9TU2iemAmkeUwgbUZMgDCPUAAEopNGym000nqN Q2oBkBoAAAAANBE1JtqhtRkBoaDIAGgBoGhpkAGgSKI0Rqnk08p6aU2IaajaT0Q000epoDRo9QGI cZMmjEMTTAQMCaYIwTE000AGEEkQjQBDTQ0TEGkymmTFMagyMmgBmo0iEr1mQeVgYpqvceurbPOr aTVDpatSKi9/Gbbjw2LMMG+/dtyohnFpRWO1+/Bqt1dVtc2BwTtSyBjfRZV42UvOUfFvTKnMgRBB gGlmD9bCw+2CnxjNIfUKwbY22mxbdCN79z3viTqJjmgDiWTXRd08pMx3VRvMKZOpYj00O7fhftWH 9C8kcCRgajMc+0/E74GNB8E/u8hLpC0IiOGSc2A5Tmj/SSoAIBYh9KFGU7gg0gyCQQBbACiUu91e +gPfJ0NRY35n6HEKAMv9zJ4uFmLPRj3+Xbtwf1wrMOvXyOF+AU5+WrQBOxBn59UIDbhDMtM1qYdh kOQWSZqezIKLBSsbN00DGNBKW4yesPAsvjYYEQZz0l9M6wzBCWlxDOC4y2rQdJOtciJ4q6rrI6aq cylTw2IqIsgIoVpFQX/RfOYvIJ00BXrNT0gr2BmF2ZcnohQRCISDPzcIqkGANGTqAMZrqDG2CSkC k4QnL/hGykFY4XHxoKkqVkZLeFoKlI+amkvZUiW9OR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