Bug #98702 grant grant option statements are binlogged wrongly
Submitted: 21 Feb 2020 6:36 Modified: 21 Feb 2020 6:54
Reporter: Song Libing Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[21 Feb 2020 6:36] Song Libing
Description:
Grant statements are binlogged wrongly if 'GRANT OPTION' is in the privilege list. Only 'GRANT OPTION' privilege is binlogged, other privileges disappear.

GRANT INSERT, SELECT, Grant Option ON db1.* to 'test_user'@'%';
is binlogged  as:
"GRANT GRANT OPTION ON `db1`.* TO 'test_user'@'%' WITH GRANT OPTION"

How to repeat:
CREATE DATABASE db1;
CREATE TABLE db1.t1(c1 INT);

CREATE USER 'test_user'@'%';

GRANT INSERT, SELECT, Grant Option ON db1.* to 'test_user'@'%';

show binlog events;       # <---- check the result
show grants for 'test_user'@'%';

Suggested fix:
Look the code in bool Rewriter_grant::rewrite().

  else if (lex->grant_privilege) // <----- this line caused the wrong result
    rlb->append(STRING_WITH_LEN("GRANT OPTION"));
  else {
[21 Feb 2020 6:54] MySQL Verification Team
Hello Libing,

Thank you for the report and feedback.
Imho this is duplicate of Bug #98678, please see Bug #98678. 

regards,
Umesh