# HG changeset patch # User Kim Alvefur # Date 1343503593 -7200 # Node ID 2dbb3bf74090bc4644f50a5bd9e135bcc115d0a8 # Parent c64b5081bfa8d4543ccbe44f71d56ab7ea8a1c5d mod_storage_sql: Split out query handling logic from getsql() into a separate function diff -r c64b5081bfa8 -r 2dbb3bf74090 plugins/mod_storage_sql.lua --- 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