1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-31 22:22:30 +03:00
bug #26842: master binary log contains invalid queries - replication fails
bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements

Problem:  
binlogging PS' we may produce syntacticly incorrect queries in the binlog replacing 
some parameters with variable names (instead of variable values).
E.g. in the reported case of "limit ?" clause: replacing "?" with "@var"
produces "limit @var" which is not a correct SQL syntax. 
Also it may lead to different query execution on slave if we
set and use a variable in the same statement, e.g.
"insert into t1 values (@x:=@x+1, ?)"

Fix: make the stored statement string created upon its execution use variable values
(instead of names) to fill placeholders.
This commit is contained in:
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
2007-05-24 15:35:43 +05:00
parent f1ae9793a7
commit 2c759bd45f
6 changed files with 98 additions and 46 deletions

View File

@@ -253,10 +253,44 @@ SELECT * from t2;
k
100
42
drop table t1, t2;
reset master;
create table t1 (a int);
prepare s from "insert into t1 values (@a),(?)";
set @a=98;
execute s using @a;
prepare s from "insert into t1 values (?)";
set @a=99;
execute s using @a;
prepare s from "insert into t1 select 100 limit ?";
set @a=100;
execute s using @a;
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 98 Query 1 184 use `test`; create table t1 (a int)
slave-bin.000001 184 User var 2 226 @`a`=98
slave-bin.000001 226 Query 1 320 use `test`; insert into t1 values (@a),(98)
slave-bin.000001 320 Query 1 409 use `test`; insert into t1 values (99)
slave-bin.000001 409 Query 1 507 use `test`; insert into t1 select 100 limit 100
select * from t1;
a
98
98
99
100
drop table t1;
create table t1(a int, b int);
prepare s1 from 'insert into t1 values (@x:=@x+1, ?)';
set @x=1;
execute s1 using @x;
select * from t1;
a b
2 1
select * from t1;
a b
2 1
drop table t1;
End of 5.0 tests.
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
CREATE TABLE t1 (i INT);