aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-11-30 15:58:23 +0100
committerKim Alvefur <zash@zash.se>2021-11-30 15:58:23 +0100
commit36bbf6b07704941852cb894c2936ced1aa44baf5 (patch)
treece2789f806503874b51ca8d21f390356d9875276 /plugins/mod_storage_sql.lua
parent0d9065ae80cf76bd9b0042fb9d2f1ecfc9e06fc9 (diff)
downloadprosody-36bbf6b07704941852cb894c2936ced1aa44baf5.tar.gz
prosody-36bbf6b07704941852cb894c2936ced1aa44baf5.zip
mod_storage_sql: Adjust handling of 'total' for multi-id queries
Otherwise a query for a set of ids may cause that value to be cached, despite only covering a subset.
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index deafb005..7babd969 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -428,7 +428,8 @@ function archive_store:find(username, query)
local cache_key = jid_join(username, host, self.store);
local total = archive_item_count_cache:get(cache_key);
(total and item_count_cache_hit or item_count_cache_miss)();
- if total ~= nil and query.limit == 0 and query.start == nil and query.with == nil and query["end"] == nil and query.key == nil then
+ if total ~= nil and query.limit == 0 and query.start == nil and query.with == nil and query["end"] == nil
+ and query.key == nil and query.ids == nil then
return noop, total;
end
local ok, result, err = engine:transaction(function()
@@ -452,7 +453,7 @@ function archive_store:find(username, query)
total = row[1];
end
end
- if query.start == nil and query.with == nil and query["end"] == nil and query.key == nil then
+ if query.start == nil and query.with == nil and query["end"] == nil and query.key == nil and query.ids == nil then
archive_item_count_cache:set(cache_key, total);
end
if query.limit == 0 then -- Skip the real query