Comparison

plugins/mod_storage_sql2.lua @ 5968:e1e9f1411442

mod_storage_sql2: Include user, host and store in id lookup
author Kim Alvefur <zash@zash.se>
date Wed, 25 Dec 2013 15:28:55 +0100
parent 5913:6865eecaf5a5
child 5969:0a3b8003ac9c
comparison
equal deleted inserted replaced
5954:6dc73be95213 5968:e1e9f1411442
254 where[#where+1] = "`key` = ?"; 254 where[#where+1] = "`key` = ?";
255 args[#args+1] = query.key 255 args[#args+1] = query.key
256 end 256 end
257 end 257 end
258 local function archive_where_id_range(query, args, where) 258 local function archive_where_id_range(query, args, where)
259 local args_len = #args
259 -- Before or after specific item, exclusive 260 -- Before or after specific item, exclusive
260 if query.after then -- keys better be unique! 261 if query.after then -- keys better be unique!
261 where[#where+1] = "`sort_id` > (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? LIMIT 1)" 262 where[#where+1] = "`sort_id` > (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ?`AND user` = ?`AND store` = ? LIMIT 1)"
262 args[#args+1] = query.after 263 args[args_len+1], args[args_len+2], args[args_len+3], args[args_len+4] = query.after, args[1], args[2], args[3];
264 args_len = args_len + 4
263 end 265 end
264 if query.before then 266 if query.before then
265 where[#where+1] = "`sort_id` < (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? LIMIT 1)" 267 where[#where+1] = "`sort_id` < (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ?`AND user` = ?`AND store` = ? LIMIT 1)"
266 args[#args+1] = query.before 268 args[args_len+1], args[args_len+2], args[args_len+3], args[args_len+4] = query.before, args[1], args[2], args[3];
267 end 269 end
268 end 270 end
269 271
270 function archive_store:find(username, query) 272 function archive_store:find(username, query)
271 query = query or {}; 273 query = query or {};