Bug #75976 main.merge test case fails if binlog_format=ROW
Submitted: 20 Feb 2015 9:51 Modified: 16 Mar 2016 21:29
Reporter: João Gramacho Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Merge storage engine Severity:S3 (Non-critical)
Version:5.7.6 OS:Any
Assigned to: Venkatesh Duggirala CPU Architecture:Any

[20 Feb 2015 9:51] João Gramacho
Description:
I hit this bug while testing WL#8313 (changing binlog_format default to ROW):

$ ./mtr --mem main.merge
Logging: /home/.../mysql-test-run.pl  --mem main.merge
MySQL Version 5.7.7
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/.../mysql-5.7/debug/mysql-test/var'...
 - symlinking 'var' to '/dev/shm/var_auto_pWhg'
Installing system database...

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
main.merge                               [ fail ]
        Test ended at 2015-02-20 09:15:29

CURRENT_TEST: main.merge
mysqltest: At line 2316: query 'CREATE TABLE m2 LIKE m1' failed: 2013: Lost connection to MySQL server during query

Notice that this issue might be related with Bug#72074, but it doesn't require replication nor binlog enabled to be reproduced.

How to repeat:
Set binlog_format to ROW at the top of the test case:

diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index e72b903..e865d17 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -1,6 +1,7 @@
 #
 # Test of MERGE TABLES
 #
+SET binlog_format=ROW;
 # MERGE tables require MyISAM tables
 --source include/have_myisam.inc

And run:

./mtr --mem main.merge

Suggested fix:
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 528b945..6c86da5 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1584,6 +1584,10 @@ void ha_myisammrg::append_create_info(String *packet)
   */
   if (file->open_tables == file->end_table)
     return;
+
+  if (children_l == NULL)
+    return;
+
   packet->append(STRING_WITH_LEN(" UNION=("));
 
   current_db= table->s->db.str;
[26 Feb 2016 3:43] Venkatesh Duggirala
Bug#74502 is marked as duplicate of this bug.
[16 Mar 2016 21:29] Daniel So
Added the following entry to the MySQL 5.5.49, 5.6.30, 5.7.13, 5.8.0 changelogs:

"The test case main.merge failed when the variables binlog_format was set to “ROW,” as the server tried to get information for table creation for a child table before it was opened. With this fix, the server skips getting information for the table in the situation."