Permalink
Browse files

remove epgsql and add to rebar dependency

  • Loading branch information...
1 parent 5e3f173 commit 3eb97a94797e0dc6507d30d428175ffc4c616163 Bip Thelin committed Jan 12, 2012
View
@@ -1,8 +0,0 @@
-{application, epgsql,
- [{description, "PostgreSQL Client"},
- {vsn, "1.2"},
- {modules, [pgsql, pgsql_binary, pgsql_connection, pgsql_fdatetime,
- pgsql_idatetime, pgsql_sock, pgsql_types]},
- {registered, []},
- {applications, [kernel, stdlib, crypto, ssl]},
- {included_applications, []}]}.
View
@@ -4,5 +4,6 @@
{riakc, "1.1.*", {git, "git://github.com/basho/riak-erlang-client", {tag, "aa5c64a6a04192662d9c"}}},
{riakpool, "0.1", {git, "git://github.com/dweldon/riakpool", {tag, "HEAD"}}},
{mochiweb, ".*", {git, "git://github.com/mochi/mochiweb.git", "master"}},
- {misultin, ".*", {git, "git://github.com/ostinelli/misultin.git", "master"}}
+ {misultin, ".*", {git, "git://github.com/ostinelli/misultin.git", "master"}},
+ {epgsql, ".*", {git, "git://github.com/wg/epgsql.git", "master"}}
]}.
View
@@ -1,176 +0,0 @@
-%%% Copyright (C) 2008 - Will Glozer. All rights reserved.
-
--module(pgsql).
-
--export([connect/2, connect/3, connect/4, close/1]).
--export([get_parameter/2, squery/2, equery/2, equery/3]).
--export([parse/2, parse/3, parse/4, describe/2, describe/3]).
--export([bind/3, bind/4, execute/2, execute/3, execute/4]).
--export([close/2, close/3, sync/1]).
--export([with_transaction/2]).
-
--include("pgsql.hrl").
-
-%% -- client interface --
-
-connect(Host, Opts) ->
- connect(Host, os:getenv("USER"), "", Opts).
-
-connect(Host, Username, Opts) ->
- connect(Host, Username, "", Opts).
-
-connect(Host, Username, Password, Opts) ->
- {ok, C} = pgsql_connection:start_link(),
- pgsql_connection:connect(C, Host, Username, Password, Opts).
-
-close(C) when is_pid(C) ->
- catch pgsql_connection:stop(C),
- ok.
-
-get_parameter(C, Name) ->
- pgsql_connection:get_parameter(C, Name).
-
-squery(C, Sql) ->
- ok = pgsql_connection:squery(C, Sql),
- case receive_results(C, []) of
- [Result] -> Result;
- Results -> Results
- end.
-
-equery(C, Sql) ->
- equery(C, Sql, []).
-
-equery(C, Sql, Parameters) ->
- case pgsql_connection:parse(C, "", Sql, []) of
- {ok, #statement{types = Types} = S} ->
- Typed_Parameters = lists:zip(Types, Parameters),
- ok = pgsql_connection:equery(C, S, Typed_Parameters),
- receive_result(C, undefined);
- Error ->
- Error
- end.
-
-%% parse
-
-parse(C, Sql) ->
- parse(C, "", Sql, []).
-
-parse(C, Sql, Types) ->
- parse(C, "", Sql, Types).
-
-parse(C, Name, Sql, Types) ->
- pgsql_connection:parse(C, Name, Sql, Types).
-
-%% bind
-
-bind(C, Statement, Parameters) ->
- bind(C, Statement, "", Parameters).
-
-bind(C, Statement, PortalName, Parameters) ->
- pgsql_connection:bind(C, Statement, PortalName, Parameters).
-
-%% execute
-
-execute(C, S) ->
- execute(C, S, "", 0).
-
-execute(C, S, N) ->
- execute(C, S, "", N).
-
-execute(C, S, PortalName, N) ->
- pgsql_connection:execute(C, S, PortalName, N),
- receive_extended_result(C).
-
-%% statement/portal functions
-
-describe(C, #statement{name = Name}) ->
- pgsql_connection:describe(C, statement, Name).
-
-describe(C, Type, Name) ->
- pgsql_connection:describe(C, Type, Name).
-
-close(C, #statement{name = Name}) ->
- pgsql_connection:close(C, statement, Name).
-
-close(C, Type, Name) ->
- pgsql_connection:close(C, Type, Name).
-
-sync(C) ->
- pgsql_connection:sync(C).
-
-%% misc helper functions
-with_transaction(C, F) ->
- try {ok, [], []} = squery(C, "BEGIN"),
- R = F(C),
- {ok, [], []} = squery(C, "COMMIT"),
- R
- catch
- _:Why ->
- squery(C, "ROLLBACK"),
- {rollback, Why}
- end.
-
-%% -- internal functions --
-
-receive_result(C, Result) ->
- try receive_result(C, [], []) of
- done -> Result;
- R -> receive_result(C, R)
- catch
- throw:E -> E
- end.
-
-receive_results(C, Results) ->
- try receive_result(C, [], []) of
- done -> lists:reverse(Results);
- R -> receive_results(C, [R | Results])
- catch
- throw:E -> E
- end.
-
-receive_result(C, Cols, Rows) ->
- receive
- {pgsql, C, {columns, Cols2}} ->
- receive_result(C, Cols2, Rows);
- {pgsql, C, {data, Row}} ->
- receive_result(C, Cols, [Row | Rows]);
- {pgsql, C, {error, _E} = Error} ->
- Error;
- {pgsql, C, {complete, {_Type, Count}}} ->
- case Rows of
- [] -> {ok, Count};
- _L -> {ok, Count, Cols, lists:reverse(Rows)}
- end;
- {pgsql, C, {complete, _Type}} ->
- {ok, Cols, lists:reverse(Rows)};
- {pgsql, C, done} ->
- done;
- {pgsql, C, timeout} ->
- throw({error, timeout});
- {'EXIT', C, _Reason} ->
- throw({error, closed})
- end.
-
-receive_extended_result(C)->
- receive_extended_result(C, []).
-
-receive_extended_result(C, Rows) ->
- receive
- {pgsql, C, {data, Row}} ->
- receive_extended_result(C, [Row | Rows]);
- {pgsql, C, {error, _E} = Error} ->
- Error;
- {pgsql, C, suspended} ->
- {partial, lists:reverse(Rows)};
- {pgsql, C, {complete, {_Type, Count}}} ->
- case Rows of
- [] -> {ok, Count};
- _L -> {ok, Count, lists:reverse(Rows)}
- end;
- {pgsql, C, {complete, _Type}} ->
- {ok, lists:reverse(Rows)};
- {pgsql, C, timeout} ->
- {error, timeout};
- {'EXIT', C, _Reason} ->
- {error, closed}
- end.
@@ -1,68 +0,0 @@
-%%% Copyright (C) 2008 - Will Glozer. All rights reserved.
-
--module(pgsql_binary).
-
--export([encode/2, decode/2, supports/1]).
-
--define(int32, 1/big-signed-unit:32).
--define(datetime, (get(datetime_mod))).
-
-encode(_Any, null) -> <<-1:?int32>>;
-encode(bool, true) -> <<1:?int32, 1:1/big-signed-unit:8>>;
-encode(bool, false) -> <<1:?int32, 0:1/big-signed-unit:8>>;
-encode(int2, N) -> <<2:?int32, N:1/big-signed-unit:16>>;
-encode(int4, N) -> <<4:?int32, N:1/big-signed-unit:32>>;
-encode(int8, N) -> <<8:?int32, N:1/big-signed-unit:64>>;
-encode(float4, N) -> <<4:?int32, N:1/big-float-unit:32>>;
-encode(float8, N) -> <<8:?int32, N:1/big-float-unit:64>>;
-encode(bpchar, C) when is_integer(C) -> <<1:?int32, C:1/big-unsigned-unit:8>>;
-encode(bpchar, B) when is_binary(B) -> <<(byte_size(B)):?int32, B/binary>>;
-encode(Type, B) when Type == time; Type == timetz -> ?datetime:encode(Type, B);
-encode(Type, B) when Type == date; Type == timestamp -> ?datetime:encode(Type, B);
-encode(Type, B) when Type == timestamptz; Type == interval -> ?datetime:encode(Type, B);
-encode(bytea, B) when is_binary(B) -> <<(byte_size(B)):?int32, B/binary>>;
-encode(text, B) when is_binary(B) -> <<(byte_size(B)):?int32, B/binary>>;
-encode(varchar, B) when is_binary(B) -> <<(byte_size(B)):?int32, B/binary>>;
-encode(Type, L) when is_list(L) -> encode(Type, list_to_binary(L));
-encode(_Type, _Value) -> {error, unsupported}.
-
-decode(bool, <<1:1/big-signed-unit:8>>) -> true;
-decode(bool, <<0:1/big-signed-unit:8>>) -> false;
-decode(bpchar, <<C:1/big-unsigned-unit:8>>) -> C;
-decode(int2, <<N:1/big-signed-unit:16>>) -> N;
-decode(int4, <<N:1/big-signed-unit:32>>) -> N;
-decode(int8, <<N:1/big-signed-unit:64>>) -> N;
-decode(float4, <<N:1/big-float-unit:32>>) -> N;
-decode(float8, <<N:1/big-float-unit:64>>) -> N;
-decode(record, <<_:?int32, Rest/binary>>) -> list_to_tuple(decode_record(Rest, []));
-decode(Type, B) when Type == time; Type == timetz -> ?datetime:decode(Type, B);
-decode(Type, B) when Type == date; Type == timestamp -> ?datetime:decode(Type, B);
-decode(Type, B) when Type == timestamptz; Type == interval -> ?datetime:decode(Type, B);
-decode(_Other, Bin) -> Bin.
-
-decode_record(<<>>, Acc) ->
- lists:reverse(Acc);
-decode_record(<<_Type:?int32, -1:?int32, Rest/binary>>, Acc) ->
- decode_record(Rest, [null | Acc]);
-decode_record(<<Type:?int32, Len:?int32, Value:Len/binary, Rest/binary>>, Acc) ->
- Value2 = decode(pgsql_types:oid2type(Type), Value),
- decode_record(Rest, [Value2 | Acc]).
-
-supports(bool) -> true;
-supports(bpchar) -> true;
-supports(int2) -> true;
-supports(int4) -> true;
-supports(int8) -> true;
-supports(float4) -> true;
-supports(float8) -> true;
-supports(bytea) -> true;
-supports(text) -> true;
-supports(varchar) -> true;
-supports(record) -> true;
-supports(date) -> true;
-supports(time) -> true;
-supports(timetz) -> true;
-supports(timestamp) -> true;
-supports(timestamptz) -> true;
-supports(interval) -> true;
-supports(_Type) -> false.
Oops, something went wrong.

0 comments on commit 3eb97a9

Please sign in to comment.