Changeset

8082:8ca11201bfe7

mod_storage_sql: Limit encoding check to current database
author Kim Alvefur <zash@zash.se>
date Thu, 13 Apr 2017 01:29:35 +0200
parents 8081:a201f315de55
children 8083:32898a74b9d9 8084:655837e9eeeb
files plugins/mod_storage_sql.lua
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Wed Apr 12 23:16:23 2017 +0200
+++ b/plugins/mod_storage_sql.lua	Thu Apr 13 01:29:35 2017 +0200
@@ -485,11 +485,12 @@
 		SELECT "COLUMN_NAME","COLUMN_TYPE","TABLE_NAME"
 		FROM "information_schema"."columns"
 		WHERE "TABLE_NAME" LIKE 'prosody%%'
+		AND "TABLE_SCHEMA" = ?
 		AND ( "CHARACTER_SET_NAME"!=? OR "COLLATION_NAME"!=?);
 		]];
 		-- FIXME Is it ok to ignore the return values from this?
 		engine:transaction(function()
-			local result = assert(engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin"));
+			local result = assert(engine:execute(check_encoding_query, params.database, engine.charset, engine.charset.."_bin"));
 			local n_bad_columns = result:rowcount();
 			if n_bad_columns > 0 then
 				changes = true;
@@ -508,7 +509,8 @@
 			end
 		end);
 		success,err = engine:transaction(function()
-			return engine:execute(check_encoding_query, engine.charset, engine.charset.."_bin");
+			return engine:execute(check_encoding_query, params.database,
+				engine.charset, engine.charset.."_bin");
 		end);
 		if not success then
 			module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error");