Options AFAIK are mainly based around getting the replication to be be ROW
based rather then STATEMENT
based.
- Set the default to
ROW
(which is a brute force method, and has its drawbacks). - You can set the
SESSION
binlog_format toROW
, but it requires theSUPER
privilege which the user probably hasn’t and will not be granted either for good reasons. - If the logging happens in
MIXED
format you can look around here to force aROW
based entry in the binlog, trying to force a uselessFOUND_ROWS()
orUUID()
call in the update could very well trigger it.
An example for the MIXED
solution:
The queries:
INSERT INTO sometable VALUES ('a','aa');
UPDATE sometable SET aa="bb";
UPDATE sometable SET aa="cc" WHERE UUID(); -- slight overhead, but always true
The log (use mysqlbinlog to inspect it), clearly STATEMENT
based for the first 2, but ROW
based for the 3rd:
# at 175
#130918 21:18:25 server id 1 end_log_pos 277 Query thread_id=142 exec_time=0 error_code=0
use `test`/*!*/;
SET TIMESTAMP=1379531905/*!*/;
INSERT INTO sometable VALUES ('a','aa')
/*!*/;
# at 277
#130918 21:18:25 server id 1 end_log_pos 304 Xid = 488
COMMIT/*!*/;
# at 304
#130918 21:18:52 server id 1 end_log_pos 372 Query thread_id=142 exec_time=0 eror_code=0
SET TIMESTAMP=1379531932/*!*/;
BEGIN
/*!*/;
# at 372
#130918 21:18:52 server id 1 end_log_pos 463 Query thread_id=142 exec_time=0 error_code=0
SET TIMESTAMP=1379531932/*!*/;
UPDATE sometable SET aa="bb"
/*!*/;
# at 463
#130918 21:18:52 server id 1 end_log_pos 490 Xid = 497
COMMIT/*!*/;
# at 490
#130918 21:21:06 server id 1 end_log_pos 558 Query thread_id=144 exec_time=0 error_code=0
SET TIMESTAMP=1379532066/*!*/;
BEGIN
/*!*/;
# at 558
# at 610
#130918 21:21:06 server id 1 end_log_pos 610 Table_map: `test`.`sometable` mapped to number 180
#130918 21:21:06 server id 1 end_log_pos 664 Update_rows: table id 180 flags: STMT_END_F
BINLOG '
Iv05UhMBAAAANAAAAGICAAAAALQAAAAAAAEABHRlc3QACXNvbWV0YWJsZQAC/A8DAwYAAQ==
Iv05UhgBAAAANgAAAJgCAAAAALQAAAAAAAEAAv///QJiYv0CY2P8AQAAYQJiYvwBAABhAmNj
'/*!*/;
# at 664
#130918 21:21:06 server id 1 end_log_pos 691 Xid = 578
COMMIT/*!*/;
DELIMITER ;
# End of log file