Software /
code /
prosody
Comparison
plugins/mod_storage_sql2.lua @ 6727:eb9c842b80fa
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 19 May 2015 23:23:44 +0200 |
parent | 6534:b89406fa076c |
parent | 6726:e6e80ec50030 |
child | 6729:daa5c83b2879 |
comparison
equal
deleted
inserted
replaced
6723:fb25dce69d41 | 6727:eb9c842b80fa |
---|---|
246 if not ok then return nil, result; end | 246 if not ok then return nil, result; end |
247 return result; | 247 return result; |
248 end | 248 end |
249 | 249 |
250 local archive_store = {} | 250 local archive_store = {} |
251 archive_store.caps = { | |
252 total = true; | |
253 }; | |
251 archive_store.__index = archive_store | 254 archive_store.__index = archive_store |
252 function archive_store:append(username, key, when, with, value) | 255 function archive_store:append(username, key, value, when, with) |
253 if value == nil then -- COMPAT early versions | 256 if type(when) ~= "number" then |
254 when, with, value, key = key, when, with, value | 257 value, when, with = when, with, value; |
255 end | 258 end |
256 local user,store = username,self.store; | 259 local user,store = username,self.store; |
257 return engine:transaction(function() | 260 return engine:transaction(function() |
258 if key then | 261 if key then |
259 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); | 262 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); |
312 function archive_store:find(username, query) | 315 function archive_store:find(username, query) |
313 query = query or {}; | 316 query = query or {}; |
314 local user,store = username,self.store; | 317 local user,store = username,self.store; |
315 local total; | 318 local total; |
316 local ok, result = engine:transaction(function() | 319 local ok, result = engine:transaction(function() |
317 local sql_query = "SELECT `key`, `type`, `value`, `when` FROM `prosodyarchive` WHERE %s ORDER BY `sort_id` %s%s;"; | 320 local sql_query = "SELECT `key`, `type`, `value`, `when`, `with` FROM `prosodyarchive` WHERE %s ORDER BY `sort_id` %s%s;"; |
318 local args = { host, user or "", store, }; | 321 local args = { host, user or "", store, }; |
319 local where = { "`host` = ?", "`user` = ?", "`store` = ?", }; | 322 local where = { "`host` = ?", "`user` = ?", "`store` = ?", }; |
320 | 323 |
321 archive_where(query, args, where); | 324 archive_where(query, args, where); |
322 | 325 |
344 end); | 347 end); |
345 if not ok then return ok, result end | 348 if not ok then return ok, result end |
346 return function() | 349 return function() |
347 local row = result(); | 350 local row = result(); |
348 if row ~= nil then | 351 if row ~= nil then |
349 return row[1], deserialize(row[2], row[3]), row[4]; | 352 return row[1], deserialize(row[2], row[3]), row[4], row[5]; |
350 end | 353 end |
351 end, total; | 354 end, total; |
352 end | 355 end |
353 | 356 |
354 function archive_store:delete(username, query) | 357 function archive_store:delete(username, query) |