aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-10-11 18:20:09 +0100
committerMatthew Wild <mwild1@gmail.com>2018-10-11 18:20:09 +0100
commit41a32414b092fb1f3a0aafa5c97956704f21bad5 (patch)
tree4640ccbf8dbf69b93785417d8fb842296ac55216 /plugins/mod_storage_sql.lua
parentdd8a4ff4985f7b739a38ceb20f56225c2fbfd547 (diff)
downloadprosody-41a32414b092fb1f3a0aafa5c97956704f21bad5.tar.gz
prosody-41a32414b092fb1f3a0aafa5c97956704f21bad5.zip
mod_storage_sql: Workaround MySQL not supporting LIMIT subquery in archive truncate operations, fixes #1200
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 018d0d29..395e937d 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -398,6 +398,15 @@ function archive_store:delete(username, query)
LIMIT %s OFFSET ?;
]];
unlimited = "-1";
+ elseif engine.params.driver == "MySQL" then
+ sql_query = [[
+ DELETE result FROM prosodyarchive AS result JOIN (
+ SELECT sort_id FROM prosodyarchive
+ WHERE %s
+ ORDER BY "sort_id" %s
+ LIMIT %s OFFSET ?
+ ) AS limiter on result.sort_id = limiter.sort_id;]];
+ unlimited = "18446744073709551615";
else
sql_query = [[
DELETE FROM "prosodyarchive"
@@ -407,9 +416,6 @@ function archive_store:delete(username, query)
ORDER BY "sort_id" %s
LIMIT %s OFFSET ?
);]];
- if engine.params.driver == "MySQL" then
- unlimited = "18446744073709551615";
- end
end
sql_query = string.format(sql_query, t_concat(where, " AND "),
query.reverse and "ASC" or "DESC", unlimited);