Software /
code /
prosody
Changeset
5034:2dbb3bf74090
mod_storage_sql: Split out query handling logic from getsql() into a separate function
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 28 Jul 2012 21:26:33 +0200 |
parents | 5033:c64b5081bfa8 |
children | 5035:874cab7b4b3e |
files | plugins/mod_storage_sql.lua |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Sat Jul 28 21:24:59 2012 +0200 +++ b/plugins/mod_storage_sql.lua Sat Jul 28 21:26:33 2012 +0200 @@ -175,7 +175,7 @@ end end -local function getsql(sql, ...) +local function dosql(sql, ...) if params.driver == "PostgreSQL" then sql = sql:gsub("`", "\""); end @@ -184,12 +184,15 @@ 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