当我们从我们编写的sqlite3
获取包装器一次获取一行时,我遇到了性能问题。以下是伪代码:
if(sqlStatement.startEvaluation())
{
while(sqlStatement.fetchNext())
{
<Some Type> node(reinterpret_cast<type>(sqlStatement.getPointer(0)));
m_result.push_back(node);
}
}
bool rttSQLiteStatement::fetchNext()
{
try
{
int result = sqlite3_step(m_statement);
if(result==SQLITE_ROW)
return true;
if(result!=SQLITE_DONE)
setError("Unable to fetch row.");
return false;
}
catch( ... )
{
LOG_ERROR("Error while fetching next query result.");
return false;
}
}
void* rttSQLiteStatement::getPointer(int i)
{
try
{
assert(m_statement);
assert(i<m_numResultColumns);
return reinterpret_cast<void*>(sqlite3_column_int64(m_statement, i));
}
catch( ... )
{
LOG_ERROR("Error while reading pointer query result.");
return false;
}
}
我想使用类似光标的东西,它会在记录集中给我所有结果