aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-07-28 21:26:33 +0200
committerKim Alvefur <zash@zash.se>2012-07-28 21:26:33 +0200
commit780317603fa5d92f7123d26138dfc977b8280590 (patch)
treef3cd53c267df13746dbeda05aabd8ceaeab5e30f /plugins/mod_storage_sql.lua
parentf3b4b75347db35923084aa8a113a55287a1f5398 (diff)
downloadprosody-780317603fa5d92f7123d26138dfc977b8280590.tar.gz
prosody-780317603fa5d92f7123d26138dfc977b8280590.zip
mod_storage_sql: Split out query handling logic from getsql() into a separate function
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 6a2d36f1..8b05c822 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -175,7 +175,7 @@ local function deserialize(t, value)
end
end
-local function getsql(sql, ...)
+local function dosql(sql, ...)
if params.driver == "PostgreSQL" then
sql = sql:gsub("`", "\"");
end
@@ -184,12 +184,15 @@ local function getsql(sql, ...)
if not stmt and not test_connection() then error("connection failed"); end
if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end
-- run query
- local ok, err = stmt:execute(host or "", user or "", store or "", ...);
+ local ok, err = stmt:execute(...);
if not ok and not test_connection() then error("connection failed"); end
if not ok then return nil, err; end
return stmt;
end
+local function getsql(sql, ...)
+ return dosql(sql, host or "", user or "", store or "", ...);
+end
local function setsql(sql, ...)
local stmt, err = getsql(sql, ...);
if not stmt then return stmt, err; end