extensions/sqlite/driver/SqQuery.cpp
changeset 1210 18e60c8737a2
parent 1203 633c25ce6405
child 1226 478550a4d5ec
     1.1 --- a/extensions/sqlite/driver/SqQuery.cpp	Sun Jul 29 02:44:37 2007 +0000
     1.2 +++ b/extensions/sqlite/driver/SqQuery.cpp	Sun Jul 29 14:56:24 2007 +0000
     1.3 @@ -27,6 +27,7 @@
     1.4   m_pParent(parent), m_pStmt(stmt), m_pResults(NULL), m_AffectedRows(0), m_InsertID(0)
     1.5  {
     1.6  	m_ParamCount = sqlite3_bind_parameter_count(m_pStmt);
     1.7 +	m_ColCount = sqlite3_column_count(m_pStmt);
     1.8  	m_pParent->IncReferenceCount();
     1.9  }
    1.10  
    1.11 @@ -127,15 +128,25 @@
    1.12  {
    1.13  	int rc;
    1.14  
    1.15 +	/* If we don't have a result set and we have a column count, 
    1.16 +	 * create a result set pre-emptively.  This is in case there
    1.17 +	 * are no rows in the upcoming result set.
    1.18 +	 */
    1.19 +	if (!m_pResults && m_ColCount)
    1.20 +	{
    1.21 +		m_pResults = new SqResults(this);
    1.22 +	}
    1.23 +
    1.24  	/* If we've got results, throw them away */
    1.25  	if (m_pResults)
    1.26  	{
    1.27  		m_pResults->ResetResultCount();
    1.28  	}
    1.29  
    1.30 +	/* Fetch each row, if any */
    1.31  	while ((rc = sqlite3_step(m_pStmt)) == SQLITE_ROW)
    1.32  	{
    1.33 -		/* Delay creation as long as possible... */
    1.34 +		/* This should NEVER happen but we're being safe. */
    1.35  		if (!m_pResults)
    1.36  		{
    1.37  			m_pResults = new SqResults(this);