Fix support for odbc + gen_storage + static_modules

This commit is contained in:
Badlop 2011-08-13 18:11:26 +02:00
parent afad6c75a0
commit e895b12aea
3 changed files with 18 additions and 4 deletions

View File

@ -111,9 +111,12 @@ migrate_mnesia1(HostB, Table, {OldTable, OldAttributes, MigrateFun}) ->
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) ->
@ -146,10 +149,9 @@ migrate_odbc1(Host, Tables, {OldTablesColumns, MigrateFun}) ->
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) ->

View File

@ -1083,4 +1083,7 @@ update_tables(HostB, mnesia) ->
opt = Opt,
val = Val})
end, Options)
end}]).
end}]);
update_tables(_HostB, odbc) ->
ok.

View File

@ -100,6 +100,7 @@ init([Host]) ->
[?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} ->
@ -109,10 +110,18 @@ get_pids(Host) ->
[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} ->