• unknown's avatar
    Fix for · 3791e35f
    unknown authored
    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.
    3791e35f
sql_prepare.cc 84.4 KB