Skip to content

Commit

Permalink
fix compilation with gcc-10
Browse files Browse the repository at this point in the history
../sql/sql_class.cc: In constructor ‘start_new_trans::start_new_trans(THD*)’:
../include/m_string.h:61:49: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct Ha_data’; use assignment or value-initialization instead [-Werror=class-memaccess]
   61 | # define bzero(A,B)             memset((A),0,(B))
      |                                                 ^
../sql/sql_class.cc:5805:3: note: in expansion of macro ‘bzero’
 5805 |   bzero(thd->ha_data, sizeof(thd->ha_data));
      |   ^~~~~
In file included from ../sql/sql_class.cc:33:
../sql/sql_class.h:2003:8: note: ‘struct Ha_data’ declared here
 2003 | struct Ha_data
      |        ^~~~~~~
  • Loading branch information
kevgs committed Jul 9, 2020
1 parent 55c7536 commit 24ed08c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sql/sql_class.cc
Expand Up @@ -5802,7 +5802,8 @@ start_new_trans::start_new_trans(THD *thd)
mdl_savepoint= thd->mdl_context.mdl_savepoint();
memcpy(old_ha_data, thd->ha_data, sizeof(old_ha_data));
thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
bzero(thd->ha_data, sizeof(thd->ha_data));
for (auto &data : thd->ha_data)
data.reset();
old_transaction= thd->transaction;
thd->transaction= &new_transaction;
new_transaction.on= 1;
Expand Down
8 changes: 8 additions & 0 deletions sql/sql_class.h
Expand Up @@ -2024,6 +2024,14 @@ struct Ha_data
*/
plugin_ref lock;
Ha_data() :ha_ptr(NULL) {}

void reset()
{
ha_ptr= nullptr;
for (auto &info : ha_info)
info.reset();
lock= nullptr;
}
};

/**
Expand Down

0 comments on commit 24ed08c

Please sign in to comment.