Bug #66583 | Ctrl-C behavior violates principle of least astonishment | ||
---|---|---|---|
Submitted: | 28 Aug 2012 20:54 | Modified: | 10 Dec 2012 17:40 |
Reporter: | Chris Cowart | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S4 (Feature request) |
Version: | Ver 14.12 Distrib 5.0.60, for redhat-lin | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[28 Aug 2012 20:54]
Chris Cowart
[29 Aug 2012 6:26]
Valeriy Kravchuk
That bug you refer to is fixed in 5.1, 5.0.x is no longer actively supported. On modern version I see exactly the fix as described and intended: [openxs@chief 5.6]$ bin/mysql -uroot test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.7-debug Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select sleep(20); ^CCtrl-C -- sending "KILL QUERY 1" to server ... Ctrl-C -- query aborted. +-----------+ | sleep(20) | +-----------+ +-----------+ 1 row in set (1.18 sec) mysql> select version(); +-------------+ | version() | +-------------+ | 5.6.7-debug | +-------------+ 1 row in set (0.00 sec) mysql> select sleep(20); ^CCtrl-C -- sending "KILL QUERY 1" to server ... Ctrl-C -- query aborted. +-----------+ | sleep(20) | +-----------+ +-----------+ 1 row in set (0.89 sec) mysql> Ctrl-C -- exit! Aborted So, Ctrl-C kills current query, if pressed twice or there is no current query then mysql client is aborted. Isn't this enough for most use cases?
[29 Aug 2012 7:11]
Chris Cowart
No, the whole point is that no matter how many times you press Ctrl-C, the mysql client should not exit. The precedent among all other interactive unix programs is that Ctrl-C will abort the current operation, abort what you've typed, or if neither is applIcable, behave as a no-op. Ctrl-D (as eof, signalling no more input) often exits interactive programs (all the shells I referenced in the original report and the psql client). Ctrl-C does not cause any of the programs I mentioned to exit, no matter how many times you press it. The behavior is astonishing and frustrating to users who are used to widely accept behavior of interactive CLI tools. I'm not saying it had to be the default (though I think it should be), but it at least needs to be configurable. Google around for "MySQL Ctrl-c" and see how many people are astonished and frustrated by the exit-on-sigint behavior.
[29 Aug 2012 8:36]
Valeriy Kravchuk
OK, I've got your point.
[10 Dec 2012 17:40]
Paul DuBois
Noted in 5.7.0 changelog. Previously, Control+C in mysql interrupted the current statement if there was one, or exited mysql if not. Now Control+C interrupts the current statement if there was one, or cancels any partial input line otherwise, but does not exit.