• unknown's avatar
    Bug #25543 Replication of wrong values if using rand() in stored procedure · 93bd7040
    unknown authored
    When rand() is called multiple times inside a stored procedure, the server does 
    not binlog the correct random seed values.
    
    This patch corrects the problem by resetting rand_used= 0 in 
    THD::cleanup_after_query() allowing the system to save the random seeds if needed
    for each command in a stored procedure body.
    
    However, rand_used is not reset if executing in a stored function or trigger 
    because these operations are binlogged by call and thus only the calling statement
    need detect the call to rand() made by its substatements. These substatements must 
    not set rand_used to 0 because it would remove the detection of rand() by the 
    calling statement.
    
    
    mysql-test/r/rpl_misc_functions.result:
      Bug #25543 Replication of wrong values if using rand() in stored procedure
      
      The result file was modified to include the correct processing of the new
      additions to the test. The results from execution are written to files on 
      both the master and the slave. The files are compared to ensure the values 
      from rand() generated on the master are correctly generated on the slave.
    mysql-test/t/rpl_misc_functions.test:
      Bug #25543 Replication of wrong values if using rand() in stored procedure
      
      The test was modified to include a test of a stored procedure that calls
      the rand() function multiple times. 
      
      The results from execution are written to files on both the master and the
      slave. The files are compared to ensure the values from rand() generated
      on the master are correctly generated on the slave.
    sql/sql_class.cc:
      Bug #25543 Replication of wrong values if using rand() in stored procedure
      
      The code was modified to reset rand_used so that detection of calls to rand() 
      will save random seeds if needed by the slave.
    93bd7040
rpl_misc_functions.test 3.29 KB