June 16, 2007

MySQL 5.1 Command line client improvements

Posted by peter |

Just found this little handy feature today:

SQL:
  1. mysql> INSERT INTO c SELECT rand()*1000, sha1(rand()) FROM c;
  2. Query aborted BY Ctrl+C
  3. ERROR 1317 (70100): Query execution was interrupted

So now if you press CTRL-C MySQL Command Line Client will not exit but will terminate query being executed. This is great as so many queries assumed CTRL-C would also abort running query in previous MySQL versions and I've seen many monstrous queries left running without noticing just because people would think CTRL-C terminated the query. Now it finally really does.

Great Job! I wish I would see more of such relatively simple but very handy improvements :)

Related posts: :Logging your MySQL command line client sessions::MySQL Query Cache WhiteSpace and comments::SHOW OPEN TABLES – what is in your table cache:
 

9 Comments »

  1. 1. Paul DuBois

    This was introduced in 5.0.25 (and 5.1.10).

    http://dev.mysql.com/doc/refman/5.0/en/news-5-0-25.html

    Comment :: June 16, 2007 @ 4:37 pm

  2. i did that.

    Comment :: June 16, 2007 @ 5:36 pm

  3. 3. Harrison Fisk

    I helped with it ;)

    Comment :: June 16, 2007 @ 5:46 pm

  4. that’s right! i forgot that what i did was based on harrison’s initial patch.

    Comment :: June 16, 2007 @ 6:33 pm

  5. 5. peter

    Thanks Jim, Harrison, Paul

    It may have been where for a while I just somehow did not notice it before :)

    Comment :: June 17, 2007 @ 9:06 am

  6. 6. Perrin Harkins

    I agree: great feature! Very helpful.

    Comment :: June 17, 2007 @ 9:44 pm

  7. 7. Moazzam

    You guys rock! It’s very handy. Using that you can even do a select and an insert in the same query from the same table. It randomly messes up the MYI files, though (which can be repaired by table repair command). It would be great if it didn’t.

    I did something like this :

    insert into table1 (id, serial_no) select ‘asd’ as id, count(name) as serial_no from where category=’blah’

    Comment :: June 18, 2007 @ 9:13 am

  8. 8. Moazzam

    It won’t let me edit my comment so I am posting a new one. I had an error in the query I posted. Here is the right one :

    insert into table1 (id, serial_no) select ‘asd’ as id, count(name) as serial_no from table1 table1_1 where category=’blah’

    Comment :: June 18, 2007 @ 9:14 am

  9. 9. peter

    Moazzam,

    Please report it as a but KILL for the query should not cause data corruption. It would be OK to abort the query and have partially executed insert for MyISAM tables but if index gets corrupted it is surely a bug.

    Comment :: June 18, 2007 @ 11:45 am

 

Subscribe without commenting

Trackbacks/Pingbacks