Browse Source

Fix issue with columns in multiple squery response

Yakov Kozlov 2 years ago
parent
commit
a217b00080
2 changed files with 8 additions and 2 deletions
  1. 1 1
      src/commands/epgsql_cmd_squery.erl
  2. 7 1
      test/epgsql_SUITE.erl

+ 1 - 1
src/commands/epgsql_cmd_squery.erl

@@ -63,7 +63,7 @@ handle_message(?COMMAND_COMPLETE, Bin, Sock, #squery{columns = Cols} = St) ->
                  _ ->
                      {ok, Cols, Rows}
              end,
-    {add_result, Result, {complete, Complete}, Sock, St};
+    {add_result, Result, {complete, Complete}, Sock, St#squery{columns = []}};
 handle_message(?EMPTY_QUERY, _, Sock, St) ->
     {add_result, {ok, [], []}, {complete, empty}, Sock, St};
 handle_message(?READY_FOR_QUERY, _Status, Sock, _State) ->

+ 7 - 1
test/epgsql_SUITE.erl

@@ -530,8 +530,14 @@ cursor(Config) ->
 multiple_result(Config) ->
     Module = ?config(module, Config),
     epgsql_ct:with_connection(Config, fun(C) ->
+        Module:squery(C, "delete test_table1 where id = 3;"),
         [{ok, _, [{<<"1">>}]}, {ok, _, [{<<"2">>}]}] = Module:squery(C, "select 1; select 2"),
-        [{ok, _, [{<<"1">>}]}, {error, #error{}}] = Module:squery(C, "select 1; select foo;")
+        [{ok, _, [{<<"1">>}]}, {error, #error{}}] = Module:squery(C, "select 1; select foo;"),
+        [{ok, _, [{<<"one">>}]}, {ok, 1}, {ok, 1}] =
+             Module:squery(C,
+                 "select value from test_table1 where id = 1; "
+                 "insert into test_table1 (id, value) values (3, 'three');"
+                 "delete from test_table1 where id = 3;")
     end).
 
 execute_batch(Config) ->