aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-04-12 21:53:21 +0200
committerKim Alvefur <zash@zash.se>2017-04-12 21:53:21 +0200
commitd938b42d8f9f4d2108383167c3b8139ad5157816 (patch)
treefa721151446290fa6423710d27dc2eaef890ac8d /plugins/mod_storage_sql.lua
parenta03638bd16746c0a2d9a3fcb682d5026104edaf2 (diff)
downloadprosody-d938b42d8f9f4d2108383167c3b8139ad5157816.tar.gz
prosody-d938b42d8f9f4d2108383167c3b8139ad5157816.zip
mod_storage_sql: Pass charset and collation names via variable binding
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua7
1 files changed, 3 insertions, 4 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index d9e45781..9f33d987 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -484,12 +484,11 @@ local function upgrade_table(engine, params, apply_changes) -- luacheck: ignore
local check_encoding_query = [[
SELECT "COLUMN_NAME","COLUMN_TYPE","TABLE_NAME"
FROM "information_schema"."columns"
- WHERE "TABLE_NAME" LIKE 'prosody%%' AND ( "CHARACTER_SET_NAME"!='%s' OR "COLLATION_NAME"!='%s_bin' );
+ WHERE "TABLE_NAME" LIKE 'prosody%%' AND ( "CHARACTER_SET_NAME"!=? OR "COLLATION_NAME"!=?);
]];
- 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 = assert(engine:execute(check_encoding_query));
+ local result = assert(engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin"));
local n_bad_columns = result:rowcount();
if n_bad_columns > 0 then
changes = true;
@@ -507,7 +506,7 @@ local function upgrade_table(engine, params, apply_changes) -- luacheck: ignore
end
end
end);
- success,err = engine:transaction(function() return engine:execute(check_encoding_query); end);
+ success,err = engine:transaction(function() return engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin"); end);
if not success then
module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error");
return false;