summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
diff options
context:
space:
mode:
authorZou Ya <[email protected]>2020-11-24 19:54:09 +0800
committerVolker Hilsheimer <[email protected]>2020-11-26 14:43:20 +0100
commit5b93f6cae692363ab03b0c9b0ae8efd0bb4ef499 (patch)
treec3f85874099bc91c0b411ef08f54abcd1a7dc1c4 /src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
parent6cb36d825d365988ea7a601218bdd3a329290469 (diff)
Reduce the scope of variables in exec() and fetchNext()
The scope of the variable 'currBind' can be reduced if the variable 'r' is not 0. So declare the variable when the variable 'r' is 0. The local variable 'i' shadows outer variable in fetchNext(), so move it to the front of switch. Don't declare 'res' until we need and initialize it. Change-Id: Idfb220b96cfbcd4088fd7858ed9392d0a3e10aea Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp')
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 4f70728d733..2914fac3e70 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -249,8 +249,6 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset)
bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int idx, bool initialFetch)
{
Q_Q(QSQLiteResult);
- int res;
- int i;
if (skipRow) {
// already fetched
@@ -273,8 +271,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i
q->setAt(QSql::AfterLastRow);
return false;
}
- res = sqlite3_step(stmt);
-
+ int res = sqlite3_step(stmt);
switch(res) {
case SQLITE_ROW:
// check to see if should fill out columns
@@ -283,7 +280,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i
initColumns(false);
if (idx < 0 && !initialFetch)
return true;
- for (i = 0; i < rInf.count(); ++i) {
+ for (int i = 0; i < rInf.count(); ++i) {
switch (sqlite3_column_type(stmt, i)) {
case SQLITE_BLOB:
values[i + idx] = QByteArray(static_cast<const char *>(