Software /
code /
prosody
Comparison
util/sql.lua @ 8378:6a098961bc00
util.sql: Return an error message when a SQL commit fails (LuaDBI doesn't) (Thanks Ge0rG)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 07 Nov 2017 09:26:48 +0100 |
parent | 8288:e9ac2d93de18 |
child | 8380:a597ff326758 |
comparison
equal
deleted
inserted
replaced
8368:3629639d5fa9 | 8378:6a098961bc00 |
---|---|
234 local success, a, b, c = xpcall(f, handleerr); | 234 local success, a, b, c = xpcall(f, handleerr); |
235 self.__transaction = nil; | 235 self.__transaction = nil; |
236 if success then | 236 if success then |
237 log("debug", "SQL transaction success [%s]", tostring(func)); | 237 log("debug", "SQL transaction success [%s]", tostring(func)); |
238 local ok, err = self.conn:commit(); | 238 local ok, err = self.conn:commit(); |
239 if not ok then return ok, err; end -- commit failed | 239 -- LuaDBI doesn't actually return an error message here, just a boolean |
240 if not ok then return ok, err or "commit failed"; end | |
240 return success, a, b, c; | 241 return success, a, b, c; |
241 else | 242 else |
242 log("debug", "SQL transaction failure [%s]: %s", tostring(func), a.err); | 243 log("debug", "SQL transaction failure [%s]: %s", tostring(func), a.err); |
243 if self.conn then self.conn:rollback(); end | 244 if self.conn then self.conn:rollback(); end |
244 return success, a.err; | 245 return success, a.err; |