mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Fix for
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. mysql-test/r/ctype_cp932_binlog.result: Fix for bug #26842: master binary log contains invalid queries - replication fails bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements - result adjusted. mysql-test/r/ctype_cp932_notembedded.result: Fix for bug #26842: master binary log contains invalid queries - replication fails bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements - result adjusted. mysql-test/r/rpl_user_variables.result: Fix for bug #26842: master binary log contains invalid queries - replication fails bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements - test result. mysql-test/t/ctype_cp932_binlog.test: Fix for bug #26842: master binary log contains invalid queries - replication fails bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements - test adjusted. mysql-test/t/rpl_user_variables.test: Fix for bug #26842: master binary log contains invalid queries - replication fails bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements - test case. sql/sql_prepare.cc: Fix for bug #26842: master binary log contains invalid queries - replication fails bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements - set val to the variable's value (escaped if needed) then insert it into the query string in the position of the placeholder. We don't need to call get_var_with_binlog() here as there is no trace of the variable's name in the binlog.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user