Bug #91829 Class Gtid_state has a wrong function to_string(char *buf)

Submitted: 30 Jul 2018 9:51 Modified: 30 Jul 2018 12:52
Reporter: kfpanda kf Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.7.22, 5.7.23, 8.0.12 OS:Any
Assigned to: CPU Architecture:Any

[30 Jul 2018 9:51] kfpanda kf
Description:
I found an obvious mistake when I read the MySQL code.
 
Second lost_gtids.to_string(p) should be replaced with gtids_only_in_table.to_string(p).

---------------------CODE: MySQL 5.7.22 
rpl_gtid.h:

  /// Debug only: Generate a string in the given buffer and return the length.
  int to_string(char *buf) const
  {
    char *p= buf;
    p+= sprintf(p, "Executed GTIDs:\n");
    p+= executed_gtids.to_string(p);
    p+= sprintf(p, "\nOwned GTIDs:\n");
    p+= owned_gtids.to_string(p);
    p+= sprintf(p, "\nLost GTIDs:\n");
    p+= lost_gtids.to_string(p);
    p+= sprintf(p, "\nGTIDs only_in_table:\n");
    p+= lost_gtids.to_string(p);
    return (int)(p - buf);
  }

-----------------------CODE: Fixed

rpl_gtid.h:

  /// Debug only: Generate a string in the given buffer and return the length.
  int to_string(char *buf) const
  {
    char *p= buf;
    p+= sprintf(p, "Executed GTIDs:\n");
    p+= executed_gtids.to_string(p);
    p+= sprintf(p, "\nOwned GTIDs:\n");
    p+= owned_gtids.to_string(p);
    p+= sprintf(p, "\nLost GTIDs:\n");
    p+= lost_gtids.to_string(p);
    p+= sprintf(p, "\nGTIDs only_in_table:\n");
    p+= gtids_only_in_table.to_string(p);
    return (int)(p - buf);
  }

How to repeat:
I found an obvious mistake when I read the MySQL code.
 
Second lost_gtids.to_string(p) should be replaced with gtids_only_in_table.to_string(p).

---------------------CODE: MySQL 5.7.22 
rpl_gtid.h:

  /// Debug only: Generate a string in the given buffer and return the length.
  int to_string(char *buf) const
  {
    char *p= buf;
    p+= sprintf(p, "Executed GTIDs:\n");
    p+= executed_gtids.to_string(p);
    p+= sprintf(p, "\nOwned GTIDs:\n");
    p+= owned_gtids.to_string(p);
    p+= sprintf(p, "\nLost GTIDs:\n");
    p+= lost_gtids.to_string(p);
    p+= sprintf(p, "\nGTIDs only_in_table:\n");
    p+= lost_gtids.to_string(p);
    return (int)(p - buf);
  }

-----------------------CODE: Fixed

rpl_gtid.h:

  /// Debug only: Generate a string in the given buffer and return the length.
  int to_string(char *buf) const
  {
    char *p= buf;
    p+= sprintf(p, "Executed GTIDs:\n");
    p+= executed_gtids.to_string(p);
    p+= sprintf(p, "\nOwned GTIDs:\n");
    p+= owned_gtids.to_string(p);
    p+= sprintf(p, "\nLost GTIDs:\n");
    p+= lost_gtids.to_string(p);
    p+= sprintf(p, "\nGTIDs only_in_table:\n");
    p+= gtids_only_in_table.to_string(p);
    return (int)(p - buf);
  }

Suggested fix:
I found an obvious mistake when I read the MySQL code.
 
Second lost_gtids.to_string(p) should be replaced with gtids_only_in_table.to_string(p).

---------------------CODE: MySQL 5.7.22 
rpl_gtid.h:

  /// Debug only: Generate a string in the given buffer and return the length.
  int to_string(char *buf) const
  {
    char *p= buf;
    p+= sprintf(p, "Executed GTIDs:\n");
    p+= executed_gtids.to_string(p);
    p+= sprintf(p, "\nOwned GTIDs:\n");
    p+= owned_gtids.to_string(p);
    p+= sprintf(p, "\nLost GTIDs:\n");
    p+= lost_gtids.to_string(p);
    p+= sprintf(p, "\nGTIDs only_in_table:\n");
    p+= lost_gtids.to_string(p);
    return (int)(p - buf);
  }

-----------------------CODE: Fixed

rpl_gtid.h:

  /// Debug only: Generate a string in the given buffer and return the length.
  int to_string(char *buf) const
  {
    char *p= buf;
    p+= sprintf(p, "Executed GTIDs:\n");
    p+= executed_gtids.to_string(p);
    p+= sprintf(p, "\nOwned GTIDs:\n");
    p+= owned_gtids.to_string(p);
    p+= sprintf(p, "\nLost GTIDs:\n");
    p+= lost_gtids.to_string(p);
    p+= sprintf(p, "\nGTIDs only_in_table:\n");
    p+= gtids_only_in_table.to_string(p);
    return (int)(p - buf);
  }
[30 Jul 2018 12:52] MySQL Verification Team
Hello kfpanda kf,

Thank you for the report and feedback!

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.