aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-09-19 12:14:08 +0100
committerMatthew Wild <mwild1@gmail.com>2012-09-19 12:14:08 +0100
commitfc11c75968dab816534939aafb2378dcd052c5e5 (patch)
treecf7a08a965f0bb9816285dcc830a140b62fc0ab1 /plugins/mod_storage_sql.lua
parent5f27e2a04037afdb5da8ef53b88ffa7b25014e32 (diff)
parentec41d90e0f1dd90bf7908acbf5ab25301dec9519 (diff)
downloadprosody-fc11c75968dab816534939aafb2378dcd052c5e5.tar.gz
prosody-fc11c75968dab816534939aafb2378dcd052c5e5.zip
Merge 0.9->trunk
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index ebc337bf..c9a45fca 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -374,10 +374,9 @@ function driver:open(store, typ)
return nil, "unsupported-store";
end
-function driver:list_stores(username) -- Not to be confused with the list store type
- local sql = (username == true
- and "SELECT DISTINCT `store` FROM `prosody` WHERE `host`=? AND `user`!=?"
- or "SELECT DISTINCT `store` FROM `prosody` WHERE `host`=? AND `user`=?");
+function driver:stores(username)
+ local sql = "SELECT DISTINCT `store` FROM `prosody` WHERE `host`=? AND `user`" ..
+ (username == true and "!=?" or "=?");
if username == true or not username then
username = "";
end
@@ -385,11 +384,11 @@ function driver:list_stores(username) -- Not to be confused with the list store
if not stmt then
return rollback(nil, err);
end
- local stores = {};
- for row in stmt:rows() do
- stores[#stores+1] = row[1];
- end
- return commit(stores);
+ local next = stmt:rows();
+ return commit(function()
+ local row = next();
+ return row and row[1];
+ end);
end
function driver:purge(username)