Software /
code /
prosody
Diff
util/sql.lua @ 9616:61376a3c0c1d 0.11
util.sql: Switch from hacky multi-arg xpcall implementation to util.xpcall
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 11 Nov 2018 02:26:40 +0100 |
parent | 8555:4f0f5b49bb03 |
child | 10038:7dd0dddd8e02 |
line wrap: on
line diff
--- a/util/sql.lua Fri Nov 09 18:49:45 2018 +0100 +++ b/util/sql.lua Sun Nov 11 02:26:40 2018 +0100 @@ -1,9 +1,10 @@ local setmetatable, getmetatable = setmetatable, getmetatable; -local ipairs, unpack, select = ipairs, table.unpack or unpack, select; --luacheck: ignore 113 143 +local ipairs = ipairs; local tostring = tostring; local type = type; -local assert, pcall, xpcall, debug_traceback = assert, pcall, xpcall, debug.traceback; +local assert, pcall, debug_traceback = assert, pcall, debug.traceback; +local xpcall = require "util.xpcall".xpcall; local t_concat = table.concat; local log = require "util.logger".init("sql"); @@ -200,11 +201,9 @@ if not ok then return ok, err; end end --assert(not self.__transaction, "Recursive transactions not allowed"); - local args, n_args = {...}, select("#", ...); - local function f() return func(unpack(args, 1, n_args)); end log("debug", "SQL transaction begin [%s]", tostring(func)); self.__transaction = true; - local success, a, b, c = xpcall(f, handleerr); + local success, a, b, c = xpcall(func, handleerr, ...); self.__transaction = nil; if success then log("debug", "SQL transaction success [%s]", tostring(func));