diff options
Diffstat (limited to 'client/mysqladmin.cc')
-rw-r--r-- | client/mysqladmin.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 9a9377026fb..4a75cb4905f 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -24,7 +24,7 @@ #include <mysql.h> #define ADMIN_VERSION "8.42" -#define MAX_MYSQL_VAR 256 +#define MAX_MYSQL_VAR 512 #define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ #define MAX_TRUNC_LENGTH 3 @@ -232,6 +232,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_count_iterations= 1; break; case 'p': + if (argument == disabled_my_option) + argument= (char*) ""; // Don't require password if (argument) { char *start=argument; @@ -369,7 +371,7 @@ int main(int argc,char *argv[]) } else { - while (!interrupted && (!opt_count_iterations || nr_iterations)) + while (!interrupted) { new_line = 0; if ((error=execute_commands(&mysql,argc,commands))) @@ -393,11 +395,11 @@ int main(int argc,char *argv[]) } if (interval) { + if (opt_count_iterations && --nr_iterations == 0) + break; sleep(interval); if (new_line) puts(""); - if (opt_count_iterations) - nr_iterations--; } else break; @@ -677,10 +679,16 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) pos=argv[1]; for (;;) { - if (mysql_kill(mysql,(ulong) atol(pos))) + /* We don't use mysql_kill(), since it only handles 32-bit IDs. */ + char buff[26], *out; /* "KILL " + max 20 digs + NUL */ + out= strxmov(buff, "KILL ", NullS); + ullstr(strtoull(pos, NULL, 0), out); + + if (mysql_query(mysql, buff)) { - my_printf_error(0, "kill failed on %ld; error: '%s'", error_flags, - atol(pos), mysql_error(mysql)); + /* out still points to just the number */ + my_printf_error(0, "kill failed on %s; error: '%s'", error_flags, + out, mysql_error(mysql)); error=1; } if (!(pos=strchr(pos,','))) @@ -735,6 +743,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) mysql_error(mysql)); return -1; } + + DBUG_ASSERT(mysql_num_rows(res) < MAX_MYSQL_VAR); + if (!opt_vertical) print_header(res); else |