Skip to content

Commit e358d5e

Browse files
committed
put binlog_cache_data on a memroot
1 parent 8cdd661 commit e358d5e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sql/log.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void make_default_log_name(char **out, const char* log_ext, bool once)
275275
Helper classes to store non-transactional and transactional data
276276
before copying it to the binary log.
277277
*/
278-
class binlog_cache_data: public ilist_node<>
278+
class binlog_cache_data: public Sql_alloc, public ilist_node<>
279279
{
280280
public:
281281
binlog_cache_data(): share(0), sv_list(0), m_pending(0), status(0),
@@ -6382,9 +6382,9 @@ bool MYSQL_BIN_LOG::write_table_map(THD *thd, TABLE *table, bool with_annotate)
63826382

63836383

63846384
#ifdef HAVE_REPLICATION
6385-
binlog_cache_data *binlog_setup_cache_data(TABLE_SHARE *share)
6385+
static binlog_cache_data *binlog_setup_cache_data(MEM_ROOT *root, TABLE_SHARE *share)
63866386
{
6387-
auto cache= new binlog_cache_data();
6387+
auto cache= new (root) binlog_cache_data();
63886388
if (!cache || open_cached_file(&cache->cache_log, mysql_tmpdir,
63896389
LOG_PREFIX, (size_t)binlog_cache_size, MYF(MY_WME)))
63906390
{
@@ -6410,7 +6410,9 @@ binlog_cache_data *online_alter_binlog_get_cache_data(THD *thd, TABLE *table)
64106410
return &cache;
64116411
}
64126412

6413-
auto *new_cache_data= binlog_setup_cache_data(table->s);
6413+
MEM_ROOT *root= thd->in_multi_stmt_transaction_mode()
6414+
? &thd->transaction->mem_root : thd->mem_root;
6415+
auto *new_cache_data= binlog_setup_cache_data(root, table->s);
64146416
list.push_back(*new_cache_data);
64156417

64166418
return new_cache_data;

0 commit comments

Comments
 (0)