實驗:基於語句複製的不安全性《MySQL排錯指南Page83-85》

來源:互聯網
上載者:User

標籤:實驗:基於語句複製的不安全性《mysql排錯指南page83-85》

環境:

 主、從庫的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    |

+------+

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

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    |

+------+



650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

select * from t1;

+------+

| f1   |

+------+

| a    |

| b    |

| c    |

| d    |

| e    |

| f    |

| 1    |

| 2    |

| 3    |

| 4    |

| 5    |

+------+


可以看到中,最後一行,主從庫的資料排列順序變化了。如果這時候我們在主庫再執行一個類似 update t1 set f1=‘A‘ limit 4; 這種操作,則從庫的資料徹底亂了。


下面是執行update時候 主庫提示的warnings警示。

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)


實驗:基於語句複製的不安全性《MySQL排錯指南Page83-85》

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.