aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.cpp
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/sqlfileexecutor.cpp
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/sqlfileexecutor.cpp')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.cpp b/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.cpp
index 819d222..b2f46e5 100644
--- a/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.cpp
+++ b/SQLiteStudio3/coreSQLiteStudio/sqlfileexecutor.cpp
@@ -26,17 +26,22 @@ void SqlFileExecutor::execSqlFromFile(Db* db, const QString& filePath, bool igno
return;
}
- fkWasEnabled = db->exec("PRAGMA foreign_keys")->getSingleCell().toBool();
- if (fkWasEnabled)
- {
- SqlQueryPtr res = db->exec("PRAGMA foreign_keys = 0");
- if (res->isError())
- {
- qDebug() << "Failed to temporarily disable foreign keys enforcement:" << db->getErrorText();
- emit execEnded();
- return;
- }
- }
+ // #4871 is caused by this. On one hand it doesn't make sense to disable FK for script execution
+ // (after all we're trying to execute script just like from SQL Editor, but we do it directly from file),
+ // but on the other hand, it was introduced probably for some reason. It's kept commented for now to see
+ // if good reason for it reappears. It's a subject for removal in future (until end of 2025).
+ //
+ // fkWasEnabled = db->exec("PRAGMA foreign_keys")->getSingleCell().toBool();
+ // if (fkWasEnabled)
+ // {
+ // SqlQueryPtr res = db->exec("PRAGMA foreign_keys = 0");
+ // if (res->isError())
+ // {
+ // qDebug() << "Failed to temporarily disable foreign keys enforcement:" << db->getErrorText();
+ // emit execEnded();
+ // return;
+ // }
+ // }
// Exec file
executionInProgress = 1;
@@ -113,12 +118,14 @@ void SqlFileExecutor::execInThread()
QList<QPair<QString, QString>> errors = executeFromStream(stream, executed, attemptedExecutions, ok, fileSize);
int millis = timer.elapsed();
- if (fkWasEnabled)
- {
- SqlQueryPtr res = db->exec("PRAGMA foreign_keys = 1");
- if (res->isError())
- qDebug() << "Failed to restore foreign keys enforcement after execution SQL from file:" << res->getErrorText();
- }
+ // See comment about fkWasEnabled above.
+ //
+ // if (fkWasEnabled)
+ // {
+ // SqlQueryPtr res = db->exec("PRAGMA foreign_keys = 1");
+ // if (res->isError())
+ // qDebug() << "Failed to restore foreign keys enforcement after execution SQL from file:" << res->getErrorText();
+ // }
if (executionInProgress.loadAcquire())
{
@@ -215,7 +222,7 @@ bool SqlFileExecutor::shouldSkipQuery(const QString& sql)
if (sql.trimmed().isEmpty() || !db->isComplete(sql))
return true;
- QString upper = sql.toUpper().trimmed().split("\n").last().trimmed();
+ QString upper = sql.toUpper().trimmed();
return (upper.startsWith("BEGIN") ||
upper.startsWith("COMMIT") ||
upper.startsWith("ROLLBACK") ||