anchor.diff:  code_change(_OldVsn, State, _Extra) ->
       {ok, State}.
   
  -handle_call({setup,Args}, _From, #state{}=S) ->
  -    case setup(Args, S) of
  -        {ok, State} ->
  -            {reply, ok, State};
  -        {error, Reason, State} ->
  -            {reply, {error,Reason}, State}
  -    end;
  -handle_call({Func,Args}, _From, #state{handle=H}=S)
  +handle_call({Func,Args}, _From, State)
     when is_atom(Func), is_list(Args)->
  +    ready(Func, Args, State).
  +
  +handle_cast(_Request, State) ->
  +    {stop, enotsup, State}.
  +
  +handle_info(timeout, State) ->
  +    initialized(State);
  +handle_info({tcp_closed,Socket}, #state{handle=H}=S)
  +  when Socket =:= ?SOCKET(H) ->
  +    {stop, tcp_closed, S};
  +handle_info({'EXIT',_Pid,Reason}, State) ->
  +    {stop, Reason, State}.
  +
  +%% == private ==
  +
  +cleanup(#state{handle=H}=S)
  +  when undefined =/= H ->
  +    _ = myer_protocol:close(H),
  +    cleanup(S#state{handle = undefined});
  +cleanup(#state{}) ->
  +    baseline:flush().
  +
  +setup(Args) ->
  +    process_flag(trap_exit, true),
  +    loaded(Args, #state{}).
  +
  +
  +loaded(Args, #state{}=S) ->
  +    {ok, S#state{args = Args}, 0}.
  +
  +
  +initialized(#state{args=A,handle=undefined}=S) ->
  +    L = [
  +         proplists:get_value(address, A, "localhost"),
  +         proplists:get_value(port, A, 3306),
  +         proplists:get_value(default_character_set, A, ?CHARSET_utf8_general_ci),
  +         proplists:get_value(compress, A, false),
  +         proplists:get_value(max_allowed_packet, A, 4194304),
  +         timer:seconds(proplists:get_value(timeout, A, 10))
  +        ],
  +    case apply(myer_protocol, connect, [L]) of
  +        {ok, Handle} ->
  +            connected(S#state{handle = Handle});
  +        {error, Reason} ->
  +            {error, Reason, S};
  +        {error, Reason, Handle} ->
  +            {error, Reason, S#state{handle = Handle}}
  +    end.
  +
  +connected(#state{args=A,handle=H}=S) ->
  +    L = [
  +         proplists:get_value(user, A, <<"root">>),
  +         proplists:get_value(password, A, <<"">>),
  +         proplists:get_value(database, A, <<"">>)
  +        ],
  +    case apply(myer_protocol, auth, [H|L]) of
  +        {ok, _Result, Handle} ->
  +            authorized(S#state{handle = Handle});
  +        {error, Reason, Handle} ->
  +            {error, Reason, S#state{handle = Handle}}
  +    end.
  +
  +authorized(#state{}=S) ->
  +    {noreply, S}.
  +
  +
  +ready(Func, Args, #state{handle=H}=S) ->
       case apply(myer_protocol, Func, [H|Args]) of
           {ok, Handle} ->
               {reply, ok, S#state{handle = Handle}};
  
positive.code: -include("internal.hrl").
  
  %% -- public --
  -export([start_link/1, start_link/2, stop/1]).
  -export([call/2, cast/2]).
  
  %% -- behaviour: gen_server --
  -behaviour(gen_server).
  
negative.code:            true -> throw({badarg,K})
          end,
      [T|List];
  validate({default_character_set=K,Value}, List) -> % non_neg_integer()
      T = if is_integer(Value), 0 =< Value     -> {K, Value};
             true -> throw({badarg,K})
          end,
      [T|List];
  