Browse files

Spreading changes into parametric queries too.

  • Loading branch information...
1 parent 923e833 commit 67027a37da7a38e12eb12e370feb1adf572e89dd noss committed Sep 13, 2007
Showing with 7 additions and 10 deletions.
  1. +3 −8 lib/pgsql/src/pgsql_proto.erl
  2. +4 −2 lib/pgsql/src/pgsql_util.erl
View
11 lib/pgsql/src/pgsql_proto.erl
@@ -231,20 +231,15 @@ idle(Sock, Pid) ->
%% simplistic version using the unnammed prepared statement and portal.
{equery, Ref, Pid, {Query, Params}} ->
ParseP = encode_message(parse, {"", Query, []}),
- BindP = encode_message(bind, {"", "", Params, [binary]}),
+ BindP = encode_message(bind, {"", "", Params, [text]}),
DescribeP = encode_message(describe, {portal, ""}),
ExecuteP = encode_message(execute, {"", 0}),
SyncP = encode_message(sync, []),
ok = send(Sock, [ParseP, BindP, DescribeP, ExecuteP, SyncP]),
{ok, Command, Desc, Status, Logs} = process_equery([]),
- OidMap = get(oidmap),
- NameTypes = lists:map(fun({Name, _Format, _ColNo, Oid, _, _, _}) ->
- {Name, dict:fetch(Oid, OidMap)}
- end,
- Desc),
- Pid ! {pgsql, Ref, {Command, Status, NameTypes, Logs}},
+ Pid ! {pgsql, Ref, {Command, Status, Desc, Logs}},
idle(Sock, Pid);
%% Prepare a statement, so it can be used for queries later on.
{prepare, Ref, Pid, {Name, Query}} ->
@@ -272,7 +267,7 @@ idle(Sock, Pid) ->
{execute, Ref, Pid, {Name, Params}} ->
%%io:format("execute: ~p ~p ~n", [Name, Params]),
begin % Issue first requests for the prepared statement.
- BindP = encode_message(bind, {"", Name, Params, [binary]}),
+ BindP = encode_message(bind, {"", Name, Params, [text]}),
DescribeP = encode_message(describe, {portal, ""}),
ExecuteP = encode_message(execute, {"", 0}),
FlushP = encode_message(flush, []),
View
6 lib/pgsql/src/pgsql_util.erl
@@ -265,14 +265,16 @@ decode_col(#desc{format=text, type=date}, Value) ->
<<Year:4/binary, $-, Month:2/binary, $-, Day:2/binary>> = Value,
{b2i(Year), b2i(Month), b2i(Day)};
decode_col(#desc{format=text, type=time}, Value) ->
- <<Hour:2/binary, $:, Minute:2/binary, $:, Second:2/binary>> = Value,
+ <<Hour:2/binary, $:, Minute:2/binary, $:, Second:2/binary,_/binary>> = Value,
{b2i(Hour), b2i(Minute), b2i(Second)};
decode_col(#desc{format=text, type=timestamp}, Value) ->
<<Year:4/binary, _, Month:2/binary, _, Day:2/binary, $\s,
- Hour:2/binary, $:, Minute:2/binary, $:, Second:2/binary>> = Value,
+ Hour:2/binary, $:, Minute:2/binary, $:, Second:2/binary,_/binary>> = Value,
{{b2i(Year), b2i(Month), b2i(Day)}, {b2i(Hour), b2i(Minute), b2i(Second)}};
decode_col(#desc{format=text}, Value) ->
Value;
+decode_col(#desc{format=binary}, Value) ->
+ Value;
decode_col(_, Value) ->
throw({unknown_format, Value}).

0 comments on commit 67027a3

Please sign in to comment.