fixed an sqlite bug where empty results would count as no result set
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401216
This commit is contained in:
parent
dd8a7512a6
commit
64d7fd751a
@ -27,6 +27,7 @@ SqQuery::SqQuery(SqDatabase *parent, sqlite3_stmt *stmt) :
|
||||
m_pParent(parent), m_pStmt(stmt), m_pResults(NULL), m_AffectedRows(0), m_InsertID(0)
|
||||
{
|
||||
m_ParamCount = sqlite3_bind_parameter_count(m_pStmt);
|
||||
m_ColCount = sqlite3_column_count(m_pStmt);
|
||||
m_pParent->IncReferenceCount();
|
||||
}
|
||||
|
||||
@ -127,15 +128,25 @@ bool SqQuery::Execute()
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* If we don't have a result set and we have a column count,
|
||||
* create a result set pre-emptively. This is in case there
|
||||
* are no rows in the upcoming result set.
|
||||
*/
|
||||
if (!m_pResults && m_ColCount)
|
||||
{
|
||||
m_pResults = new SqResults(this);
|
||||
}
|
||||
|
||||
/* If we've got results, throw them away */
|
||||
if (m_pResults)
|
||||
{
|
||||
m_pResults->ResetResultCount();
|
||||
}
|
||||
|
||||
/* Fetch each row, if any */
|
||||
while ((rc = sqlite3_step(m_pStmt)) == SQLITE_ROW)
|
||||
{
|
||||
/* Delay creation as long as possible... */
|
||||
/* This should NEVER happen but we're being safe. */
|
||||
if (!m_pResults)
|
||||
{
|
||||
m_pResults = new SqResults(this);
|
||||
|
@ -81,6 +81,7 @@ private:
|
||||
int m_LastErrorCode;
|
||||
unsigned int m_AffectedRows;
|
||||
unsigned int m_InsertID;
|
||||
unsigned int m_ColCount;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_SQLITE_SOURCEMOD_QUERY_H_
|
||||
|
Loading…
Reference in New Issue
Block a user