• konstantin@mysql.com's avatar
    A fix for Bug#19022 "Memory bug when switching db during trigger execution". · 55d148c5
    konstantin@mysql.com authored
    No test case as the bug is in an existing test case (rpl_trigger.test
    when it is run under valgrind).
    The warning was caused by memory corruption in replication slave: thd->db
    was pointing at a stack address that was previously used by 
    sp_head::execute()::old_db. This happened because mysql_change_db
    behaved differently in replication slave and did not make a copy of the 
    argument to assign to thd->db. 
    The solution is to always free the old value of thd->db and allocate a new
    copy, regardless whether we're running in a replication slave or not.
    55d148c5
sql_db.cc 32.9 KB