Commit 80c1556a authored by unknown's avatar unknown

changes to mysqladmin : use queries instead of commands (so that they have a chance to go

into the binlog), SLAVE START -> START SLAVE, error test changes.


client/mysqladmin.c:
  Now that FLUSH TABLES and some other FLUSH go into the binlog, the same commands
  issued from mysqladmin should also go into the binlog. How could I explain to
  a user that "mysql -e 'flush tables'" is not exactly the same as "mysqladmin
  flush-tables" ?? So I replace mysql_refresh() by mysql_query().
  Also SLAVE START -> START SLAVE to make this work with 4.1 (it won't work with
  3.23 anymore).
  Also the code tested for mysql_refresh() < 0 for errors, but this cannot happen :
  - mysql_refresh() calls simple_command()
  - in 4.1 the return type of simple_command() is my_bool, and I have checked the 4.1 libmysql
  code and it returns 0 or 1, not negative values.
  - note that in 4.0 libmysql, simple_command() returns int which can be < 0, but we don't
  care here as we link the 4.1 mysqladmin with the 4.1 libmysql.
  Btw, some other parts of the code already checked
  for mysql_refresh() != 0, not < 0. So now it's homogenous : we always test for != 0
  instead of < 0.
parent ddabd51c
......@@ -520,7 +520,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
case ADMIN_FLUSH_PRIVILEGES:
case ADMIN_RELOAD:
if (mysql_refresh(mysql,REFRESH_GRANT) < 0)
if (mysql_query(mysql,"flush privileges"))
{
my_printf_error(0,"reload failed; error: '%s'",MYF(ME_BELL),
mysql_error(mysql));
......@@ -531,7 +531,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
if (mysql_refresh(mysql,
(uint) ~(REFRESH_GRANT | REFRESH_STATUS |
REFRESH_READ_LOCK | REFRESH_SLAVE |
REFRESH_MASTER)) < 0)
REFRESH_MASTER)))
{
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
mysql_error(mysql));
......@@ -539,7 +539,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
break;
case ADMIN_FLUSH_THREADS:
if (mysql_refresh(mysql,(uint) REFRESH_THREADS) < 0)
if (mysql_refresh(mysql,(uint) REFRESH_THREADS))
{
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
mysql_error(mysql));
......@@ -726,7 +726,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
case ADMIN_FLUSH_HOSTS:
{
if (mysql_refresh(mysql,REFRESH_HOSTS))
if (mysql_query(mysql,"flush hosts"))
{
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
mysql_error(mysql));
......@@ -736,7 +736,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
case ADMIN_FLUSH_TABLES:
{
if (mysql_refresh(mysql,REFRESH_TABLES))
if (mysql_query(mysql,"flush tables"))
{
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
mysql_error(mysql));
......@@ -746,7 +746,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
case ADMIN_FLUSH_STATUS:
{
if (mysql_refresh(mysql,REFRESH_STATUS))
if (mysql_query(mysql,"flush status"))
{
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
mysql_error(mysql));
......@@ -793,7 +793,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
case ADMIN_START_SLAVE:
if (mysql_query(mysql, "SLAVE START"))
if (mysql_query(mysql, "START SLAVE"))
{
my_printf_error(0, "Error starting slave: %s", MYF(ME_BELL),
mysql_error(mysql));
......@@ -803,7 +803,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
puts("Slave started");
break;
case ADMIN_STOP_SLAVE:
if (mysql_query(mysql, "SLAVE STOP"))
if (mysql_query(mysql, "STOP SLAVE"))
{
my_printf_error(0, "Error stopping slave: %s", MYF(ME_BELL),
mysql_error(mysql));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment