Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 7859:9eb13c14eaab
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 24 Jan 2017 19:27:17 +0100 |
parent | 7857:db48b1697234 |
parent | 7858:14fe60a65c69 |
child | 7909:428d4abee723 |
comparison
equal
deleted
inserted
replaced
7857:db48b1697234 | 7859:9eb13c14eaab |
---|---|
285 end | 285 end |
286 | 286 |
287 function archive_store:delete(username, query) | 287 function archive_store:delete(username, query) |
288 query = query or {}; | 288 query = query or {}; |
289 local user,store = username,self.store; | 289 local user,store = username,self.store; |
290 local stmt, err = engine:transaction(function() | 290 local ok, stmt = engine:transaction(function() |
291 local sql_query = "DELETE FROM `prosodyarchive` WHERE %s;"; | 291 local sql_query = "DELETE FROM `prosodyarchive` WHERE %s;"; |
292 local args = { host, user or "", store, }; | 292 local args = { host, user or "", store, }; |
293 local where = { "`host` = ?", "`user` = ?", "`store` = ?", }; | 293 local where = { "`host` = ?", "`user` = ?", "`store` = ?", }; |
294 if user == true then | 294 if user == true then |
295 table.remove(args, 2); | 295 table.remove(args, 2); |
298 archive_where(query, args, where); | 298 archive_where(query, args, where); |
299 archive_where_id_range(query, args, where); | 299 archive_where_id_range(query, args, where); |
300 sql_query = sql_query:format(t_concat(where, " AND ")); | 300 sql_query = sql_query:format(t_concat(where, " AND ")); |
301 return engine:delete(sql_query, unpack(args)); | 301 return engine:delete(sql_query, unpack(args)); |
302 end); | 302 end); |
303 return stmt and stmt:affected() or nil, err; | 303 return ok and stmt:affected(), stmt; |
304 end | 304 end |
305 | 305 |
306 local stores = { | 306 local stores = { |
307 keyval = keyval_store; | 307 keyval = keyval_store; |
308 map = map_store; | 308 map = map_store; |