Skip to content

Commit 3d96561

Browse files
committed
WL#15831: Step 2/4: Changes to client tools and command structures
This patch does minor changes to mysql client to modernize the list of words it uses for completion. For mysqladmin we replace the usage of RESET MASTER with the new command RESET BINARY LOGS AND GTIDS. The tool will however use the old command if the version of the server it is contacting does not support it. We also do minor renames for command enum values in the server. Finally, we also remove the deprecated status variables that contain the master/slave terminology. Change-Id: If609924fc99a61e7e373f1ed01a3e758627cf66f
1 parent 7cabca9 commit 3d96561

File tree

6 files changed

+49
-91
lines changed

6 files changed

+49
-91
lines changed

client/mysql.cc

+15-15
Original file line numberDiff line numberDiff line change
@@ -688,21 +688,21 @@ static COMMANDS commands[] = {
688688
{"LOOP", 0, nullptr, false, ""},
689689
{"LOW_PRIORITY", 0, nullptr, false, ""},
690690
{"MASTER", 0, nullptr, false, ""},
691-
{"MASTER_CONNECT_RETRY", 0, nullptr, false, ""},
692-
{"MASTER_HOST", 0, nullptr, false, ""},
693-
{"MASTER_LOG_FILE", 0, nullptr, false, ""},
694-
{"MASTER_LOG_POS", 0, nullptr, false, ""},
695-
{"MASTER_PASSWORD", 0, nullptr, false, ""},
696-
{"MASTER_PORT", 0, nullptr, false, ""},
697-
{"MASTER_SERVER_ID", 0, nullptr, false, ""},
698-
{"MASTER_SSL", 0, nullptr, false, ""},
699-
{"MASTER_SSL_CA", 0, nullptr, false, ""},
700-
{"MASTER_SSL_CAPATH", 0, nullptr, false, ""},
701-
{"MASTER_SSL_CERT", 0, nullptr, false, ""},
702-
{"MASTER_SSL_CIPHER", 0, nullptr, false, ""},
703-
{"MASTER_TLS_VERSION", 0, nullptr, false, ""},
704-
{"MASTER_SSL_KEY", 0, nullptr, false, ""},
705-
{"MASTER_USER", 0, nullptr, false, ""},
691+
{"SOURCE_CONNECT_RETRY", 0, nullptr, false, ""},
692+
{"SOURCE_HOST", 0, nullptr, false, ""},
693+
{"SOURCE_LOG_FILE", 0, nullptr, false, ""},
694+
{"SOURCE_LOG_POS", 0, nullptr, false, ""},
695+
{"SOURCE_PASSWORD", 0, nullptr, false, ""},
696+
{"SOURCE_PORT", 0, nullptr, false, ""},
697+
{"SOURCE_SERVER_ID", 0, nullptr, false, ""},
698+
{"SOURCE_SSL", 0, nullptr, false, ""},
699+
{"SOURCE_SSL_CA", 0, nullptr, false, ""},
700+
{"SOURCE_SSL_CAPATH", 0, nullptr, false, ""},
701+
{"SOURCE_SSL_CERT", 0, nullptr, false, ""},
702+
{"SOURCE_SSL_CIPHER", 0, nullptr, false, ""},
703+
{"SOURCE_TLS_VERSION", 0, nullptr, false, ""},
704+
{"SOURCE_SSL_KEY", 0, nullptr, false, ""},
705+
{"SOURCE_USER", 0, nullptr, false, ""},
706706
{"MATCH", 0, nullptr, false, ""},
707707
{"MAX_CONNECTIONS_PER_HOUR", 0, nullptr, false, ""},
708708
{"MAX_QUERIES_PER_HOUR", 0, nullptr, false, ""},

client/mysqladmin.cc

+7-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#define MAX_MYSQL_VAR 8192
6161
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
6262
#define MAX_TRUNC_LENGTH 3
63+
#define FIRST_SOURCE_COMMAND_VERSION 80200
6364

6465
const char *host = nullptr;
6566
char *user = nullptr;
@@ -676,6 +677,7 @@ static int execute_commands(MYSQL *mysql, int argc, char **argv) {
676677
for (; argc > 0; argv++, argc--) {
677678
int option;
678679
bool log_warnings = true;
680+
std::string admin_reset_command = "RESET REPLICA, BINARY LOGS AND GTIDS";
679681
switch (option = find_type(argv[0], &command_typelib, FIND_TYPE_BASIC)) {
680682
case ADMIN_CREATE: {
681683
char buff[FN_REFLEN + 20];
@@ -747,9 +749,13 @@ static int execute_commands(MYSQL *mysql, int argc, char **argv) {
747749
}
748750
break;
749751
case ADMIN_REFRESH:
752+
if (mysql_get_server_version(mysql) < FIRST_SOURCE_COMMAND_VERSION) {
753+
admin_reset_command = "RESET REPLICA, MASTER";
754+
}
755+
750756
if (mysql_query(mysql, "FLUSH PRIVILEGES, STATUS") ||
751757
mysql_query(mysql, "FLUSH TABLES WITH READ LOCK") ||
752-
mysql_query(mysql, "RESET REPLICA, MASTER")) {
758+
mysql_query(mysql, admin_reset_command.c_str())) {
753759
my_printf_error(0, "refresh failed; error: '%s'", error_flags,
754760
mysql_error(mysql));
755761
return -1;

include/my_sqlcommand.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ enum enum_sql_command {
6565
SQLCOM_SHOW_ENGINE_STATUS,
6666
SQLCOM_SHOW_ENGINE_MUTEX,
6767
SQLCOM_SHOW_PROCESSLIST,
68-
SQLCOM_SHOW_MASTER_STAT,
69-
SQLCOM_SHOW_SLAVE_STAT,
68+
SQLCOM_SHOW_BINLOG_STATUS,
69+
SQLCOM_SHOW_REPLICA_STATUS,
7070
SQLCOM_SHOW_GRANTS,
7171
SQLCOM_SHOW_CREATE,
7272
SQLCOM_SHOW_CHARSETS,
@@ -101,12 +101,12 @@ enum enum_sql_command {
101101
SQLCOM_COMMIT,
102102
SQLCOM_SAVEPOINT,
103103
SQLCOM_RELEASE_SAVEPOINT,
104-
SQLCOM_SLAVE_START,
105-
SQLCOM_SLAVE_STOP,
104+
SQLCOM_REPLICA_START,
105+
SQLCOM_REPLICA_STOP,
106106
SQLCOM_START_GROUP_REPLICATION,
107107
SQLCOM_STOP_GROUP_REPLICATION,
108108
SQLCOM_BEGIN,
109-
SQLCOM_CHANGE_MASTER,
109+
SQLCOM_CHANGE_REPLICATION_SOURCE,
110110
SQLCOM_CHANGE_REPLICATION_FILTER,
111111
SQLCOM_RENAME_TABLE,
112112
SQLCOM_RESET,
@@ -117,7 +117,7 @@ enum enum_sql_command {
117117
SQLCOM_HA_OPEN,
118118
SQLCOM_HA_CLOSE,
119119
SQLCOM_HA_READ,
120-
SQLCOM_SHOW_SLAVE_HOSTS,
120+
SQLCOM_SHOW_REPLICAS,
121121
SQLCOM_DELETE_MULTI,
122122
SQLCOM_UPDATE_MULTI,
123123
SQLCOM_SHOW_BINLOG_EVENTS,

include/mysql/plugin_audit.h.pp

+6-6
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@
197197
SQLCOM_SHOW_ENGINE_STATUS,
198198
SQLCOM_SHOW_ENGINE_MUTEX,
199199
SQLCOM_SHOW_PROCESSLIST,
200-
SQLCOM_SHOW_MASTER_STAT,
201-
SQLCOM_SHOW_SLAVE_STAT,
200+
SQLCOM_SHOW_BINLOG_STATUS,
201+
SQLCOM_SHOW_REPLICA_STATUS,
202202
SQLCOM_SHOW_GRANTS,
203203
SQLCOM_SHOW_CREATE,
204204
SQLCOM_SHOW_CHARSETS,
@@ -233,12 +233,12 @@
233233
SQLCOM_COMMIT,
234234
SQLCOM_SAVEPOINT,
235235
SQLCOM_RELEASE_SAVEPOINT,
236-
SQLCOM_SLAVE_START,
237-
SQLCOM_SLAVE_STOP,
236+
SQLCOM_REPLICA_START,
237+
SQLCOM_REPLICA_STOP,
238238
SQLCOM_START_GROUP_REPLICATION,
239239
SQLCOM_STOP_GROUP_REPLICATION,
240240
SQLCOM_BEGIN,
241-
SQLCOM_CHANGE_MASTER,
241+
SQLCOM_CHANGE_REPLICATION_SOURCE,
242242
SQLCOM_CHANGE_REPLICATION_FILTER,
243243
SQLCOM_RENAME_TABLE,
244244
SQLCOM_RESET,
@@ -249,7 +249,7 @@
249249
SQLCOM_HA_OPEN,
250250
SQLCOM_HA_CLOSE,
251251
SQLCOM_HA_READ,
252-
SQLCOM_SHOW_SLAVE_HOSTS,
252+
SQLCOM_SHOW_REPLICAS,
253253
SQLCOM_DELETE_MULTI,
254254
SQLCOM_UPDATE_MULTI,
255255
SQLCOM_SHOW_BINLOG_EVENTS,

include/mysql_com.h

-6
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,12 @@
226226
#define REFRESH_REPLICA \
227227
64 /**< Reset source info and restart replica \
228228
thread, RESET REPLICA */
229-
#define REFRESH_SLAVE \
230-
REFRESH_REPLICA /**< Reset source info and restart replica \
231-
thread, RESET REPLICA. This is deprecated, \
232-
use REFRESH_REPLICA instead. */
233229

234230
#define REFRESH_SOURCE \
235231
128 /**< Remove all bin logs in the index \
236232
and truncate the index. Also resets \
237233
GTID information. Command: \
238234
RESET BINARY LOGS AND GTIDS */
239-
#define REFRESH_MASTER \
240-
REFRESH_SOURCE /**< This is deprecated, use REFRESH_SOURCE instead. */
241235

242236
#define REFRESH_ERROR_LOG 256 /**< Rotate only the error log */
243237
#define REFRESH_ENGINE_LOG 512 /**< Flush all storage engine logs */

sql/mysqld.cc

+15-57
Original file line numberDiff line numberDiff line change
@@ -4151,15 +4151,13 @@ SHOW_VAR com_status_vars[] = {
41514151
{"change_db",
41524152
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHANGE_DB]),
41534153
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
4154-
{"change_master",
4155-
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHANGE_MASTER]),
4156-
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
41574154
{"change_repl_filter",
41584155
(char *)offsetof(System_status_var,
41594156
com_stat[(uint)SQLCOM_CHANGE_REPLICATION_FILTER]),
41604157
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
41614158
{"change_replication_source",
4162-
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHANGE_MASTER]),
4159+
(char *)offsetof(System_status_var,
4160+
com_stat[(uint)SQLCOM_CHANGE_REPLICATION_SOURCE]),
41634161
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
41644162
{"check", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHECK]),
41654163
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
@@ -4478,13 +4476,9 @@ SHOW_VAR com_status_vars[] = {
44784476
{"show_keys",
44794477
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_KEYS]),
44804478
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
4481-
{"show_master_status",
4482-
(char *)offsetof(System_status_var,
4483-
com_stat[(uint)SQLCOM_SHOW_MASTER_STAT]),
4484-
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
44854479
{"show_binary_log_status",
44864480
(char *)offsetof(System_status_var,
4487-
com_stat[(uint)SQLCOM_SHOW_MASTER_STAT]),
4481+
com_stat[(uint)SQLCOM_SHOW_BINLOG_STATUS]),
44884482
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
44894483
{"show_open_tables",
44904484
(char *)offsetof(System_status_var,
@@ -4523,20 +4517,11 @@ SHOW_VAR com_status_vars[] = {
45234517
com_stat[(uint)SQLCOM_SHOW_RELAYLOG_EVENTS]),
45244518
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
45254519
{"show_replicas",
4526-
(char *)offsetof(System_status_var,
4527-
com_stat[(uint)SQLCOM_SHOW_SLAVE_HOSTS]),
4528-
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
4529-
{"show_slave_hosts",
4530-
(char *)offsetof(System_status_var,
4531-
com_stat[(uint)SQLCOM_SHOW_SLAVE_HOSTS]),
4520+
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_REPLICAS]),
45324521
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
45334522
{"show_replica_status",
45344523
(char *)offsetof(System_status_var,
4535-
com_stat[(uint)SQLCOM_SHOW_SLAVE_STAT]),
4536-
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
4537-
{"show_slave_status",
4538-
(char *)offsetof(System_status_var,
4539-
com_stat[(uint)SQLCOM_SHOW_SLAVE_STAT]),
4524+
com_stat[(uint)SQLCOM_SHOW_REPLICA_STATUS]),
45404525
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
45414526
{"show_status",
45424527
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_STATUS]),
@@ -4569,16 +4554,10 @@ SHOW_VAR com_status_vars[] = {
45694554
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHUTDOWN]),
45704555
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
45714556
{"replica_start",
4572-
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_START]),
4573-
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
4574-
{"slave_start",
4575-
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_START]),
4557+
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REPLICA_START]),
45764558
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
45774559
{"replica_stop",
4578-
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_STOP]),
4579-
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
4580-
{"slave_stop",
4581-
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_STOP]),
4560+
(char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REPLICA_STOP]),
45824561
SHOW_LONG_STATUS, SHOW_SCOPE_ALL},
45834562
{"group_replication_start",
45844563
(char *)offsetof(System_status_var,
@@ -5367,10 +5346,6 @@ static PSI_metric_info_v1 com_metrics[] = {
53675346
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
53685347
(void *)offsetof(aggregated_stats_buffer,
53695348
com_stat[(uint)SQLCOM_CHANGE_DB])},
5370-
{"change_master", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
5371-
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
5372-
(void *)offsetof(aggregated_stats_buffer,
5373-
com_stat[(uint)SQLCOM_CHANGE_MASTER])},
53745349
{"change_repl_filter", "", COM_COMMON_DESCRIPTION,
53755350
MetricOTELType::ASYNC_COUNTER, MetricNumType::METRIC_INTEGER, 0, 0,
53765351
get_metric_aggregated_integer,
@@ -5380,7 +5355,7 @@ static PSI_metric_info_v1 com_metrics[] = {
53805355
MetricOTELType::ASYNC_COUNTER, MetricNumType::METRIC_INTEGER, 0, 0,
53815356
get_metric_aggregated_integer,
53825357
(void *)offsetof(aggregated_stats_buffer,
5383-
com_stat[(uint)SQLCOM_CHANGE_MASTER])},
5358+
com_stat[(uint)SQLCOM_CHANGE_REPLICATION_SOURCE])},
53845359
{"check", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
53855360
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
53865361
(void *)offsetof(aggregated_stats_buffer, com_stat[(uint)SQLCOM_CHECK])},
@@ -5795,11 +5770,11 @@ static PSI_metric_info_v1 com_metrics[] = {
57955770
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
57965771
(void *)offsetof(aggregated_stats_buffer,
57975772
com_stat[(uint)SQLCOM_SHOW_KEYS])},
5798-
{"show_master_status", "", COM_COMMON_DESCRIPTION,
5773+
{"show_binary_log_status", "", COM_COMMON_DESCRIPTION,
57995774
MetricOTELType::ASYNC_COUNTER, MetricNumType::METRIC_INTEGER, 0, 0,
58005775
get_metric_aggregated_integer,
58015776
(void *)offsetof(aggregated_stats_buffer,
5802-
com_stat[(uint)SQLCOM_SHOW_MASTER_STAT])},
5777+
com_stat[(uint)SQLCOM_SHOW_BINLOG_STATUS])},
58035778
{"show_open_tables", "", COM_COMMON_DESCRIPTION,
58045779
MetricOTELType::ASYNC_COUNTER, MetricNumType::METRIC_INTEGER, 0, 0,
58055780
get_metric_aggregated_integer,
@@ -5845,12 +5820,12 @@ static PSI_metric_info_v1 com_metrics[] = {
58455820
{"show_replicas", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
58465821
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
58475822
(void *)offsetof(aggregated_stats_buffer,
5848-
com_stat[(uint)SQLCOM_SHOW_SLAVE_HOSTS])},
5823+
com_stat[(uint)SQLCOM_SHOW_REPLICAS])},
58495824
{"show_replica_status", "", COM_COMMON_DESCRIPTION,
58505825
MetricOTELType::ASYNC_COUNTER, MetricNumType::METRIC_INTEGER, 0, 0,
58515826
get_metric_aggregated_integer,
58525827
(void *)offsetof(aggregated_stats_buffer,
5853-
com_stat[(uint)SQLCOM_SHOW_SLAVE_STAT])},
5828+
com_stat[(uint)SQLCOM_SHOW_REPLICA_STATUS])},
58545829
{"show_status", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
58555830
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
58565831
(void *)offsetof(aggregated_stats_buffer,
@@ -5894,19 +5869,11 @@ static PSI_metric_info_v1 com_metrics[] = {
58945869
{"replica_start", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
58955870
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
58965871
(void *)offsetof(aggregated_stats_buffer,
5897-
com_stat[(uint)SQLCOM_SLAVE_START])},
5898-
{"slave_start", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
5899-
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
5900-
(void *)offsetof(aggregated_stats_buffer,
5901-
com_stat[(uint)SQLCOM_SLAVE_START])},
5872+
com_stat[(uint)SQLCOM_REPLICA_START])},
59025873
{"replica_stop", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
59035874
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
59045875
(void *)offsetof(aggregated_stats_buffer,
5905-
com_stat[(uint)SQLCOM_SLAVE_STOP])},
5906-
{"slave_stop", "", COM_COMMON_DESCRIPTION, MetricOTELType::ASYNC_COUNTER,
5907-
MetricNumType::METRIC_INTEGER, 0, 0, get_metric_aggregated_integer,
5908-
(void *)offsetof(aggregated_stats_buffer,
5909-
com_stat[(uint)SQLCOM_SLAVE_STOP])},
5876+
com_stat[(uint)SQLCOM_REPLICA_STOP])},
59105877
{"group_replication_start", "", COM_COMMON_DESCRIPTION,
59115878
MetricOTELType::ASYNC_COUNTER, MetricNumType::METRIC_INTEGER, 0, 0,
59125879
get_metric_aggregated_integer,
@@ -6710,21 +6677,12 @@ int init_common_variables() {
67106677
Com_stmt_reset => com_stmt_reset
67116678
Com_stmt_send_long_data => com_stmt_send_long_data
67126679

6713-
We also have aliases for 6 com_status_vars:
6714-
6715-
Com_slave_start => Com_replica_start
6716-
Com_slave_stop => Com_replica_stop
6717-
Com_show_slave_status => Com_show_replica_status
6718-
Com_show_slave_hosts => Com_show_replicas
6719-
Com_change_master => Com_change_replication_source
6720-
Com_show_master_status => Com_show_binary_log_status
6721-
67226680
With this correction the number of Com_ variables (number of elements in
67236681
the array, excluding the last element - terminator) must match the number
67246682
of SQLCOM_ constants.
67256683
*/
67266684
static_assert(sizeof(com_status_vars) / sizeof(com_status_vars[0]) - 1 ==
6727-
SQLCOM_END + 13,
6685+
SQLCOM_END + 7,
67286686
"");
67296687
#endif
67306688

0 commit comments

Comments
 (0)