This commit is contained in:
niamtokik
2023-11-05 11:16:00 +00:00
parent 36d7cac156
commit 4098bc6af0
4 changed files with 86 additions and 2 deletions

View File

@@ -349,7 +349,8 @@ lookup(TypeAlias, Table, Key) ->
load_table(TypeAlias, Table, Reason, CsList) ->
?LOG_DEBUG("~p",[{?MODULE, self(), load_table, [TypeAlias, Table, Reason, CsList]}]),
throw({todo, ?MODULE, load_table, [TypeAlias, Table, Reason, CsList]}).
% throw({todo, ?MODULE, load_table, [TypeAlias, Table, Reason, CsList]}).
ok.
%%--------------------------------------------------------------------
%% @doc

View File

@@ -15,5 +15,8 @@ init([]) ->
, intensity => 0
, period => 1
},
ChildSpecs = [],
ChildSpecs = [#{ id => mnesia_debug_table
, start => {mnesia_debug_table, start_link, []}
}
],
{ok, {SupFlags, ChildSpecs}}.

View File

@@ -0,0 +1,24 @@
-module(mnesia_debug_table).
-behavior(gen_server).
-export([start_link/0]).
-export([init/1]).
-export([handle_info/2, handle_cast/2, handle_call/3]).
-include_lib("kernel/include/logger.hrl").
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], [debug]).
init(_) ->
{ok, []}.
handle_cast(Message, State) ->
?LOG_DEBUG("~p", [{?MODULE, self(), handle_cast, [Message, State]}]),
{noreply, State}.
handle_call(Message, From, State) ->
?LOG_DEBUG("~p", [{?MODULE, self(), handle_call, [Message, From, State]}]),
{noreply, State}.
handle_info(Message, State) ->
?LOG_DEBUG("~p", [{?MODULE, self(), handle_info, [Message, State]}]),
{noreply, State}.

View File

@@ -38,6 +38,8 @@ more when this one is coming directly from Datalog world.
## Mnesia Custom Backend Steps
### Table Creation Process
1. A schema can be created using `mnesia:create_schema/0`
```erlang
@@ -89,6 +91,60 @@ mnesia:create_table( my_table
8. Mnesia will call then `CustomModule:check_definition/4` function
callback and should check the properties of the table.
9. Then `Module:create_table/3` is called
10. `Module:semantics/2`
11. `Module:load_table/4`
### Read Operations
Those operations are not altering the database content.
#### `mnesia:read/2`
1. `Module:lookup/3`
#### `mnesia:first/1`
1. `Module:first/2`
#### `mnesia:last/1`
1. `Module:last/2`
#### `mnesia:prev/2`
1. `Module:prev/3`
#### `mnesia:next/2`
1. `Module:next/3`
#### `mnesia:all_keys/1`
1. `Module:fixtable/3`
#### `mnesia:select/2`
1. `Module:fixtable/3`
### Write Operations
Those operations are modifying database's content by creating,
updating or deleting one or more entries.
#### `mnesia:write/1`
1. `Module:validate_record/6`
#### `mnesia:delete/1`
1. `Module:delete/3`
#### `mnesia:delete_object/1`
1. `Module:load_table/3`
## Backend Definition and Interfaces