aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-01-06 23:53:50 +0100
committerKim Alvefur <zash@zash.se>2023-01-06 23:53:50 +0100
commit7c647e1cee1cae8846001b338a761b7e86c5f667 (patch)
tree167457992353bde596c932a1075236137afae4a9 /plugins
parentf5006b12024db1c76601cfe69960788a254c2b26 (diff)
parent91a064bd4985f7bf826faacb9faa680088f9a453 (diff)
downloadprosody-7c647e1cee1cae8846001b338a761b7e86c5f667.tar.gz
prosody-7c647e1cee1cae8846001b338a761b7e86c5f667.zip
Merge 0.12->trunk
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql.lua26
1 files changed, 12 insertions, 14 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 938e838e..982ddada 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -469,12 +469,8 @@ function archive_store:find(username, query)
local ok, err = archive_where_id_range(query, args, where);
if not ok then return ok, err; end
- if query.limit then
- args[#args+1] = query.limit;
- end
-
sql_query = sql_query:format(t_concat(where, " AND "), query.reverse
- and "DESC" or "ASC", query.limit and " LIMIT ?" or "");
+ and "DESC" or "ASC", query.limit and " LIMIT " .. query.limit or "");
return engine:select(sql_query, unpack(args));
end);
if not ok then return ok, result; end
@@ -592,6 +588,17 @@ function archive_store:delete(username, query)
if not ok then return ok, err; end
if query.truncate == nil then
sql_query = sql_query:format(t_concat(where, " AND "));
+ 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 18446744073709551615 OFFSET %s
+ ) AS limiter on result.sort_id = limiter.sort_id;]];
+
+ sql_query = string.format(sql_query, t_concat(where, " AND "),
+ query.reverse and "ASC" or "DESC", query.truncate);
else
args[#args+1] = query.truncate;
local unlimited = "ALL";
@@ -613,15 +620,6 @@ function archive_store:delete(username, query)
]];
end
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";
end
sql_query = string.format(sql_query, t_concat(where, " AND "),
query.reverse and "ASC" or "DESC", unlimited);