From: Mattias Jonsson Date: April 20 2012 1:15pm Subject: bzr push into mysql-trunk branch (mattias.jonsson:3709 to 3710) Bug#13907676 WL#4305 List-Archive: http://lists.mysql.com/commits/143598 X-Bug: 13907676 Message-Id: <201204201315.q3KDFqmp001849@acsmt357.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3710 Mattias Jonsson 2012-04-20 Bug#13907676: HA_ARCHIVE::INFO In WL#4305 the refactoring of the archive writer, it could flush the writer when it was not yet open. This was due to if bulk insert was used but no rows was actually inserted (write_row was never called), the writer was marked dirty even if it was not open. Fix was to only mark it as dirty if it was opened. modified: mysql-test/r/archive.result mysql-test/t/archive.test storage/archive/ha_archive.cc 3709 Norvald H. Ryeng 2012-04-20 Bug#12888306 MISSING ROWS FOR SELECT >ALL (SUBQUERY WITHOUT ROWS) Problem: Subqueries with implicit grouping may return incorrect results due to not evaluating the WHERE clause. Queries with ALL/ANY are rewritten to use MIN/MAX. The rewritten form of the query has no GROUP BY clause, so these queries fit the pattern for triggering this bug. JOIN::optimize() calls opt_sum_query() to replace aggregation functions with constant fields for implicitly grouped queries. If the aggregation function is MIN or MAX, it checks the argument to the aggregation function. If it is a constant, the constant is selected as the minimum/maximum value if the table has rows, and NULL if it doesn't. However, the WHERE clause is not checked, so the MIN/MAX may be evaluated to a constant when it should have been NULL. Fix: Don't replace MIN/MAX of constants if there is a WHERE clause. @ mysql-test/r/explain.result Changes to EXPLAIN for queries with implicit grouping. @ mysql-test/r/fulltext.result Corrected test case for bug #12888306. @ mysql-test/r/group_by.result Add test case for bug #12888306. @ mysql-test/t/fulltext.test Corrected test case for bug #12888306. @ mysql-test/t/group_by.test Add test case for bug #12888306. @ sql/opt_sum.cc Don't replace MIN/MAX of constants if there are conds. modified: mysql-test/r/explain.result mysql-test/r/fulltext.result mysql-test/r/group_by.result mysql-test/t/fulltext.test mysql-test/t/group_by.test sql/opt_sum.cc === modified file 'mysql-test/r/archive.result' --- a/mysql-test/r/archive.result revid:norvald.ryeng@stripped +++ b/mysql-test/r/archive.result revid:mattias.jonsson@stripped @@ -12915,3 +12915,11 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; +# +# Bug#13907676: HA_ARCHIVE::INFO +# +CREATE TABLE t1 (a INT) ENGINE=ARCHIVE; +CREATE TABLE t2 SELECT * FROM t1; +SELECT * FROM t2; +a +DROP TABLE t1, t2; === modified file 'mysql-test/t/archive.test' --- a/mysql-test/t/archive.test revid:norvald.ryeng@stripped +++ b/mysql-test/t/archive.test revid:mattias.jonsson@stripped @@ -1803,3 +1803,11 @@ CHECKSUM TABLE t1 EXTENDED; FLUSH TABLE t1; OPTIMIZE TABLE t1; DROP TABLE t1; + +--echo # +--echo # Bug#13907676: HA_ARCHIVE::INFO +--echo # +CREATE TABLE t1 (a INT) ENGINE=ARCHIVE; +CREATE TABLE t2 SELECT * FROM t1; +SELECT * FROM t2; +DROP TABLE t1, t2; === modified file 'storage/archive/ha_archive.cc' --- a/storage/archive/ha_archive.cc revid:norvald.ryeng@stripped +++ b/storage/archive/ha_archive.cc revid:mattias.jonsson@stripped @@ -1657,19 +1657,13 @@ int ha_archive::info(uint flag) { DBUG_ENTER("ha_archive::info"); - /* - If dirty, we lock, and then reset/flush the data. - I found that just calling azflush() doesn't always work. - */ mysql_mutex_lock(&share->mutex); - if (share->dirty == TRUE) + if (share->dirty) { - if (share->dirty == TRUE) - { - DBUG_PRINT("ha_archive", ("archive flushing out rows for scan")); - azflush(&(share->archive_write), Z_SYNC_FLUSH); - share->dirty= FALSE; - } + DBUG_PRINT("ha_archive", ("archive flushing out rows for scan")); + DBUG_ASSERT(share->archive_write_open); + azflush(&(share->archive_write), Z_SYNC_FLUSH); + share->dirty= FALSE; } /* @@ -1709,6 +1703,7 @@ int ha_archive::info(uint flag) if (flag & HA_STATUS_AUTO) { + /* TODO: Use the shared writer instead during the lock above. */ init_archive_reader(); mysql_mutex_lock(&share->mutex); azflush(&archive, Z_SYNC_FLUSH); @@ -1782,7 +1777,10 @@ int ha_archive::end_bulk_insert() { DBUG_ENTER("ha_archive::end_bulk_insert"); bulk_insert= FALSE; - share->dirty= TRUE; + mysql_mutex_lock(&share->mutex); + if (share->archive_write_open) + share->dirty= true; + mysql_mutex_unlock(&share->mutex); DBUG_RETURN(0); } No bundle (reason: useless for push emails).