Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 7847:c430932b8113
mod_storage_sql: Return number of affected items from archive:delete
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 22 Nov 2016 18:13:21 +0100 |
parent | 7757:437fb77e5ded |
child | 7857:db48b1697234 |
child | 7858:14fe60a65c69 |
comparison
equal
deleted
inserted
replaced
7846:22275bc5744a | 7847:c430932b8113 |
---|---|
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 return engine:transaction(function() | 290 local stmt, err = 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 end | 304 end |
304 | 305 |
305 local stores = { | 306 local stores = { |
306 keyval = keyval_store; | 307 keyval = keyval_store; |
307 map = map_store; | 308 map = map_store; |