Skip to content

Commit 24ed08c

Browse files
committed
fix compilation with gcc-10
../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 | ^~~~~~~
1 parent 55c7536 commit 24ed08c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

sql/sql_class.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5802,7 +5802,8 @@ start_new_trans::start_new_trans(THD *thd)
58025802
mdl_savepoint= thd->mdl_context.mdl_savepoint();
58035803
memcpy(old_ha_data, thd->ha_data, sizeof(old_ha_data));
58045804
thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
5805-
bzero(thd->ha_data, sizeof(thd->ha_data));
5805+
for (auto &data : thd->ha_data)
5806+
data.reset();
58065807
old_transaction= thd->transaction;
58075808
thd->transaction= &new_transaction;
58085809
new_transaction.on= 1;

sql/sql_class.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,14 @@ struct Ha_data
20242024
*/
20252025
plugin_ref lock;
20262026
Ha_data() :ha_ptr(NULL) {}
2027+
2028+
void reset()
2029+
{
2030+
ha_ptr= nullptr;
2031+
for (auto &info : ha_info)
2032+
info.reset();
2033+
lock= nullptr;
2034+
}
20272035
};
20282036

20292037
/**

0 commit comments

Comments
 (0)