Comparison

plugins/mod_storage_sql.lua @ 10793:9ce67da45e54

mod_storage_sql: Log database connection parameters when creating engine This is meant to help trace down an issue where Prosody apparently creates multiple conflicting SQL engines, causing problems especially with SQLite3, e.g. #616 #784.
author Kim Alvefur <zash@zash.se>
date Sat, 02 May 2020 14:13:02 +0200
parent 10701:929c95e518f0
child 10925:73e95ecec733
comparison
equal deleted inserted replaced
10792:ef2bd183f660 10793:9ce67da45e54
757 757
758 function module.load() 758 function module.load()
759 if prosody.prosodyctl then return; end 759 if prosody.prosodyctl then return; end
760 local engines = module:shared("/*/sql/connections"); 760 local engines = module:shared("/*/sql/connections");
761 local params = normalize_params(module:get_option("sql", default_params)); 761 local params = normalize_params(module:get_option("sql", default_params));
762 engine = engines[sql.db2uri(params)]; 762 local db_uri = sql.db2uri(params);
763 engine = engines[db_uri];
763 if not engine then 764 if not engine then
764 module:log("debug", "Creating new engine"); 765 module:log("debug", "Creating new engine %s", db_uri);
765 engine = sql:create_engine(params, function (engine) -- luacheck: ignore 431/engine 766 engine = sql:create_engine(params, function (engine) -- luacheck: ignore 431/engine
766 if module:get_option("sql_manage_tables", true) then 767 if module:get_option("sql_manage_tables", true) then
767 -- Automatically create table, ignore failure (table probably already exists) 768 -- Automatically create table, ignore failure (table probably already exists)
768 -- FIXME: we should check in information_schema, etc. 769 -- FIXME: we should check in information_schema, etc.
769 create_table(engine); 770 create_table(engine);