警告:即使没有限制,为什么带有限制子句的语句也不安全?

32b*_*oat 1 mysql innodb replication logs mysql-5.5

由于 mysql 错误日志中的一些警告,我有点恼火。示例 1:

[Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. 
The statement is unsafe because it uses a LIMIT clause. 
This is unsafe because the set of rows included cannot be predicted. 
Statement: UPDATE `table` SET `status` = '1' WHERE `ID` = '15800' LIMIT 1
Run Code Online (Sandbox Code Playgroud)

我的同事写了这些语句,我一直想知道在使用显式 ID 时限制语句的目的。尽管如此,使用 LIMIT也会出现此警告。
示例 2:

[Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. 
The statement is unsafe because it uses a LIMIT clause. 
This is unsafe because the set of rows included cannot be predicted. 
Statement: DELETE FROM table WHERE id = 426888
Run Code Online (Sandbox Code Playgroud)

在这种情况下可能有什么问题?

gbn*_*gbn 5

你有 LIMIT 没有 ORDER BY。因此,这是没有意义的。

没有 ORDER BY 的集合没有隐含的顺序。错误消息告诉您:

这是不安全的,因为无法预测包含的行集

您的 DELETE 是否有触发器或带有 LIMIT 的触发器?

  • 我们确实设置了触发器(在更新和删除上),其中语句也包含限制子句。已更正,不再出现警告,谢谢。 (2认同)