aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-03-13 17:42:22 +0100
committerKim Alvefur <zash@zash.se>2016-03-13 17:42:22 +0100
commit9df91659b930ab36d9761b049d18ed30f4b93352 (patch)
tree8867ee32d7b350dcd8bd93844ef016d338531dc4 /plugins/mod_storage_sql.lua
parentb65ec4aebe68d0810faa076c7ae68acc2abe34e3 (diff)
downloadprosody-9df91659b930ab36d9761b049d18ed30f4b93352.tar.gz
prosody-9df91659b930ab36d9761b049d18ed30f4b93352.zip
mod_storage_sql: Add LIMIT clause to queries where only a single row is expected
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index bf3c1c7b..a289310b 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -134,11 +134,11 @@ map_store.remove = {};
function map_store:get(username, key)
local ok, result = engine:transaction(function()
if type(key) == "string" and key ~= "" then
- for row in engine:select("SELECT `type`, `value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, username or "", self.store, key) do
+ for row in engine:select("SELECT `type`, `value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=? LIMIT 1", host, username or "", self.store, key) do
return deserialize(row[1], row[2]);
end
else
- for row in engine:select("SELECT `type`, `value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, username or "", self.store, "") do
+ for row in engine:select("SELECT `type`, `value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=? LIMIT 1", host, username or "", self.store, "") do
local data = deserialize(row[1], row[2]);
return data and data[key] or nil;
end
@@ -163,7 +163,7 @@ function map_store:set_keys(username, keydatas)
end
else
local extradata = {};
- for row in engine:select("SELECT `type`, `value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, username or "", self.store, "") do
+ for row in engine:select("SELECT `type`, `value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=? LIMIT 1", host, username or "", self.store, "") do
extradata = deserialize(row[1], row[2]);
break;
end