Changeset

8080:8833f2ca6e53

mod_storage_sql: Pass charset and collation names via variable binding
author Kim Alvefur <zash@zash.se>
date Wed, 12 Apr 2017 21:53:21 +0200
parents 8079:b058fc4a4243
children 8081:a201f315de55
files plugins/mod_storage_sql.lua
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Wed Apr 12 21:51:17 2017 +0200
+++ b/plugins/mod_storage_sql.lua	Wed Apr 12 21:53:21 2017 +0200
@@ -484,12 +484,11 @@
 		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 @@
 				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;