• unknown's avatar
    Fix for the patch for bug#21726: Incorrect result with multiple · 37b5cbdc
    unknown authored
    invocations of LAST_INSERT_ID.
    
    Reding of LAST_INSERT_ID inside stored function wasn't noted by caller,
    and no LAST_INSERT_ID_EVENT was issued for binary log.
    
    The solution is to add THD::last_insert_id_used_bin_log, which is much
    like THD::last_insert_id_used, but is reset only for upper-level
    statements.  This new variable is used to issue LAST_INSERT_ID_EVENT.
    
    
    mysql-test/r/rpl_insert_id.result:
      For bug#21726, add result for statement-based replication of function
      calls.
    mysql-test/t/rpl_insert_id.test:
      For bug#21726, add test case for statement-based replication of function
      calls.
    sql/item_func.cc:
      Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
    sql/log.cc:
      Issue LAST_INSERT_ID_EVENT if THD::last_insert_id_used_bin_log is set.
    sql/set_var.cc:
      Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
    sql/sql_class.cc:
      Initialize THD::last_insert_id_used_bin_log.
      Fix typo, add whitespace.
    sql/sql_class.h:
      Add THD::last_insert_id_used_bin_log.
    sql/sql_parse.cc:
      Reset THD::last_insert_id_used_bin_log for upper-level statements.
    sql/sql_select.cc:
      Set THD::last_insert_id_used_bin_log for issuing of LAST_INSERT_ID_EVENT.
    37b5cbdc
sql_select.cc 462 KB