From 358ade297948443295224b6400e06447636c0e32 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 30 Jul 2019 02:23:44 +0200 Subject: util.sql: Remove tostring call from logging Taken care of by loggingmanager now --- util/sql.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'util/sql.lua') diff --git a/util/sql.lua b/util/sql.lua index 00c7b57f..4406d7ff 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -201,18 +201,18 @@ function engine:_transaction(func, ...) if not ok then return ok, err; end end --assert(not self.__transaction, "Recursive transactions not allowed"); - log("debug", "SQL transaction begin [%s]", tostring(func)); + log("debug", "SQL transaction begin [%s]", func); self.__transaction = true; local success, a, b, c = xpcall(func, handleerr, ...); self.__transaction = nil; if success then - log("debug", "SQL transaction success [%s]", tostring(func)); + log("debug", "SQL transaction success [%s]", func); local ok, err = self.conn:commit(); -- LuaDBI doesn't actually return an error message here, just a boolean if not ok then return ok, err or "commit failed"; end return success, a, b, c; else - log("debug", "SQL transaction failure [%s]: %s", tostring(func), a.err); + log("debug", "SQL transaction failure [%s]: %s", func, a.err); if self.conn then self.conn:rollback(); end return success, a.err; end @@ -224,7 +224,7 @@ function engine:transaction(...) if not conn or not conn:ping() then log("debug", "Database connection was closed. Will reconnect and retry."); self.conn = nil; - log("debug", "Retrying SQL transaction [%s]", tostring((...))); + log("debug", "Retrying SQL transaction [%s]", (...)); ok, ret = self:_transaction(...); log("debug", "SQL transaction retry %s", ok and "succeeded" or "failed"); else -- cgit v1.2.3 From 272944f4dfb578ad6ed13c5d323cad4c74f3e5d1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 28 Sep 2019 18:24:28 +0200 Subject: util.sql: Preserve 3rd and 4th return values from transaction (fixes #1434) (thanks mrdoctorwho) --- util/sql.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'util/sql.lua') diff --git a/util/sql.lua b/util/sql.lua index 4406d7ff..86740b1c 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -218,14 +218,14 @@ function engine:_transaction(func, ...) end end function engine:transaction(...) - local ok, ret = self:_transaction(...); + local ok, ret, b, c = self:_transaction(...); if not ok then local conn = self.conn; if not conn or not conn:ping() then log("debug", "Database connection was closed. Will reconnect and retry."); self.conn = nil; log("debug", "Retrying SQL transaction [%s]", (...)); - ok, ret = self:_transaction(...); + ok, ret, b, c = self:_transaction(...); log("debug", "SQL transaction retry %s", ok and "succeeded" or "failed"); else log("debug", "SQL connection is up, so not retrying"); @@ -234,7 +234,7 @@ function engine:transaction(...) log("error", "Error in SQL transaction: %s", ret); end end - return ok, ret; + return ok, ret, b, c; end function engine:_create_index(index) local sql = "CREATE INDEX \""..index.name.."\" ON \""..index.table.."\" ("; -- cgit v1.2.3 From b0361006e16aa8d861e85aea5a4ab3bc163dc229 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 23 Dec 2019 21:13:27 +0100 Subject: util.sql: Handle failure to detect connection encoding Silences a luacheck warning about an unused variable --- util/sql.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/sql.lua') diff --git a/util/sql.lua b/util/sql.lua index 86740b1c..9d1c86ca 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -335,6 +335,9 @@ function engine:set_encoding() -- to UTF-8 local ok, actual_charset = self:transaction(function () return self:select"SHOW SESSION VARIABLES LIKE 'character_set_client'"; end); + if not ok then + return false, "Failed to detect connection encoding"; + end local charset_ok = true; for row in actual_charset do if row[2] ~= charset then -- cgit v1.2.3