aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-04-12 20:59:18 +0200
committerKim Alvefur <zash@zash.se>2017-04-12 20:59:18 +0200
commita22c6725be05e65b0ccde5b8e2b8eb22944a3426 (patch)
tree812565071e2a3b84ab2fee8ca331e5be4b6e63e7
parent8a9dd05b08a3a85b84680547e9b0f2027499fd37 (diff)
parentb3cd19063f63fa426f35523bfb77be45d1e0dd4e (diff)
downloadprosody-a22c6725be05e65b0ccde5b8e2b8eb22944a3426.tar.gz
prosody-a22c6725be05e65b0ccde5b8e2b8eb22944a3426.zip
Merge 0.10->trunk
-rw-r--r--plugins/mod_storage_sql.lua2
-rw-r--r--util/sql.lua4
2 files changed, 3 insertions, 3 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 70fea09f..bf7190b8 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -489,7 +489,7 @@ local function upgrade_table(engine, params, apply_changes) -- luacheck: ignore
check_encoding_query = check_encoding_query:format(engine.charset, engine.charset);
-- FIXME Is it ok to ignore the return values from this?
engine:transaction(function()
- local result = engine:execute(check_encoding_query);
+ local result = assert(engine:execute(check_encoding_query));
local n_bad_columns = result:rowcount();
if n_bad_columns > 0 then
changes = true;
diff --git a/util/sql.lua b/util/sql.lua
index a859ddc9..f7c68ed3 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -139,6 +139,7 @@ function engine:execute(sql, ...)
if not success then return success, err; end
local prepared = self.prepared;
+ sql = self:prepquery(sql);
local stmt = prepared[sql];
if not stmt then
local err;
@@ -159,6 +160,7 @@ local result_mt = { __index = {
local function debugquery(where, sql, ...)
local i = 0; local a = {...}
+ sql = sql:gsub("\n?\t+", " ");
log("debug", "[%s] %s", where, sql:gsub("%?", function () i = i + 1; local v = a[i]; if type(v) == "string" then v = ("%q"):format(v); end return tostring(v); end));
end
@@ -254,7 +256,6 @@ function engine:_create_index(index)
if index.unique then
sql = sql:gsub("^CREATE", "CREATE UNIQUE");
end
- sql = self:prepquery(sql);
if self._debug then
debugquery("create", sql);
end
@@ -286,7 +287,6 @@ function engine:_create_table(table)
if self.params.driver == "MySQL" then
sql = sql:gsub(";$", (" CHARACTER SET '%s' COLLATE '%s_bin';"):format(self.charset, self.charset));
end
- sql = self:prepquery(sql);
if self._debug then
debugquery("create", sql);
end