aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-13 14:39:38 +0200
committerKim Alvefur <zash@zash.se>2019-05-13 14:39:38 +0200
commit9838f3732d53e1e3d34cd57a25a030f61005cb53 (patch)
tree484f46e0f8449e79a3e98a92950e46ad676715dd /plugins/mod_storage_sql.lua
parent1045642fa450a0dd46009a39c6a1fa4b949e9888 (diff)
downloadprosody-9838f3732d53e1e3d34cd57a25a030f61005cb53.tar.gz
prosody-9838f3732d53e1e3d34cd57a25a030f61005cb53.zip
mod_storage_sql: Handle SQLite DELETE with LIMIT being optional (fixes #1359)
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index dbf5e2da..a449091e 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -399,12 +399,14 @@ function archive_store:delete(username, query)
LIMIT %s OFFSET ?
);]];
if engine.params.driver == "SQLite3" then
- sql_query = [[
- DELETE FROM "prosodyarchive"
- WHERE %s
- ORDER BY "sort_id" %s
- LIMIT %s OFFSET ?;
- ]];
+ if engine._have_delete_limit then
+ sql_query = [[
+ DELETE FROM "prosodyarchive"
+ WHERE %s
+ ORDER BY "sort_id" %s
+ LIMIT %s OFFSET ?;
+ ]];
+ end
unlimited = "-1";
elseif engine.params.driver == "MySQL" then
sql_query = [[
@@ -620,6 +622,13 @@ function module.load()
module:log("error", "Old database format detected. Please run: prosodyctl mod_%s upgrade", module.name);
return false, "database upgrade needed";
end
+ if engine.params.driver == "SQLite3" then
+ for row in engine:select("PRAGMA compile_options") do
+ if row[1] == "ENABLE_UPDATE_DELETE_LIMIT" then
+ engine._have_delete_limit = true;
+ end
+ end
+ end
end
end);
engines[sql.db2uri(params)] = engine;