aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-01-16 01:58:22 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2025-01-16 01:58:22 -0500
commita5ae79be08125b31bb6b8d9703090a98c6fd2e30 (patch)
tree569ee612c9de85b2bb423efa485688ef1d43852e /SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h
parent21966b4f924b0a1933d9662e75ff253bd154fdb7 (diff)
parent81a21e6ce040e7740de86340c8ea4dba30e69bc3 (diff)
Update upstream source from tag 'upstream/3.4.13+dfsg'
Update to upstream version '3.4.13+dfsg' with Debian dir bf81ee0219cb8e4562a4751df17d75814772d2d6
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h b/SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h
index f8812e9..d1831e2 100644
--- a/SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h
+++ b/SQLiteStudio3/coreSQLiteStudio/db/abstractdb3.h
@@ -65,6 +65,7 @@ class AbstractDb3 : public AbstractDb
bool registerAggregateFunction(const QString& name, int argCount, bool deterministic);
bool registerCollationInternal(const QString& name);
bool deregisterCollationInternal(const QString& name);
+ bool isTransactionActive() const;
private:
class Query : public SqlQuery
@@ -362,7 +363,7 @@ QList<AliasedColumn> AbstractDb3<T>::columnsForQuery(const QString& query)
return result;
}
- if (tail && !QString::fromUtf8(tail).trimmed().isEmpty())
+ if (tail && !QString::fromUtf8(tail).trimmed().isEmpty() && !removeComments(QString::fromUtf8(tail)).trimmed().isEmpty())
qWarning() << "Executed query left with tailing contents:" << tail << ", while finding columns for query:" << query;
@@ -556,6 +557,12 @@ bool AbstractDb3<T>::registerCollationInternal(const QString& name)
if (!dbHandle)
return false;
+ CollationManager::CollationPtr collation = COLLATIONS->getCollation(name);
+ if (collation == nullptr)
+ return false;
+ if (collation->type == CollationManager::CollationType::EXTENSION_BASED)
+ return !(exec(collation->code, Flag::NO_LOCK)->isError());
+
CollationUserData* userData = new CollationUserData;
userData->name = name;
@@ -875,6 +882,15 @@ void AbstractDb3<T>::registerDefaultCollationRequestHandler()
qWarning() << "Could not register default collation request handler. Unknown collations will cause errors.";
}
+template <class T>
+bool AbstractDb3<T>::isTransactionActive() const
+{
+ if (!dbHandle)
+ return false;
+
+ return !T::get_autocommit(dbHandle);
+}
+
//------------------------------------------------------------------------------------
// Results
//------------------------------------------------------------------------------------
@@ -940,7 +956,7 @@ int AbstractDb3<T>::Query::prepareStmt()
return res;
}
- if (tail && !QString::fromUtf8(tail).trimmed().isEmpty())
+ if (tail && !QString::fromUtf8(tail).trimmed().isEmpty() && !removeComments(QString::fromUtf8(tail)).trimmed().isEmpty())
qWarning() << "Executed query left with tailing contents:" << tail << ", while executing query:" << query;
return T::OK;
@@ -1189,14 +1205,14 @@ int AbstractDb3<T>::Query::fetchFirst()
for (int i = 0; i < colCount; i++)
colNames << QString::fromUtf8(T::column_name(stmt, i));
- int changesBefore = T::total_changes(db->dbHandle);
+ qint64 changesBefore = T::total_changes64(db->dbHandle);
rowAvailable = true;
int res = fetchNext();
affected = 0;
if (res == T::OK)
{
- affected = T::total_changes(db->dbHandle) - changesBefore;
+ affected = T::total_changes64(db->dbHandle) - changesBefore;
insertRowId["ROWID"] = T::last_insert_rowid(db->dbHandle);
}
@@ -1218,7 +1234,8 @@ int AbstractDb3<T>::Query::fetchNext()
rowAvailable = false;
int res;
int secondsSpent = 0;
- while ((res = T::step(stmt)) == T::BUSY && secondsSpent < db->getTimeout())
+ bool zeroTimeout = flags.testFlag(Db::Flag::ZERO_TIMEOUT);
+ while ((res = T::step(stmt)) == T::BUSY && !zeroTimeout && secondsSpent < db->getTimeout() && !T::is_interrupted(db->dbHandle))
{
QThread::sleep(1);
if (db->getTimeout() >= 0)
@@ -1233,6 +1250,9 @@ int AbstractDb3<T>::Query::fetchNext()
case T::DONE:
// Empty pointer as no more results are available.
break;
+ case T::INTERRUPT:
+ setError(res, QString::fromUtf8(T::errmsg(db->dbHandle)));
+ return T::INTERRUPT;
default:
setError(res, QString::fromUtf8(T::errmsg(db->dbHandle)));
return T::ERROR;