Skip to content

Commit 7b4a7f0

Browse files
Pekka NousiainenPiotr Obrzut
authored andcommitted
wl#7614 alignment1.diff
avoid alignment crash on sparc (cherry picked from commit 554bb4157cb4340017044c9866a35c2676cce8c3)
1 parent e57ac3b commit 7b4a7f0

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

storage/ndb/tools/NdbImportImpl.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,8 +3132,8 @@ NdbImportImpl::DiagTeam::read_old_diags()
31323132
// runno
31333133
{
31343134
const Attr& attr = table.get_attr("runno");
3135-
const void* p = attr.get_value(row);
3136-
uint32 x = *(uint32*)p;
3135+
uint32 x;
3136+
attr.get_value(row, x);
31373137
if (runno == Inval_uint32 || runno < x)
31383138
runno = x;
31393139
}
@@ -3164,8 +3164,8 @@ NdbImportImpl::DiagTeam::read_old_diags()
31643164
// runno
31653165
{
31663166
const Attr& attr = table.get_attr("runno");
3167-
const void* p = attr.get_value(row);
3168-
uint32 runno = *(uint32*)p;
3167+
uint32 runno;
3168+
attr.get_value(row, runno);
31693169
if (runno != job.m_runno - 1)
31703170
{
31713171
m_util.free_row(row);
@@ -3175,32 +3175,27 @@ NdbImportImpl::DiagTeam::read_old_diags()
31753175
// start
31763176
{
31773177
const Attr& attr = table.get_attr("start");
3178-
const void* p = attr.get_value(row);
3179-
range.m_start = *(uint64*)p;
3178+
attr.get_value(row, range.m_start);
31803179
}
31813180
// end
31823181
{
31833182
const Attr& attr = table.get_attr("end");
3184-
const void* p = attr.get_value(row);
3185-
range.m_end = *(uint64*)p;
3183+
attr.get_value(row, range.m_end);
31863184
}
31873185
// startpos
31883186
{
31893187
const Attr& attr = table.get_attr("startpos");
3190-
const void* p = attr.get_value(row);
3191-
range.m_startpos = *(uint64*)p;
3188+
attr.get_value(row, range.m_startpos);
31923189
}
31933190
// endpos
31943191
{
31953192
const Attr& attr = table.get_attr("endpos");
3196-
const void* p = attr.get_value(row);
3197-
range.m_endpos = *(uint64*)p;
3193+
attr.get_value(row, range.m_endpos);
31983194
}
31993195
// reject
32003196
{
32013197
const Attr& attr = table.get_attr("reject");
3202-
const void* p = attr.get_value(row);
3203-
range.m_reject = *(uint64*)p;
3198+
attr.get_value(row, range.m_reject);
32043199
}
32053200
m_util.free_row(row);
32063201
// add to old rowmap

storage/ndb/tools/NdbImportUtil.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,15 @@ class NdbImportUtil {
198198
void set_value(Row* row, const void* data, uint len) const;
199199
void set_blob(Row* row, const void* data, uint len) const;
200200
void set_null(Row* row, bool null) const;
201+
// used only for pseudo-tables, attrs are non-nullable
201202
const void* get_value(const Row* row) const;
203+
// avoid alignment crash, add required methods here
204+
void get_value(const Row* row, uint32& value) const {
205+
memcpy(&value, get_value(row), sizeof(value));
206+
}
207+
void get_value(const Row* row, uint64& value) const {
208+
memcpy(&value, get_value(row), sizeof(value));
209+
}
202210
bool get_null(const Row* row) const;
203211
uint get_blob_parts(uint len) const;
204212
void set_sqltype();

0 commit comments

Comments
 (0)