必要なテーブルが既に作成されていることを確認する関数を作成しようとしています。サンプルは次のとおりです。
ensure_table_exists(Table, MnesiaTables, Nodes) ->
case lists:member(Table, MnesiaTables) of
true ->
throw({error, db_might_have_already_been_created});
false ->
mnesia:create_table(Table, [{disc_copies, Nodes},
{attributes, record_info(fields, Table)}]),
ok
end.
問題は、コンパイル時にエラーが発生することです: illegal record info
. コンパイル時に record_info が解決されるか、record info の 2 番目の引数が実際にはソース コードから取得できるレコードでなければならないのでしょうか?