Bug #64444 Pressing Ctrl-C during Search History (Ctrl-R) should cancel search, not exit
Submitted: 24 Feb 2012 14:20 Modified: 28 Jun 2013 23:42
Reporter: Thomas Baker Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.1.41, 5.5.20 OS:Any
Assigned to: Matthew Lord CPU Architecture:Any
Tags: CTRL-C, ctrl-r, history

[24 Feb 2012 14:20] Thomas Baker
Description:
Pressing Ctrl-C during a (Ctrl-R) Search History takes you all the way out of the mysql client instead of just out of search history.  This is unlike the behavior of bash.

Other people experience this same problem:
http://bugs.mysql.com/bug.php?id=1989 (closed because a related issue was reported on the same ticket)
http://ubuntuforums.org/archive/index.php/t-866335.html

Note: I'm really not sure to what extent these behaviors are inherited from the shell or readline but as the behavior of Ctrl-C during long-running queries was changed I think this is a legitimate request.

How to repeat:
1. Sign in to mysql commandline client.
2. Ctrl-R, begin typing part of some previous command.
3. Ctrl-C

Expected:
- Taken back to "mysql>" prompt.

Actual:
- Dumped out of commandline client altogether.

Example:

[bakert@hotblackdesiato ~]$ mysql --version
mysql  Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1
[bakert@hotblackdesiato ~]$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26662265
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(reverse-i-search)`SELE': ^CCtrl-C -- exit!;Aborted
[bakert@hotblackdesiato ~]$ 

Suggested fix:
The behavior of Ctrl-C during long-running query was changed to cancel the query.  I'd like to see the same change made when searching history.  The first Ctrl-C takes you back to a plain "mysql>" prompt, hitting Ctrl-C again there exits the client (or even change exit to Ctrl-D like a shell/terminal?)
[24 Feb 2012 17:25] Valeriy Kravchuk
Thank you for the feature request.
[15 Mar 2012 10:54] Chris Buckley
See also #63201.
[28 Jun 2013 23:42] Matthew Lord
Hi Thomas,

Thank you for the feature request, and for helping to make MySQL even better!

I'm closing this for now, as I get the desired behavior using the latest client from 5.7.1:

mysql> select * from foo;                                                                                                                                                                                       bck:selec
^C

I did:
  1) ctrl-r
  2) typed "selec"
  3) ctrl-c

If I'm misunderstanding anything here, just let me know.

Thanks again!
[1 Jul 2013 7:08] NOT_FOUND NOT_FOUND
Awesome!  Thanks so much.