File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -588,10 +588,13 @@ defmodule Ecto.Adapters.MyXQL do
588588 args: args
589589 ]
590590
591+ # Trap exits in case mysql dies in the middle of execution so that we can surface the error
592+ old_trap_exit = Process . flag ( :trap_exit , true )
591593 port = Port . open ( { :spawn_executable , abs_cmd } , port_opts )
592- send ( port , { self ( ) , { :command , contents } } )
593- send ( port , { self ( ) , { :command , ";SELECT '__ECTO_EOF__';\n " } } )
594- collect_output ( port , "" )
594+ Port . command ( port , [ contents , ";SELECT '__ECTO_EOF__';\n " ] )
595+ result = collect_output ( port , "" )
596+ Process . flag ( :trap_exit , old_trap_exit )
597+ result
595598 end
596599
597600 defp args_env ( opts , opt_args ) do
@@ -651,6 +654,9 @@ defmodule Ecto.Adapters.MyXQL do
651654 collect_output ( port , acc )
652655 end
653656
657+ { :EXIT , ^ port , _reason } ->
658+ { acc , 1 }
659+
654660 { ^ port , { :exit_status , status } } ->
655661 { acc , status }
656662 end
You can’t perform that action at this time.
0 commit comments