aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-09-17 05:42:10 +0200
committerKim Alvefur <zash@zash.se>2012-09-17 05:42:10 +0200
commitf7f8f20929972134c129aea7c53ec45eb60e0454 (patch)
treed7fb672e714c45dae2129e01afc73e33570c4c40 /plugins/mod_storage_sql.lua
parent172562976cd1ef9395f8f6913d49f02d3ba3dba2 (diff)
downloadprosody-f7f8f20929972134c129aea7c53ec45eb60e0454.tar.gz
prosody-f7f8f20929972134c129aea7c53ec45eb60e0454.zip
storagemanager, datamanager, mod_storage_{internal,sql}: Replace list_stores() with an iterator version
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 ea25c90b..5a08598a 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) -- Not to be confused with the list store type
+ 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)