Bug #99857 mysql_use_result() can't get result if slave no set slave_uuid
Submitted: 12 Jun 2020 3:32 Modified: 20 Aug 2020 1:05
Reporter: su fei Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S1 (Critical)
Version:5.7.31,8.0.20 OS:Any
Assigned to: CPU Architecture:Any
Tags: mysql_use_result

[12 Jun 2020 3:32] su fei
Description:
I get a Unknown MySQL error

If a slave connect master without user variable of slave_uuid , I can,t use mysql_use_result() to get result of sql 'show slave hosts;'

How to repeat:
Using replication protocol to connect MySQL server, the process have not set user variable of slave_uuid. 

Using MySQL client without --quick option connect server,run:

mysql> show slave hosts\G       
*************************** 1. row ***************************
 Server_id: 2019314
      Host: db1n9
      Port: 8018
 Master_id: 9080
Slave_UUID: 
1 row in set (0.00 sec)

When with --quick option connect server,run:

mysql> show slave hosts\G
ERROR 2000 (HY000): Unknown MySQL error
0 rows in set (0.00 sec)

Unfortunately, the result is Unknown MySQL error
[17 Jun 2020 10:58] MySQL Verification Team
Hi,

How did you get 8.0.20 to start without server_uuid ?
[17 Jun 2020 14:06] su fei
I just use MySQL replication protocol library like go-mysql as a MySQL slave to sync binlog from master. 
It's very terrible that other session get Unknown MySQL error due to an replication protocol client connection without slave_uuid.
[19 Jun 2020 11:01] MySQL Verification Team
Hi,

I think the mysql bug here would be on the side of the client app that did not set UUID, but mysql should work same with regards to this with and without --quick so I'm verifying this bug.

Thanks for the report
Bogdan
[20 Aug 2020 1:05] su fei
I find that old versions(such as mysql 5.7.21) have not this problem.

the resean:

In version 5.7.31, the function read_one_row() is :
    // check field length
    len = (ulong)net_field_length_checked(&pos, (ulong)(end_pos - pos));
    if (pos > end_pos) {
      set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
      return -1;
    }

    if (len == NULL_LENGTH) { /* null field */
      row[field] = 0;
      *lengths++ = 0;
    } else {
      row[field] = (char *)pos;
      pos += len;
      *lengths++ = len;
    }
First, should check whether the field is null,like version 5.7.21;
if the last field value is null, in version 5.7.31 , Unknown MySQL error will happen
[5 Aug 2021 10:16] MySQL Verification Team
Bug #104544 marked as duplicate of this one