Bug #65438 Unnecessary code in "MYSQL_BIN_LOG::open_binlog"
Submitted: 28 May 2012 2:49 Modified: 25 Apr 2013 17:04
Reporter: xiaobin lin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1, 5.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: unnecessary variable

[28 May 2012 2:49] xiaobin lin
Description:
In MYSQL_BIN_LOG::open (sql/log.cc), the variable "File file= -1;" is used only once in end of the function  "if (file >= 0)my_close(file,MYF(0));"

So, is the variable necessary?

How to repeat:
read source code

Suggested fix:
@@ -2567,7 +2605,6 @@
                          bool null_created_arg,
                          bool need_mutex)
 {
-  File file= -1;
 
   DBUG_ENTER("MYSQL_BIN_LOG::open");
   DBUG_PRINT("enter",("log_type: %d",(int) log_type_arg));
@@ -2726,8 +2763,6 @@
 Turning logging off for the whole duration of the MySQL server process. \
 To turn it on again: fix the cause, \
 shutdown the MySQL server and restart it.", name, errno);
-  if (file >= 0)
-    my_close(file,MYF(0));
   end_io_cache(&log_file);
   end_io_cache(&index_file);
   safeFree(name);
[28 May 2012 5:55] Valeriy Kravchuk
In both 5.1.x and 5.5.x I clearly see 

if ((file= my_open(...

in this function. So, variable gets a value >=0 if file is opened successfully. Please, check.
[28 May 2012 6:02] xiaobin lin
Valeriy :
I mean in the function "MYSQL_BIN_LOG::open"

Let's look into the latest one in bzr "5.5.25"

The function from "log.cc:2958" to "log.cc:3146" .

Which line is the statement you mentioned?
[28 May 2012 6:52] Valeriy Kravchuk
My fault. The code I referred to is in MySQL_BIN_LOG::open_purge_index_file().
[10 Jan 2013 12:15] Erlend Dahl
Not repeatable on recent sources.
[12 Mar 2013 3:26] MySQL Verification Team
I've been investigating binlog failures, and found this bug report.

The code in question is still there in mysql-5.6.
The function name is actually "MYSQL_BIN_LOG::open_binlog".
[25 Apr 2013 17:04] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html
[25 Apr 2013 17:05] Jon Stephens
Documented fix in the 5.7.2 changelog as follows:

        The internal function MYSQL_BIN_LOG::open_binlog()
        contained an unneeded variable, which has been removed.

Closed.