@@ -7276,8 +7276,8 @@ Rdb_table_handler *Rdb_open_tables_map::get_table_handler(
7276
7276
7277
7277
// First, look up the table in the hash map.
7278
7278
RDB_MUTEX_LOCK_CHECK(m_mutex);
7279
- const auto it = m_table_map.find (table_name_str);
7280
- if (it != m_table_map.end() ) {
7279
+ const auto [it, success] = m_table_map.emplace (table_name_str, nullptr );
7280
+ if (success ) {
7281
7281
// Found it
7282
7282
table_handler = it->second;
7283
7283
} else {
@@ -7289,6 +7289,7 @@ Rdb_table_handler *Rdb_open_tables_map::get_table_handler(
7289
7289
my_multi_malloc(PSI_NOT_INSTRUMENTED, MYF(MY_WME | MY_ZEROFILL),
7290
7290
&table_handler, sizeof(*table_handler), &tmp_name,
7291
7291
table_name_str.length() + 1, NullS)))) {
7292
+ m_table_map.erase(it); // malloc failing is unlikely
7292
7293
// Allocating a new Rdb_table_handler and a new table name failed.
7293
7294
RDB_MUTEX_UNLOCK_CHECK(m_mutex);
7294
7295
return nullptr;
@@ -7299,7 +7300,7 @@ Rdb_table_handler *Rdb_open_tables_map::get_table_handler(
7299
7300
table_handler->m_table_name = tmp_name;
7300
7301
strxmov(table_handler->m_table_name, table_name, NullS);
7301
7302
7302
- m_table_map.emplace(table_name_str, table_handler) ;
7303
+ it->second = table_handler;
7303
7304
7304
7305
thr_lock_init(&table_handler->m_thr_lock);
7305
7306
table_handler->m_io_perf_read.init();
0 commit comments