25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-31 15:21:38 +01:00

Dialyzer fixes. Ensure all_table_hosts/1 returns only a list of binaries

This commit is contained in:
Badlop 2010-09-28 16:05:33 +02:00
parent 403690a498
commit 56b66ab64f
2 changed files with 16 additions and 8 deletions

View File

@ -58,14 +58,21 @@ behaviour_info(_) ->
-include("ejabberd.hrl"). % This is used for ERROR_MSG -include("ejabberd.hrl"). % This is used for ERROR_MSG
%% Returns all hosts where the table Tab is defined %% Returns all hosts where the table Tab is defined
-spec all_table_hosts(atom()) -> -spec all_table_hosts(storage_table()) ->
[storage_host()]. [storage_host()].
all_table_hosts(Tab) -> all_table_hosts(Tab) ->
mnesia:dirty_select(table, [{{table, {'$1', '$2'}, '_', '_'}, TT = setelement(2, {table, {<<"hidding_from_dialyzer">>, '$2'}, '_', '_'}, {'$1', '$2'}),
Res = (catch mnesia:dirty_select(table, [{TT,
[{'=:=', '$2', {const, Tab}}], [{'=:=', '$2', {const, Tab}}],
['$1']}]). ['$1']}])),
case Res of
Res when is_list(Res) ->
[HostB || HostB <- Res, is_binary(HostB)];
_ ->
[]
end.
-spec table_info(storage_host, storage_table, atom()) -> -spec table_info(storage_host(), storage_table(), atom()) ->
any(). any().
table_info(Host, Tab, InfoKey) -> table_info(Host, Tab, InfoKey) ->
Info = Info =
@ -108,7 +115,7 @@ table_info(Host, Tab, InfoKey) ->
%% option() is any mnesia option %% option() is any mnesia option
%% columndef() defaults to text for all unspecified attributes %% columndef() defaults to text for all unspecified attributes
-spec create_table(atom(), storage_host(), storage_table(), #table{}) -> -spec create_table(atom(), storage_host(), storage_table(), list()) ->
tuple(). tuple().
create_table(mnesia, Host, Tab, Def) -> create_table(mnesia, Host, Tab, Def) ->
@ -130,9 +137,9 @@ define_table(Backend, Host, Name, Def) ->
backend = Backend, backend = Backend,
def = Def}). def = Def}).
%% @spec (#table{}) -> [{atom(), any()}] %% @spec (list()) -> [{atom(), any()}]
-spec filter_mnesia_tabdef(#table{}) -> -spec filter_mnesia_tabdef(list()) ->
[any()]. [any()].
filter_mnesia_tabdef(TabDef) -> filter_mnesia_tabdef(TabDef) ->
@ -202,6 +209,7 @@ dirty_read(Host, Tab, Key) ->
| {'or', matchrule(), matchrule()} | {'or', matchrule(), matchrule()}
| {'orelse', matchrule(), matchrule()} | {'orelse', matchrule(), matchrule()}
| {'=', Attribute::atom(), matchvalue()} | {'=', Attribute::atom(), matchvalue()}
| {'<', Attribute::atom(), matchvalue()}
| {'=/=', Attribute::atom(), matchvalue()} | {'=/=', Attribute::atom(), matchvalue()}
| {like, Attribute::atom(), matchvalue()}). | {like, Attribute::atom(), matchvalue()}).

View File

@ -22,7 +22,7 @@
attributes :: [string()], % Columns attributes :: [string()], % Columns
columns :: string(), % "\"col1\", \"col2\" ,..." columns :: string(), % "\"col1\", \"col2\" ,..."
column_names :: [{string(), [string()]}], % [{string(), [string()]}] (already quoted) column_names :: [{string(), [string()]}], % [{string(), [string()]}] (already quoted)
types :: [{string(), atom()}], types :: [{string(), atom() | tuple()}],
host :: string() host :: string()
}). }).
-record(odbc_cont, {tabdef, sql, offset = 0, limit}). -record(odbc_cont, {tabdef, sql, offset = 0, limit}).