Description:
Invoking the external editor from the command line using command \e, will first execute the statement then open the editor and then try to re-execute the edited statement (asking for another delimiter (";")), if the statement ends with ";". Whilst it is syntactically correct, that ";" ends the statement and sending the line, will execute the statement, this behaviour is unexpected and might be harmful. If the command "\e" would be purely statement oriented, the editor should be empty, if "\e" is preceded by ";". Yet the statement is executed and transferred to the editor, but without the delimiter.
If more than one statement is supplied within the same line, only the last statement will be transferred to the editor.
Furthermore, the edited statement is not added to the statement history, available with the up key on the command line. Only the statement delimiter added after terminating the editor will be shown. Thus the edited statement is lost for re-use.
How to repeat:
open mysql command line client
select database
type statement, e.g. select * from sometable;\e
quit the editor
confirm the statement (you don't see) with delimiter or abort with \c
type line with two statements, e.g. select * from sometable; select count(*) from sometable;\e
confirm the statement (you don't see) with delimiter or abort with \c
Suggested fix:
Do not execute the statement preceded by \e prior to opening the editor, even if the statement is delimited. Alternatively transfer the full input line to the editor without execution or only transfer the last un-delimited statement to the editor.