Bug #1989 Control-C aborts client
Submitted: 1 Dec 2003 11:51 Modified: 4 May 2006 16:32
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version: OS:Linux (Linux)
Assigned to: Jim Winstead CPU Architecture:Any

[1 Dec 2003 11:51] [ name withheld ]
Description:
Pressing Ctrl-C in the Linux command line client aborts it.  I find this very annoying.  Ctrl-C should imho only cancel the half-typed sql command and return to a new prompt.  At this point, Ctrl-D might stop the client.  Like in any decent Shell.

How to repeat:
Like I said.
[1 Dec 2003 13:36] Dean Ellis
I am changing this to a feature request.

Thank you for your suggestion.
[1 Sep 2004 18:00] Shawn Green
I would like the option of using ctrl-c to abort a long query from the client without causing the client to exit.  I don't know how many times I started something, realized my mistake and wanted a "stop query" feature. I have begun running two sessions at once: one for my live queries and one I can use to KILL any long-running queries I started in the first session. 

Also, If I request to stop a query from the same client that initiated it, I also should not need to reconnect to the server (I shouldn't lose my connection, only abort the statement). It would be nice that while acting as an administrator I could cancel a statement from another process without breaking that processes connection. They would just get an error back like "Statement aborted by administrator" or "Statement aborted by user@hostname" but keep their connection.
[28 Nov 2005 7:47] Valeriy Kravchuk
Thank you for several feature requests in one. I agree, that Ctrl-C will be a good way to stop/break current statement execution. But for it to be possible  I also agree, that there should be some way for the user with appropriate privileges (administrator) to stop (kill) other users threads in client. We already have mysql_kill() in C API (http://dev.mysql.com/doc/refman/5.0/en/mysql-kill.html).
[28 Nov 2005 10:15] Valeriy Kravchuk
Oh, sorry, there is a KILL command already. http://dev.mysql.com/doc/refman/5.0/en/kill.html. So, what is needed is just perform KILL QUERY for current thread when Ctrl+C is pressed.
[3 May 2006 19:04] Jim Winstead
Fixed in 5.1.10. When Ctrl-C is used, the client will first try to kill the query. If it cannot do so, or Ctrl-C is pressed again before it is done, the client will exit as before.
[4 May 2006 16:32] Paul DuBois
Noted in 5.1.10 changelog.
[12 Jan 2008 4:11] Karim Nassar
This bug should not be closed.

The original bug was that ctrl-c exits the mysql shell. I would like to extend the feature request to make this a configurable option. Many shell gurus hit ctrl-c by force of habit. They (I being one of them) would LOVE to have an option to make the mysql shell NOT exit when force of habit takes control. For an example of the desired behavior, open a bash shell, type 'rm -rf foo' hit ctrl-c.
[2 Apr 2012 13:14] fabien markart
As Karim said, this bug should not have been close.
Ctrl-C in mysql CLI kills the client this is really annoying...
[4 Apr 2012 0:58] lalal llalalla
This would be excellent! I would love it if it were like this. I'd contribute a patch if it weren't too complicated, but i wouldn't know where to start and have some things to finish.

Thanks for everything guys!