diff options
author | Kim Alvefur <zash@zash.se> | 2012-09-17 05:42:10 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-09-17 05:42:10 +0200 |
commit | 07bb8a42ce660684bbe4742aeefd5ea92092a37e (patch) | |
tree | d7fb672e714c45dae2129e01afc73e33570c4c40 /plugins | |
parent | 136674425b54b191ecef0006d8460f84a4a67f35 (diff) | |
download | prosody-07bb8a42ce660684bbe4742aeefd5ea92092a37e.tar.gz prosody-07bb8a42ce660684bbe4742aeefd5ea92092a37e.zip |
storagemanager, datamanager, mod_storage_{internal,sql}: Replace list_stores() with an iterator version
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_storage_internal.lua | 4 | ||||
-rw-r--r-- | plugins/mod_storage_sql.lua | 17 |
2 files changed, 10 insertions, 11 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index 92ac3ef5..d8fdfc6f 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -16,8 +16,8 @@ function driver:set(user, data) return datamanager.store(user, host, self.store, data); end -function driver:list_stores(username) - return datamanager.list_stores(username, host); +function driver:stores(username) + return datamanager.stores(username, host); end function driver:purge(user) 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) |