
Definition at line 74 of file qsql_sqlite2.cpp.
Public Member Functions | |
| QSQLite2ResultPrivate (QSQLite2Result *res) | |
| void | cleanup () |
| bool | fetchNext (QSqlCachedResult::ValueCache &values, int idx, bool initialFetch) |
| bool | isSelect () |
| void | init (const char **cnames, int numCols) |
| void | finalize () |
Public Attributes | |
| QSQLite2Result * | q |
| sqlite * | access |
| const char * | currentTail |
| sqlite_vm * | currentMachine |
| uint | skippedStatus: 1 |
| uint | skipRow: 1 |
| uint | utf8: 1 |
| QSqlRecord | rInf |
| QSQLite2ResultPrivate::QSQLite2ResultPrivate | ( | QSQLite2Result * | res | ) |
Definition at line 101 of file qsql_sqlite2.cpp.
00101 : q(res), access(0), currentTail(0), 00102 currentMachine(0), skippedStatus(false), skipRow(false), utf8(false) 00103 { 00104 }
| void QSQLite2ResultPrivate::cleanup | ( | ) |
Definition at line 106 of file qsql_sqlite2.cpp.
References QSql::BeforeFirstRow, QSqlCachedResult::cleanup(), QSqlRecord::clear(), currentMachine, currentTail, finalize(), q, rInf, QSqlResult::setActive(), QSqlResult::setAt(), skippedStatus, and skipRow.
Referenced by QSQLite2Result::reset(), and QSQLite2Result::~QSQLite2Result().
00107 { 00108 finalize(); 00109 rInf.clear(); 00110 currentTail = 0; 00111 currentMachine = 0; 00112 skippedStatus = false; 00113 skipRow = false; 00114 q->setAt(QSql::BeforeFirstRow); 00115 q->setActive(false); 00116 q->cleanup(); 00117 }
Here is the call graph for this function:

| bool QSQLite2ResultPrivate::fetchNext | ( | QSqlCachedResult::ValueCache & | values, | |
| int | idx, | |||
| bool | initialFetch | |||
| ) |
Definition at line 154 of file qsql_sqlite2.cpp.
References QSql::AfterLastRow, currentMachine, finalize(), QString::fromAscii(), QString::fromUtf8(), i, init(), QSqlRecord::isEmpty(), q, rInf, QSqlResult::setAt(), skippedStatus, skipRow, SQLITE_BUSY, SQLITE_DONE, SQLITE_ERROR, SQLITE_MISUSE, SQLITE_ROW, utf8, and values.
Referenced by QSQLite2Result::gotoNext(), and QSQLite2Result::reset().
00155 { 00156 // may be caching. 00157 const char **fvals; 00158 const char **cnames; 00159 int colNum; 00160 int res; 00161 int i; 00162 00163 if (skipRow) { 00164 // already fetched 00165 Q_ASSERT(!initialFetch); 00166 skipRow = false; 00167 return skippedStatus; 00168 } 00169 skipRow = initialFetch; 00170 00171 if (!currentMachine) 00172 return false; 00173 00174 // keep trying while busy, wish I could implement this better. 00175 while ((res = sqlite_step(currentMachine, &colNum, &fvals, &cnames)) == SQLITE_BUSY) { 00176 // sleep instead requesting result again immidiately. 00177 #if defined Q_WS_WIN32 00178 Sleep(1000); 00179 #else 00180 sleep(1); 00181 #endif 00182 } 00183 00184 switch(res) { 00185 case SQLITE_ROW: 00186 // check to see if should fill out columns 00187 if (rInf.isEmpty()) 00188 // must be first call. 00189 init(cnames, colNum); 00190 if (!fvals) 00191 return false; 00192 if (idx < 0 && !initialFetch) 00193 return true; 00194 for (i = 0; i < colNum; ++i) 00195 values[i + idx] = utf8 ? QString::fromUtf8(fvals[i]) : QString::fromAscii(fvals[i]); 00196 return true; 00197 case SQLITE_DONE: 00198 if (rInf.isEmpty()) 00199 // must be first call. 00200 init(cnames, colNum); 00201 q->setAt(QSql::AfterLastRow); 00202 return false; 00203 case SQLITE_ERROR: 00204 case SQLITE_MISUSE: 00205 default: 00206 // something wrong, don't get col info, but still return false 00207 finalize(); // finalize to get the error message. 00208 q->setAt(QSql::AfterLastRow); 00209 return false; 00210 } 00211 return false; 00212 }
Here is the call graph for this function:

| bool QSQLite2ResultPrivate::isSelect | ( | ) |
| void QSQLite2ResultPrivate::init | ( | const char ** | cnames, | |
| int | numCols | |||
| ) |
Definition at line 136 of file qsql_sqlite2.cpp.
References QSqlRecord::append(), QSqlRecord::clear(), QString::fromAscii(), i, QSqlCachedResult::init(), nameToType(), q, and rInf.
Referenced by fetchNext().
00137 { 00138 if (!cnames) 00139 return; 00140 00141 rInf.clear(); 00142 if (numCols <= 0) 00143 return; 00144 q->init(numCols); 00145 00146 for (int i = 0; i < numCols; ++i) { 00147 const char* lastDot = strrchr(cnames[i], '.'); 00148 const char* fieldName = lastDot ? lastDot + 1 : cnames[i]; 00149 rInf.append(QSqlField(QString::fromAscii(fieldName), 00150 nameToType(QString::fromAscii(cnames[i+numCols])))); 00151 } 00152 }
Here is the call graph for this function:

| void QSQLite2ResultPrivate::finalize | ( | ) |
Definition at line 119 of file qsql_sqlite2.cpp.
References currentMachine, QString::fromAscii(), q, QSqlResult::setLastError(), QSqlError::StatementError, and QCoreApplication::translate().
Referenced by cleanup(), and fetchNext().
00120 { 00121 if (!currentMachine) 00122 return; 00123 00124 char* err = 0; 00125 int res = sqlite_finalize(currentMachine, &err); 00126 if (err) { 00127 q->setLastError(QSqlError(QCoreApplication::translate("QSQLite2Result", 00128 "Unable to fetch results"), QString::fromAscii(err), 00129 QSqlError::StatementError, res)); 00130 sqlite_freemem(err); 00131 } 00132 currentMachine = 0; 00133 }
Here is the call graph for this function:

Definition at line 85 of file qsql_sqlite2.cpp.
Referenced by cleanup(), fetchNext(), finalize(), and init().
| sqlite* QSQLite2ResultPrivate::access |
Definition at line 86 of file qsql_sqlite2.cpp.
Referenced by QSQLite2Result::numRowsAffected(), QSQLite2Result::QSQLite2Result(), and QSQLite2Result::reset().
| const char* QSQLite2ResultPrivate::currentTail |
Definition at line 90 of file qsql_sqlite2.cpp.
Referenced by cleanup(), and QSQLite2Result::reset().
Definition at line 91 of file qsql_sqlite2.cpp.
Referenced by cleanup(), fetchNext(), finalize(), QSQLite2Result::handle(), and QSQLite2Result::reset().
Definition at line 93 of file qsql_sqlite2.cpp.
Referenced by cleanup(), fetchNext(), and QSQLite2Result::reset().
Definition at line 95 of file qsql_sqlite2.cpp.
Referenced by fetchNext(), QSQLite2Result::QSQLite2Result(), and QSQLite2Result::reset().
Definition at line 96 of file qsql_sqlite2.cpp.
Referenced by cleanup(), fetchNext(), init(), QSQLite2Result::record(), and QSQLite2Result::reset().
1.5.1