end.
+migrate_odbc(HostStr, Tables, Migrations) when is_list(HostStr) ->
+ migrate_odbc(list_to_binary(HostStr), Tables, Migrations);
migrate_odbc(Host, Tables, Migrations) ->
+ HostStr = binary_to_list(Host),
try ejabberd_odbc:sql_transaction(
- Host,
+ HostStr,
fun() ->
lists:foreach(
fun(Migration) ->
ignored
end.
-migrate_odbc2(Host, Tables, OldTable, OldTables, OldColumns, OldColumnsAll, OldTablesA, ColumnsT, MigrateFun)
+migrate_odbc2(HostB, Tables, OldTable, OldTables, OldColumns, OldColumnsAll, OldTablesA, ColumnsT, MigrateFun)
when ColumnsT == OldColumnsAll ->
?INFO_MSG("Migrating ODBC table ~p to gen_storage tables ~p", [OldTable, Tables]),
- HostB = list_to_binary(Host),
%% rename old tables to *_old
lists:foreach(fun(OldTable1) ->
[?MODULE]}
end, lists:seq(1, PoolSize))}}.
+%% @spec (Host::string()) -> [pid()]
get_pids(Host) ->
case ejabberd_config:get_local_option({odbc_server, Host}) of
{host, Host1} ->
[R#sql_pool.pid || R <- Rs]
end.
+get_random_pid(HostB) when is_binary(HostB) ->
+ get_random_pid(binary_to_list(HostB));
+get_random_pid(global) ->
+ get_random_pid("localhost");
get_random_pid(Host) ->
Pids = get_pids(ejabberd:normalize_host(Host)),
lists:nth(erlang:phash(now(), length(Pids)), Pids).
+get_dbtype(HostB) when is_binary(HostB) ->
+ get_dbtype(binary_to_list(HostB));
+get_dbtype(global) ->
+ get_dbtype("localhost");
get_dbtype(Host) ->
case ejabberd_config:get_local_option({odbc_server, Host}) of
{host, Host1} ->