aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-07-10 12:08:44 +0200
committerKim Alvefur <zash@zash.se>2013-07-10 12:08:44 +0200
commite3d8ade9f0e8b2331fc65b7c8dab4282b1ce9df8 (patch)
tree205b4dadd622fae07ee601edc748ef19d09cbf62 /plugins
parentb49b1888f8aa3a695b6cc322b7066177c51db35f (diff)
downloadprosody-e3d8ade9f0e8b2331fc65b7c8dab4282b1ce9df8.tar.gz
prosody-e3d8ade9f0e8b2331fc65b7c8dab4282b1ce9df8.zip
mod_storage_sql2: Fix iteration over users and stores
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql2.lua18
1 files changed, 16 insertions, 2 deletions
diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua
index 24c08cf5..0b57d48b 100644
--- a/plugins/mod_storage_sql2.lua
+++ b/plugins/mod_storage_sql2.lua
@@ -2,6 +2,16 @@
local json = require "util.json";
local resolve_relative_path = require "core.configmanager".resolve_relative_path;
+local unpack = unpack
+local function iterator(result)
+ return function(result)
+ local row = result();
+ if row ~= nil then
+ return unpack(row);
+ end
+ end, result, nil;
+end
+
local mod_sql = module:require("sql");
local params = module:get_option("sql");
@@ -200,9 +210,11 @@ function keyval_store:set(username, data)
end);
end
function keyval_store:users()
- return engine:transaction(function()
+ local ok, result = engine:transaction(function()
return engine:select("SELECT DISTINCT `user` FROM `prosody` WHERE `host`=? AND `store`=?", host, self.store);
end);
+ if not ok then return ok, result end
+ return iterator(result);
end
local driver = {};
@@ -220,9 +232,11 @@ function driver:stores(username)
if username == true or not username then
username = "";
end
- return engine:transaction(function()
+ local ok, result = engine:transaction(function()
return engine:select(sql, host, username);
end);
+ if not ok then return ok, result end
+ return iterator(result);
end
function driver:purge(username)