anchor.diff:  -include_lib("eunit/include/eunit.hrl").
   
   -define(MAX_RETRIES, 5).
  +
  +-define(MYSQL_ERROR_CODES, [{1062, conflict}, {1451, foreign_key}, {1452, foreign_key}]).
  +-define(PGSQL_ERROR_CODES, [{<<"23505">>, conflict}, {<<"23503">>, foreign_key}]).
   
   checkout() ->
       pooler:take_member("sqerl").
  
positive.code: -spec parse_error(mysql | pgsql,{term(), term()}
                          | {error, {error, error, _, _, _}}) ->
                            {'conflict',_} | {'foreign_key',_} | {'error',_}.
  parse_error(mysql, Reason) ->
      {Code, Message} = Reason,
      case Code of
          1062 ->
              {conflict, Message};
          1451 ->
              {foreign_key, Message};
          1452 ->
              {foreign_key, Message};
          _ ->
              {error, Message}
      end;
  
  
negative.code:                      error,                     % Severity
                       Code, Message, _Extra}}) ->
      %% See http://www.postgresql.org/docs/current/static/errcodes-appendix.html
      case lists:keyfind(Code, 1, ?PGSQL_ERROR_CODES) of
          {_, ErrorType} ->
              {ErrorType, Message};
          false ->
              {error, Message}
      end.
  
  