diff --git a/dbcon/mysql/ha_mcs.cpp b/dbcon/mysql/ha_mcs.cpp index c11617388..e663cd522 100644 --- a/dbcon/mysql/ha_mcs.cpp +++ b/dbcon/mysql/ha_mcs.cpp @@ -351,7 +351,7 @@ int ha_mcs::write_row(const uchar* buf) int rc; try { - rc = ha_mcs_impl_write_row(buf, table); + rc = ha_mcs_impl_write_row(buf, table, rows_changed); } catch (std::runtime_error& e) { diff --git a/dbcon/mysql/ha_mcs_impl.cpp b/dbcon/mysql/ha_mcs_impl.cpp index e01d1be73..7367bc10a 100644 --- a/dbcon/mysql/ha_mcs_impl.cpp +++ b/dbcon/mysql/ha_mcs_impl.cpp @@ -2990,7 +2990,7 @@ int ha_mcs_impl_delete_table(const char* name) int rc = ha_mcs_impl_delete_table_(dbName, name, *ci); return rc; } -int ha_mcs_impl_write_row(const uchar* buf, TABLE* table) +int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed) { THD* thd = current_thd; // Error out INSERT on VIEW. It's currently not supported. @@ -3015,6 +3015,11 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table) cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); + // At the beginning of insert, make sure there are no + // left-over values from a previously possibly failed insert. + if (rows_changed == 0) + ci->tableValuesMap.clear(); + if (thd->slave_thread && !get_replication_slave(thd)) return 0; diff --git a/dbcon/mysql/ha_mcs_impl.h b/dbcon/mysql/ha_mcs_impl.h index f332b8fc8..87ce22ae7 100644 --- a/dbcon/mysql/ha_mcs_impl.h +++ b/dbcon/mysql/ha_mcs_impl.h @@ -32,7 +32,7 @@ extern int ha_mcs_impl_close(void); extern int ha_mcs_impl_rnd_init(TABLE* table); extern int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table); extern int ha_mcs_impl_rnd_end(TABLE* table, bool is_derived_hand = false); -extern int ha_mcs_impl_write_row(const uchar* buf, TABLE* table); +extern int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed); extern void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table); extern int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table); extern int ha_mcs_impl_rename_table(const char* from, const char* to);