MYSQL select beep; - make mysql console beep when selected - or notified

206 Views Asked by At

Rather a peculiar question.

Is there a possibility to "select beep" in mysql or any sql for that matter ? - I often run a few queries / updates / alter commands which takes quite some time and I wish when the query ends to be notified.

Is there anyway for the mysql client console to notify using audio / sound / beep ?

Before you all start crucifying me let's remember:

  1. MySQL does beep on errors - so the possibility exists
  2. MySQL or any console should be "friendly to the user", for example it includes the \G which allows to view the results in a more human readable format.

So why not beep ?

I know it is possible to achieve it using shell / bash command line or any scripting language.

1

There are 1 best solutions below

0
Majid Hajibaba On

There is no simple solution. However mysql use putchar('\a') in its code to make a beep.

if (info_type == INFO_ERROR) {
  if (!opt_nobeep) putchar('\a'); /* This should make a bell */
  if (error) {
    if (sqlstate)
      (void)tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
    else
      (void)tee_fprintf(file, "ERROR %d: ", error);
  } else
    tee_puts("ERROR: ", file);
}

If you compile mysql from the source you can use it everywhere in mysql-server/client/mysql.cc specially at the end of for loop in read_and_execute function.