anchor.diff:          {stop, Reason}
       end.
   
  +-spec build_tables_on_boot({atom() | pid()}, [tuple()]) -> ok.
   build_tables_on_boot(_, []) -> ok;
   build_tables_on_boot(Sess, [{N, Cols, Types, Default}|R]) ->
       ?Info("creating table ~p", [N]),
  
positive.code:         ,is_local_query/1
          ]).
  
  -record(state, { schema
                 , sess
      }).
  
  login(User, Password)                        -> gen_server:call(?MODULE, {login, User, Password}).
  change_password(User, Password, NewPassword) -> gen_server:call(?MODULE, {change_password, User, Password, NewPassword}).
  
  add_adapter(Id, FullName)           -> gen_server:cast(?MODULE, {add_adapter, Id, FullName}).
  add_connect(Sess, #ddConn{} = Conn) -> gen_server:cast(?MODULE, {add_connect, Sess, Conn}).
  
  add_command(Sess, Owner, Adapter, Name, Cmd, Conn, Opts) -> gen_server:call(?MODULE, {add_command, Sess, Owner, Adapter, Name, Cmd, Conn, Opts}).
  update_command(Sess, Id, Owner, Adapter, Name, Cmd, Conn, Opts) -> gen_server:call(?MODULE, {update_command, Sess, Id, Owner, Adapter, Name, Cmd, Conn, Opts}).
  add_view(Sess, Owner, Name, CmdId, ViewsState) -> gen_server:call(?MODULE, {add_view, Sess, Owner, Name, CmdId, ViewsState}).
  update_view(Sess, ViewId, ViewsState, Qry) when is_integer(ViewId) -> gen_server:call(?MODULE, {update_view, Sess, ViewId, ViewsState, Qry}).
  
  get_adapters(Sess)                     -> gen_server:call(?MODULE, {get_adapters, Sess}).
  get_connects(Sess, User)               -> gen_server:call(?MODULE, {get_connects, Sess, User}).
  del_conn(Sess, ConId)                  -> gen_server:call(?MODULE, {del_conn, Sess, ConId}).
  get_command(Sess, IdOrName)            -> gen_server:call(?MODULE, {get_command, Sess, IdOrName}).
  get_view(Sess, Name, Adapter, Owner)   -> gen_server:call(?MODULE, {get_view, Sess, Name, Adapter, Owner}).
  
  hexstr_to_bin(S)        -> hexstr_to_bin(S, []).
  hexstr_to_bin([], Acc)  -> list_to_binary(lists:reverse(Acc));
  hexstr_to_bin([X,Y|T], Acc) ->
      {ok, [V], []} = io_lib:fread("~16u", [X,Y]),
      hexstr_to_bin(T, [V | Acc]).
  
  start_link(SchemaName) ->
      ?Debug("starting...~n"),
      Result = gen_server:start_link({local, ?MODULE}, ?MODULE, [SchemaName], []),
  
negative.code:         ]),
          ?Info("tables ~p created", [[ddAdapter, ddInterface, ddConn, ddCmd, ddView, ddDash]]),
          Sess:run_cmd(insert, [ddInterface, #ddInterface{id = ddjson, fullName = <<"DDerl">>}]),
          % Initializing adapters (all the *_adapter modules compiled with dderl)
          %  doesn't include dynamically built adapters
          {ok, AdaptMods} = application:get_key(dderl, modules),
  