Software /
code /
prosody
Changeset
10012:acf4a7bfb6aa 0.11
mod_storage_sql: Handle SQLite DELETE with LIMIT being optional (fixes #1359)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 13 May 2019 14:39:38 +0200 |
parents | 10011:2408e6362c15 |
children | 10013:62d8689beafb |
files | plugins/mod_storage_sql.lua |
diffstat | 1 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Mon May 13 14:47:41 2019 +0200 +++ b/plugins/mod_storage_sql.lua Mon May 13 14:39:38 2019 +0200 @@ -399,12 +399,14 @@ 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 @@ 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;