]> granicus.if.org Git - ejabberd/commitdiff
Fix support for odbc + gen_storage + static_modules
authorBadlop <badlop@process-one.net>
Sat, 13 Aug 2011 16:11:26 +0000 (18:11 +0200)
committerBadlop <badlop@process-one.net>
Tue, 16 Aug 2011 17:29:38 +0000 (19:29 +0200)
src/gen_storage_migration.erl
src/mod_muc/mod_muc.erl
src/odbc/ejabberd_odbc_sup.erl

index 54afe6ad197023b0038b3558ffaaf4b0d9534b27..7de85aa74d6fc6e88ee076c1aa8e21008b839ceb 100644 (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) ->
index 791e5e0d9a9b6b1318fe5540c7fb3aeeeffb9b03..d23374b576a99d341c0d4f944f441036a32b6612 100644 (file)
@@ -1083,4 +1083,7 @@ update_tables(HostB, mnesia) ->
                                                          opt = Opt,
                                                          val = Val})
                  end, Options)
-       end}]).
+       end}]);
+
+update_tables(_HostB, odbc) ->
+    ok.
index df0b57bf1df6e0a7aaec8ecdf9d8519a82046982..862b28cb78ef6a5f0c41c13a92b72f78dca053b8 100644 (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} ->