diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-06 00:16:54 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-06 00:16:54 +0100 |
| commit | fa2e2ffea4b357e4d34cb3d3211fb26d1a024132 (patch) | |
| tree | 5f0789805235e2d9d85619f3c6a2dc010441c114 | |
| parent | a4510d055fed78482536878c30f83c12b35206e4 (diff) | |
| download | rabbitmq-server-git-fa2e2ffea4b357e4d34cb3d3211fb26d1a024132.tar.gz | |
refactored code
| -rw-r--r-- | src/rabbit_mnesia.erl | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index af0f53b309..99e058cb2a 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -234,25 +234,16 @@ ensure_mnesia_not_running() -> check_schema_integrity() -> try - % Check that all tables are present - case catch [mnesia:table_info(Tab, version) || Tab <- table_names()] of - {'EXIT', Reason} -> throw({missing_table, Reason}); - _ -> ok - end, - % Check that tables are defined correctly TabDefs = table_definitions(), - lists:foreach(fun(Tab) -> - {_, TabDef} = proplists:lookup(Tab, TabDefs), - {_, ExpAttrs} = proplists:lookup(attributes, TabDef), - Attrs = mnesia:table_info(Tab, attributes), - case lists:usort(ExpAttrs) /= lists:usort(Attrs) of - true -> - throw({table_not_defined_correctly, Tab}); - _ -> - ok - end - end, table_names()), - ok + case lists:all(fun(Tab) -> + {_, TabDef} = proplists:lookup(Tab, TabDefs), + {_, ExpAttrs} = proplists:lookup(attributes, TabDef), + Attrs = mnesia:table_info(Tab, attributes), + sets:is_subset(sets:from_list(ExpAttrs), sets:from_list(Attrs)) + end, table_names()) of + true -> ok; + false -> {error, database_tables_incompatible} + end catch throw:Why -> {error, Why} |
