# HG changeset patch # User Kim Alvefur # Date 1638284303 -3600 # Node ID f0e78fa8f24c3062b7534d7a5522af80718c317c # Parent 395dce95508d51dce1f64aae8db7e93746b2de42 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. diff -r 395dce95508d -r f0e78fa8f24c plugins/mod_storage_sql.lua --- a/plugins/mod_storage_sql.lua Tue Nov 30 15:24:17 2021 +0100 +++ b/plugins/mod_storage_sql.lua Tue Nov 30 15:58:23 2021 +0100 @@ -428,7 +428,8 @@ 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 @@ 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