前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >实验:基于语句复制的不安全性《MySQL排错指南Page83-85》

实验:基于语句复制的不安全性《MySQL排错指南Page83-85》

作者头像
保持热爱奔赴山海
发布2019-09-17 11:26:27
3290
发布2019-09-17 11:26:27
举报
文章被收录于专栏:饮水机管理员饮水机管理员

环境:

 主、从库的binlog_format = statement

  隔离级别: RC

主库会话1

主库会话2

主库会话3

从库会话

use test;create table f1(char(2))engine=InnoDB;

begin;insert into t1 select 1;insert into t1 select 2;insert into t1 select 3;insert into t1 select 4;insert into t1 select 5;

begin;insert into t1 select 'a';insert into t1 select 'b';insert into t1 select 'c';insert into t1 select 'd';insert into t1 select 'e';insert into t1 select 'f';commit;

select * from t1;+------+| f1   |+------+| a    || b    || c    || d    || e    || f    |+------+

select * from t1;+------+| f1   |+------+| a    || b    || c    || d    || e    || f    |+------+

commit

select * from t1;+------+| f1   |+------+| 1    || 2    || 3    || 4    || 5    || a    || b    || c    || d    || e    || f    |+------+

select * from t1;+------+| f1   |+------+| a    || b    || c    || d    || e    || f    || 1    || 2    || 3    || 4    || 5    |+------+

可以看到上图中,最后一行,主从库的数据排列顺序变化了。如果这时候我们在主库再执行一个类似 update t1 set f1='A' limit 4; 这种操作,则从库的数据彻底乱了。

下面是执行update时候 主库提示的warnings告警。

代码语言:javascript
复制
master [localhost] {root} (test) > master [localhost] {root} (test) > show warnings \G
*************************** 1. row ***************************
  Level: Note
   Code: 1592
Message: 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.
1 row in set (0.00 sec)
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-10-29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档