# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1382992495 -3600
# Node ID 12d12bda4b8c19cccffa79eb2c49f67544ed5207
# Parent  3321a4b3e6c4a19c59a1e17dc46124a00aa70525
mod_storage_sql2: Split up setting of encoding and table upgrade code

diff -r 3321a4b3e6c4 -r 12d12bda4b8c plugins/mod_storage_sql2.lua
--- a/plugins/mod_storage_sql2.lua	Tue Oct 15 10:47:34 2013 +0200
+++ b/plugins/mod_storage_sql2.lua	Mon Oct 28 21:34:55 2013 +0100
@@ -108,8 +108,9 @@
 	local success,err = engine:transaction(function() return engine:execute(set_names_query); end);
 	if not success then
 		module:log("error", "Failed to set database connection encoding to UTF8: %s", err);
-		return;
 	end
+end
+local function upgrade_table()
 	if params.driver == "MySQL" then
 		-- COMPAT w/pre-0.9: Upgrade tables to UTF-8 if not already
 		local check_encoding_query = "SELECT `COLUMN_NAME`,`COLUMN_TYPE` FROM `information_schema`.`columns` WHERE `TABLE_NAME`='prosody' AND ( `CHARACTER_SET_NAME`!='utf8' OR `COLLATION_NAME`!='utf8_bin' );";
@@ -149,6 +150,7 @@
 
 	-- Encoding mess
 	set_encoding();
+	upgrade_table();
 
 	-- Automatically create table, ignore failure (table probably already exists)
 	create_table();