Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions modules/mysqlx/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ const char *AtomicResult::GetString(unsigned int columnId)

size_t idx = (m_CurRow * m_FieldCount) + columnId;

assert(m_Table[idx] != NULL);
// NULL cells are stored as empty slots (see CopyFrom()).
if (!m_Table[idx])
return NULL;

return m_Table[idx]->chars();
}
Expand Down Expand Up @@ -583,12 +585,16 @@ void AtomicResult::CopyFrom(IResultSet *rs)
row = rs->GetRow();
for (unsigned int i=0; i<m_FieldCount; i++,idx++)
{
if (m_Table[idx])
const char* string = row->GetString(i);
if (!string)
{
*m_Table[idx] = row->GetString(i);
// Keep NULL distinguishable from an empty string, ke::AString can't hold NULL.
delete m_Table[idx];
m_Table[idx] = NULL;
} else if (m_Table[idx]) {
*m_Table[idx] = string;
} else {
const char* string = row->GetString(i);
m_Table[idx] = new ke::AString(string ? string : "");
m_Table[idx] = new ke::AString(string);
}
}
rs->NextRow();
Expand Down
15 changes: 11 additions & 4 deletions modules/sqlite/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ const char *AtomicResult::GetString(unsigned int columnId)

size_t idx = (m_CurRow * m_FieldCount) + columnId;

assert(m_Table[idx] != NULL);
// NULL cells are stored as empty slots (see CopyFrom()).
if (!m_Table[idx])
return NULL;

return m_Table[idx]->chars();
}
Expand Down Expand Up @@ -559,11 +561,16 @@ void AtomicResult::CopyFrom(IResultSet *rs)
row = rs->GetRow();
for (unsigned int i=0; i<m_FieldCount; i++,idx++)
{
if (m_Table[idx])
const char* string = row->GetString(i);
if (!string)
{
*m_Table[idx] = row->GetString(i);
// Keep NULL distinguishable from an empty string, ke::AString can't hold NULL.
delete m_Table[idx];
m_Table[idx] = NULL;
} else if (m_Table[idx]) {
*m_Table[idx] = string;
} else {
m_Table[idx] = new ke::AString(row->GetString(i));
m_Table[idx] = new ke::AString(string);
}
}
rs->NextRow();
Expand Down
Loading