# HG changeset patch # User Kim Alvefur # Date 1387981735 -3600 # Node ID e1e9f14114423f7e389e6c2ec87b19b8c58b0d9c # Parent 6dc73be95213ad283221554652ec0272ebd79418 mod_storage_sql2: Include user, host and store in id lookup diff -r 6dc73be95213 -r e1e9f1411442 plugins/mod_storage_sql2.lua --- a/plugins/mod_storage_sql2.lua Wed Dec 18 18:36:54 2013 +0100 +++ b/plugins/mod_storage_sql2.lua Wed Dec 25 15:28:55 2013 +0100 @@ -256,14 +256,16 @@ end end local function archive_where_id_range(query, args, where) + local args_len = #args -- Before or after specific item, exclusive if query.after then -- keys better be unique! - where[#where+1] = "`sort_id` > (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? LIMIT 1)" - args[#args+1] = query.after + where[#where+1] = "`sort_id` > (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ?`AND user` = ?`AND store` = ? LIMIT 1)" + args[args_len+1], args[args_len+2], args[args_len+3], args[args_len+4] = query.after, args[1], args[2], args[3]; + args_len = args_len + 4 end if query.before then - where[#where+1] = "`sort_id` < (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? LIMIT 1)" - args[#args+1] = query.before + where[#where+1] = "`sort_id` < (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ?`AND user` = ?`AND store` = ? LIMIT 1)" + args[args_len+1], args[args_len+2], args[args_len+3], args[args_len+4] = query.before, args[1], args[2], args[3]; end end