Skip to content

Commit 0af8b56

Browse files
grooverdansvoj
authored andcommitted
MDEV-11610: mysqladmin flush-X-log options
Add the following options to mysqladmin + flush-binary-log Flush binary log + flush-engine-log Flush engine log(s) + flush-error-log Flush error log + flush-general-log Flush general log + flush-relay-log Flush relay log + flush-user-resources Flush user resources
1 parent 33c1f20 commit 0af8b56

File tree

1 file changed

+74
-4
lines changed

1 file changed

+74
-4
lines changed

client/mysqladmin.cc

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ enum commands {
102102
ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS,
103103
ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE,
104104
ADMIN_START_ALL_SLAVES, ADMIN_STOP_ALL_SLAVES,
105-
ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD, ADMIN_FLUSH_SLOW_LOG,
105+
ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD, ADMIN_FLUSH_BINARY_LOG,
106+
ADMIN_FLUSH_ENGINE_LOG, ADMIN_FLUSH_ERROR_LOG, ADMIN_FLUSH_GENERAL_LOG,
107+
ADMIN_FLUSH_RELAY_LOG, ADMIN_FLUSH_SLOW_LOG,
106108
ADMIN_FLUSH_TABLE_STATISTICS, ADMIN_FLUSH_INDEX_STATISTICS,
107109
ADMIN_FLUSH_USER_STATISTICS, ADMIN_FLUSH_CLIENT_STATISTICS,
110+
ADMIN_FLUSH_USER_RESOURCES,
108111
ADMIN_FLUSH_ALL_STATUS, ADMIN_FLUSH_ALL_STATISTICS
109112
};
110113
static const char *command_names[]= {
@@ -116,9 +119,10 @@ static const char *command_names[]= {
116119
"ping", "extended-status", "flush-status",
117120
"flush-privileges", "start-slave", "stop-slave",
118121
"start-all-slaves", "stop-all-slaves",
119-
"flush-threads", "old-password", "flush-slow-log",
122+
"flush-threads", "old-password", "flush-binary-log", "flush-engine-log",
123+
"flush-error-log", "flush-general-log", "flush-relay-log", "flush-slow-log",
120124
"flush-table-statistics", "flush-index-statistics",
121-
"flush-user-statistics", "flush-client-statistics",
125+
"flush-user-statistics", "flush-client-statistics", "flush-user-resources",
122126
"flush-all-status", "flush-all-statistics",
123127
NullS
124128
};
@@ -916,6 +920,56 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
916920
}
917921
break;
918922
}
923+
case ADMIN_FLUSH_BINARY_LOG:
924+
{
925+
if (mysql_query(mysql, "flush binary logs"))
926+
{
927+
my_printf_error(0, "flush failed; error: '%s'", error_flags,
928+
mysql_error(mysql));
929+
return -1;
930+
}
931+
break;
932+
}
933+
case ADMIN_FLUSH_ENGINE_LOG:
934+
{
935+
if (mysql_query(mysql,"flush engine logs"))
936+
{
937+
my_printf_error(0, "flush failed; error: '%s'", error_flags,
938+
mysql_error(mysql));
939+
return -1;
940+
}
941+
break;
942+
}
943+
case ADMIN_FLUSH_ERROR_LOG:
944+
{
945+
if (mysql_query(mysql, "flush error logs"))
946+
{
947+
my_printf_error(0, "flush failed; error: '%s'", error_flags,
948+
mysql_error(mysql));
949+
return -1;
950+
}
951+
break;
952+
}
953+
case ADMIN_FLUSH_GENERAL_LOG:
954+
{
955+
if (mysql_query(mysql, "flush general logs"))
956+
{
957+
my_printf_error(0, "flush failed; error: '%s'", error_flags,
958+
mysql_error(mysql));
959+
return -1;
960+
}
961+
break;
962+
}
963+
case ADMIN_FLUSH_RELAY_LOG:
964+
{
965+
if (mysql_query(mysql, "flush relay logs"))
966+
{
967+
my_printf_error(0, "flush failed; error: '%s'", error_flags,
968+
mysql_error(mysql));
969+
return -1;
970+
}
971+
break;
972+
}
919973
case ADMIN_FLUSH_SLOW_LOG:
920974
{
921975
if (mysql_query(mysql,"flush slow logs"))
@@ -986,6 +1040,16 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
9861040
}
9871041
break;
9881042
}
1043+
case ADMIN_FLUSH_USER_RESOURCES:
1044+
{
1045+
if (mysql_query(mysql, "flush user_resources"))
1046+
{
1047+
my_printf_error(0, "flush failed; error: '%s'", error_flags,
1048+
mysql_error(mysql));
1049+
return -1;
1050+
}
1051+
break;
1052+
}
9891053
case ADMIN_FLUSH_CLIENT_STATISTICS:
9901054
{
9911055
if (mysql_query(mysql,"flush client_statistics"))
@@ -1309,12 +1373,18 @@ static void usage(void)
13091373
flush-index-statistics Flush index statistics\n\
13101374
flush-logs Flush all logs\n\
13111375
flush-privileges Reload grant tables (same as reload)\n\
1376+
flush-binary-log Flush binary log\n\
1377+
flush-engine-log Flush engine log(s)\n\
1378+
flush-error-log Flush error log\n\
1379+
flush-general-log Flush general log\n\
1380+
flush-relay-log Flush relay log\n\
13121381
flush-slow-log Flush slow query log\n\
1313-
flush-status Clear status variables\n\
1382+
flush-status Clear status variables\n\
13141383
flush-table-statistics Clear table statistics\n\
13151384
flush-tables Flush all tables\n\
13161385
flush-threads Flush the thread cache\n\
13171386
flush-user-statistics Flush user statistics\n\
1387+
flush-user-resources Flush user resources\n\
13181388
kill id,id,... Kill mysql threads");
13191389
#if MYSQL_VERSION_ID >= 32200
13201390
puts("\

0 commit comments

Comments
 (0)