Closed zhanghaiyang9999 closed 1 month ago
it's the design of MySQL binlog replication. https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_query You can find some material to learn about it.
it's the design of MySQL binlog replication. https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_query You can find some material to learn about it.
Thanks! But it's a strange design.
it's the design of MySQL binlog replication. https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_query You can find some material to learn about it.
Thanks! But it's a strange design.
I remember it means the current database this session is on (USE db
). So if the query doesn't specify the database name this field should act as the default value.
If I had 2 schemas, named test001 and tpcc. They have one same name(say t2) table, when I change the table t2 of tpcc, the query_event returns the schema name is test001. can reproduce this issue stably with Mysql5.x or Mysql 8.x
replication.QUERY_EVENT event := ev.Event.(*replication.QueryEvent) dbname := string(event.Schema) //the dbname is test001 sqlstr := string(event.Query) //the sqlstr is "ALTER TABLE
tpcc
.t2
ADD COLUMNdesc10
VARCHAR(45) NULL AFTERdesc9
;"