Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/ecto/adapters/myxql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,13 @@ defmodule Ecto.Adapters.MyXQL do
args: args
]

# Trap exits in case mysql dies in the middle of execution so that we can surface the error
old_trap_exit = Process.flag(:trap_exit, true)
port = Port.open({:spawn_executable, abs_cmd}, port_opts)
send(port, {self(), {:command, contents}})
send(port, {self(), {:command, ";SELECT '__ECTO_EOF__';\n"}})
collect_output(port, "")
Port.command(port, [contents, ";SELECT '__ECTO_EOF__';\n"])
result = collect_output(port, "")
Process.flag(:trap_exit, old_trap_exit)
result
end

defp args_env(opts, opt_args) do
Expand Down Expand Up @@ -651,6 +654,9 @@ defmodule Ecto.Adapters.MyXQL do
collect_output(port, acc)
end

{:EXIT, ^port, _reason} ->
{acc, 1}

{^port, {:exit_status, status}} ->
{acc, status}
end
Expand Down
Loading