Permalink
Browse files

execute_batch: send Sync after series of Bind,Execute

  • Loading branch information...
1 parent 58381ef commit 5142cd76bbd416f92d068a46adf135f0c1a68283 @mabrek committed Feb 11, 2012
Showing with 16 additions and 15 deletions.
  1. +16 −15 src/pgsql_sock.erl
View
@@ -184,21 +184,22 @@ command({execute, _Statement, PortalName, MaxRows}, State) ->
command({execute_batch, Batch}, State) ->
#state{mod = Mod, sock = Sock} = State,
- do_send(
- Mod, Sock,
- lists:map(
- fun({Statement, PortalName, Parameters, MaxRows}) ->
- #statement{name = StatementName,
- columns = Columns,
- types = Types} = Statement,
- Typed_Parameters = lists:zip(Types, Parameters),
- Bin1 = pgsql_wire:encode_parameters(Typed_Parameters),
- Bin2 = pgsql_wire:encode_formats(Columns),
- [pgsql_wire:encode($B, [PortalName, 0, StatementName, 0,
- Bin1, Bin2]),
- pgsql_wire:encode($E, [PortalName, 0, <<MaxRows:?int32>>])]
- end,
- Batch)),
+ BindExecute =
+ lists:map(
+ fun({Statement, PortalName, Parameters, MaxRows}) ->
+ #statement{name = StatementName,
+ columns = Columns,
+ types = Types} = Statement,
+ Typed_Parameters = lists:zip(Types, Parameters),
+ Bin1 = pgsql_wire:encode_parameters(Typed_Parameters),
+ Bin2 = pgsql_wire:encode_formats(Columns),
+ [pgsql_wire:encode($B, [PortalName, 0, StatementName, 0,
+ Bin1, Bin2]),
+ pgsql_wire:encode($E, [PortalName, 0, <<MaxRows:?int32>>])]
+ end,
+ Batch),
+ Sync = pgsql_wire:encode($S, []),
+ do_send(Mod, Sock, [BindExecute, Sync]),
{noreply, State};
command({describe_statement, Name}, State) ->

0 comments on commit 5142cd7

Please sign in to comment.