Skip to content

Commit

Permalink
WL#13448: Remove COM_XXX commands which are deprecated
Browse files Browse the repository at this point in the history
Removed:
COM_REFRESH
COM_FIELD_LIST
COM_PROCESS_INFO
COM_PROCESS_KILL
mysql_refresh()
mysql_reload()
mysql_list_fields()
mysql_list_processes()
mysql_kill()

Change-Id: I14b830e2d82d0d5af43c1a26fa28172fcb2006a4
  • Loading branch information
gkodinov committed Oct 31, 2023
1 parent fd48fef commit 15d9b4d
Show file tree
Hide file tree
Showing 35 changed files with 65 additions and 2,133 deletions.
10 changes: 8 additions & 2 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3218,8 +3218,14 @@ You can turn off this feature to get a quicker startup with -A\n\n");
}
i = 0;
while ((table_row = mysql_fetch_row(tables))) {
if ((fields = mysql_list_fields(&mysql_handle, (const char *)table_row[0],
NullS))) {
char quoted_table_name[2 * NAME_LEN + 2];
char query[2 * NAME_LEN + 100];
mysql_real_escape_string_quote(&mysql_handle, quoted_table_name,
table_row[0], strlen(table_row[0]), '`');
snprintf(query, sizeof(query), "SELECT * FROM `%s` LIMIT 0",
quoted_table_name);
if (!mysql_query(&mysql_handle, query) &&
(fields = mysql_store_result(&mysql_handle))) {
num_fields = mysql_num_fields(fields);
if (!(field_names[i] = (char **)hash_mem_root.Alloc(
sizeof(char *) * (num_fields * 2 + 1)))) {
Expand Down
16 changes: 3 additions & 13 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ enum commands {
ADMIN_FLUSH_PRIVILEGES,
ADMIN_START_REPLICA,
ADMIN_STOP_REPLICA,
ADMIN_FLUSH_THREADS,
ADMIN_START_SLAVE,
ADMIN_STOP_SLAVE
};
Expand All @@ -178,7 +177,6 @@ static const char *command_names[] = {"create",
"flush-privileges",
"start-replica",
"stop-replica",
"flush-threads",
"start-slave",
"stop-slave",
NullS};
Expand Down Expand Up @@ -749,16 +747,9 @@ static int execute_commands(MYSQL *mysql, int argc, char **argv) {
}
break;
case ADMIN_REFRESH:
if (mysql_refresh(mysql, (uint) ~(REFRESH_GRANT | REFRESH_STATUS |
REFRESH_READ_LOCK | REFRESH_REPLICA |
REFRESH_SOURCE))) {
my_printf_error(0, "refresh failed; error: '%s'", error_flags,
mysql_error(mysql));
return -1;
}
break;
case ADMIN_FLUSH_THREADS:
if (mysql_refresh(mysql, (uint)REFRESH_THREADS)) {
if (mysql_query(mysql, "FLUSH PRIVILEGES, STATUS") ||
mysql_query(mysql, "FLUSH TABLES WITH READ LOCK") ||
mysql_query(mysql, "RESET REPLICA, MASTER")) {
my_printf_error(0, "refresh failed; error: '%s'", error_flags,
mysql_error(mysql));
return -1;
Expand Down Expand Up @@ -822,7 +813,6 @@ static int execute_commands(MYSQL *mysql, int argc, char **argv) {
}
pos = argv[1];
for (;;) {
/* 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(my_strtoull(pos, nullptr, 0), out);
Expand Down
10 changes: 4 additions & 6 deletions client/mysqldump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4785,8 +4785,7 @@ static int dump_all_tables_in_db(char *database) {
dynstr_free(&query);
}
if (flush_logs) {
if (mysql_refresh(mysql, REFRESH_LOG))
DB_error(mysql, "when doing refresh");
if (mysql_query(mysql, "FLUSH LOGS")) DB_error(mysql, "when doing refresh");
/* We shall continue here, if --force was given */
else
verbose_msg("-- dump_all_tables_in_db : logs flushed successfully!\n");
Expand Down Expand Up @@ -4941,8 +4940,7 @@ static bool dump_all_views_in_db(char *database) {
dynstr_free(&query);
}
if (flush_logs) {
if (mysql_refresh(mysql, REFRESH_LOG))
DB_error(mysql, "when doing refresh");
if (mysql_query(mysql, "FLUSH LOGS")) DB_error(mysql, "when doing refresh");
/* We shall continue here, if --force was given */
else
verbose_msg("-- dump_all_views_in_db : logs flushed successfully!\n");
Expand Down Expand Up @@ -5060,7 +5058,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) {
}
dynstr_free(&lock_tables_query);
if (flush_logs) {
if (mysql_refresh(mysql, REFRESH_LOG)) {
if (mysql_query(mysql, "FLUSH LOGS")) {
if (!opt_force) root.Clear();
DB_error(mysql, "when doing refresh");
}
Expand Down Expand Up @@ -6211,7 +6209,7 @@ int main(int argc, char **argv) {
(flush_logs || server_with_gtids_and_opt_purge_not_off)) ||
opt_delete_source_logs) {
if (flush_logs || opt_delete_source_logs) {
if (mysql_refresh(mysql, REFRESH_LOG)) {
if (mysql_query(mysql, "FLUSH LOGS")) {
DB_error(mysql, "when doing refresh");
goto err;
}
Expand Down
9 changes: 7 additions & 2 deletions client/mysqlshow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static int list_tables(MYSQL *mysql, const char *db, const char *table) {
const char *header;
size_t head_length;
uint counter = 0;
char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
char query[2 * NAME_LEN + 100], rows[2 * NAME_LEN + 2], fields[16];
MYSQL_FIELD *field;
MYSQL_RES *result = nullptr;
MYSQL_ROW row, rrow;
Expand Down Expand Up @@ -568,7 +568,12 @@ static int list_tables(MYSQL *mysql, const char *db, const char *table) {
counter++;
if (opt_verbose > 0) {
if (!(mysql_select_db(mysql, db))) {
MYSQL_RES *rresult = mysql_list_fields(mysql, row[0], nullptr);
mysql_real_escape_string_quote(mysql, rows, row[0],
(unsigned long)strlen(row[0]), '`');
snprintf(query, sizeof(query), "SELECT * FROM `%s` LIMIT 0", rows);
MYSQL_RES *rresult = (0 == mysql_query(mysql, query))
? mysql_store_result(mysql)
: nullptr;
ulong rowcount = 0L;
if (!rresult) {
my_stpcpy(fields, "N/A");
Expand Down
26 changes: 13 additions & 13 deletions include/my_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ enum enum_server_command {
Also used internally to mark the start of a session.
*/
COM_SLEEP,
COM_QUIT, /**< See @ref page_protocol_com_quit */
COM_INIT_DB, /**< See @ref page_protocol_com_init_db */
COM_QUERY, /**< See @ref page_protocol_com_query */
COM_FIELD_LIST, /**< Deprecated. See @ref page_protocol_com_field_list */
COM_QUIT, /**< See @ref page_protocol_com_quit */
COM_INIT_DB, /**< See @ref page_protocol_com_init_db */
COM_QUERY, /**< See @ref page_protocol_com_query */
COM_UNUSED_3, /**< Removed, used to be COM_FIELD_LIST */
COM_CREATE_DB, /**< Currently refused by the server. See ::dispatch_command */
COM_DROP_DB, /**< Currently refused by the server. See ::dispatch_command */
COM_REFRESH, /**< Deprecated. See @ref page_protocol_com_refresh */
COM_DEPRECATED_1, /**< Deprecated, used to be COM_SHUTDOWN */
COM_STATISTICS, /**< See @ref page_protocol_com_statistics */
COM_PROCESS_INFO, /**< Deprecated. See @ref page_protocol_com_process_info */
COM_CONNECT, /**< Currently refused by the server. */
COM_PROCESS_KILL, /**< Deprecated. See @ref page_protocol_com_process_kill */
COM_DEBUG, /**< See @ref page_protocol_com_debug */
COM_PING, /**< See @ref page_protocol_com_ping */
COM_TIME, /**< Currently refused by the server. */
COM_UNUSED_2, /**< Removed, used to be COM_REFRESH. */
COM_UNUSED_1, /**< Removed, used to be COM_SHUTDOWN */
COM_STATISTICS, /**< See @ref page_protocol_com_statistics */
COM_UNUSED_4, /**< Removed, used to be COM_PROCESS_INFO */
COM_CONNECT, /**< Currently refused by the server. */
COM_UNUSED_5, /**< Removed, used to be COM_PROCESS_KILL */
COM_DEBUG, /**< See @ref page_protocol_com_debug */
COM_PING, /**< See @ref page_protocol_com_ping */
COM_TIME, /**< Currently refused by the server. */
COM_DELAYED_INSERT, /**< Functionality removed. */
COM_CHANGE_USER, /**< See @ref page_protocol_com_change_user */
COM_BINLOG_DUMP, /**< See @ref page_protocol_com_binlog_dump */
Expand Down
9 changes: 1 addition & 8 deletions include/mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ typedef struct MYSQL_FIELD {
char *org_table; /* Org table name, if table was an alias */
char *db; /* Database for table */
char *catalog; /* Catalog for table */
char *def; /* Default value (set by mysql_list_fields) */
char *def; /* Default value */
unsigned long length; /* Width of column (create length) */
unsigned long max_length; /* Max width for selected set */
unsigned int name_length;
Expand Down Expand Up @@ -512,8 +512,6 @@ void mysql_set_local_infile_handler(

void mysql_set_local_infile_default(MYSQL *mysql);
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
int STDCALL mysql_refresh(MYSQL *mysql, unsigned int refresh_options);
int STDCALL mysql_kill(MYSQL *mysql, unsigned long pid);
int STDCALL mysql_set_server_option(MYSQL *mysql,
enum enum_mysql_set_option option);
int STDCALL mysql_ping(MYSQL *mysql);
Expand All @@ -526,7 +524,6 @@ unsigned long STDCALL mysql_get_server_version(MYSQL *mysql);
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
MYSQL_RES *STDCALL mysql_list_dbs(MYSQL *mysql, const char *wild);
MYSQL_RES *STDCALL mysql_list_tables(MYSQL *mysql, const char *wild);
MYSQL_RES *STDCALL mysql_list_processes(MYSQL *mysql);
int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option,
const void *arg);
int STDCALL mysql_options4(MYSQL *mysql, enum mysql_option option,
Expand All @@ -546,8 +543,6 @@ enum net_async_status STDCALL mysql_fetch_row_nonblocking(MYSQL_RES *res,

unsigned long *STDCALL mysql_fetch_lengths(MYSQL_RES *result);
MYSQL_FIELD *STDCALL mysql_fetch_field(MYSQL_RES *result);
MYSQL_RES *STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
const char *wild);
unsigned long STDCALL mysql_escape_string(char *to, const char *from,
unsigned long from_length);
unsigned long STDCALL mysql_hex_string(char *to, const char *from,
Expand Down Expand Up @@ -800,8 +795,6 @@ void STDCALL mysql_reset_server_public_key(void);
#define MYSQL_NO_DATA 100
#define MYSQL_DATA_TRUNCATED 101

#define mysql_reload(mysql) mysql_refresh((mysql), REFRESH_GRANT)

#define HAVE_MYSQL_REAL_CONNECT

MYSQL *STDCALL mysql_real_connect_dns_srv(MYSQL *mysql,
Expand Down
15 changes: 5 additions & 10 deletions include/mysql.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
COM_QUIT,
COM_INIT_DB,
COM_QUERY,
COM_FIELD_LIST,
COM_UNUSED_3,
COM_CREATE_DB,
COM_DROP_DB,
COM_REFRESH,
COM_DEPRECATED_1,
COM_UNUSED_2,
COM_UNUSED_1,
COM_STATISTICS,
COM_PROCESS_INFO,
COM_UNUSED_4,
COM_CONNECT,
COM_PROCESS_KILL,
COM_UNUSED_5,
COM_DEBUG,
COM_PING,
COM_TIME,
Expand Down Expand Up @@ -660,8 +660,6 @@
int (*local_infile_error)(void *, char *, unsigned int), void *);
void mysql_set_local_infile_default(MYSQL *mysql);
int mysql_dump_debug_info(MYSQL *mysql);
int mysql_refresh(MYSQL *mysql, unsigned int refresh_options);
int mysql_kill(MYSQL *mysql, unsigned long pid);
int mysql_set_server_option(MYSQL *mysql,
enum enum_mysql_set_option option);
int mysql_ping(MYSQL *mysql);
Expand All @@ -674,7 +672,6 @@
unsigned int mysql_get_proto_info(MYSQL *mysql);
MYSQL_RES * mysql_list_dbs(MYSQL *mysql, const char *wild);
MYSQL_RES * mysql_list_tables(MYSQL *mysql, const char *wild);
MYSQL_RES * mysql_list_processes(MYSQL *mysql);
int mysql_options(MYSQL *mysql, enum mysql_option option,
const void *arg);
int mysql_options4(MYSQL *mysql, enum mysql_option option,
Expand All @@ -693,8 +690,6 @@
MYSQL_ROW *row);
unsigned long * mysql_fetch_lengths(MYSQL_RES *result);
MYSQL_FIELD * mysql_fetch_field(MYSQL_RES *result);
MYSQL_RES * mysql_list_fields(MYSQL *mysql, const char *table,
const char *wild);
unsigned long mysql_escape_string(char *to, const char *from,
unsigned long from_length);
unsigned long mysql_hex_string(char *to, const char *from,
Expand Down
18 changes: 0 additions & 18 deletions include/mysql/com_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ struct COM_INIT_DB_DATA {
unsigned long length;
};

struct COM_REFRESH_DATA {
unsigned char options;
};

struct COM_KILL_DATA {
unsigned long id;
};

struct COM_SET_OPTION_DATA {
unsigned int opt_command;
};
Expand Down Expand Up @@ -101,17 +93,8 @@ struct COM_QUERY_DATA {
unsigned long parameter_count;
};

struct COM_FIELD_LIST_DATA {
unsigned char *table_name;
unsigned int table_name_length;
const unsigned char *query;
unsigned int query_length;
};

union COM_DATA {
COM_INIT_DB_DATA com_init_db;
COM_REFRESH_DATA com_refresh;
COM_KILL_DATA com_kill;
COM_SET_OPTION_DATA com_set_option;
COM_STMT_EXECUTE_DATA com_stmt_execute;
COM_STMT_FETCH_DATA com_stmt_fetch;
Expand All @@ -120,7 +103,6 @@ union COM_DATA {
COM_STMT_CLOSE_DATA com_stmt_close;
COM_STMT_RESET_DATA com_stmt_reset;
COM_QUERY_DATA com_query;
COM_FIELD_LIST_DATA com_field_list;
};

#endif /* PLUGIN_PROTOCOL_INCLUDED */
10 changes: 5 additions & 5 deletions include/mysql/plugin_audit.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@
COM_QUIT,
COM_INIT_DB,
COM_QUERY,
COM_FIELD_LIST,
COM_UNUSED_3,
COM_CREATE_DB,
COM_DROP_DB,
COM_REFRESH,
COM_DEPRECATED_1,
COM_UNUSED_2,
COM_UNUSED_1,
COM_STATISTICS,
COM_PROCESS_INFO,
COM_UNUSED_4,
COM_CONNECT,
COM_PROCESS_KILL,
COM_UNUSED_5,
COM_DEBUG,
COM_PING,
COM_TIME,
Expand Down
15 changes: 0 additions & 15 deletions include/mysql/services.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
const char *db_name;
unsigned long length;
};
struct COM_REFRESH_DATA {
unsigned char options;
};
struct COM_KILL_DATA {
unsigned long id;
};
struct COM_SET_OPTION_DATA {
unsigned int opt_command;
};
Expand Down Expand Up @@ -55,16 +49,8 @@
PS_PARAM *parameters;
unsigned long parameter_count;
};
struct COM_FIELD_LIST_DATA {
unsigned char *table_name;
unsigned int table_name_length;
const unsigned char *query;
unsigned int query_length;
};
union COM_DATA {
COM_INIT_DB_DATA com_init_db;
COM_REFRESH_DATA com_refresh;
COM_KILL_DATA com_kill;
COM_SET_OPTION_DATA com_set_option;
COM_STMT_EXECUTE_DATA com_stmt_execute;
COM_STMT_FETCH_DATA com_stmt_fetch;
Expand All @@ -73,7 +59,6 @@
COM_STMT_CLOSE_DATA com_stmt_close;
COM_STMT_RESET_DATA com_stmt_reset;
COM_QUERY_DATA com_query;
COM_FIELD_LIST_DATA com_field_list;
};
#include "mysql/service_srv_session.h"
#include "mysql/service_srv_session_bits.h"
Expand Down
4 changes: 2 additions & 2 deletions include/mysql_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@
#define UNUSED_8 \
8 /**< Previously REFRESH_HOSTS but not used anymore. Use TRUNCATE TABLE \
performance_schema.host_cache instead */
#define REFRESH_STATUS 16 /**< Flush status variables, FLUSH STATUS */
#define REFRESH_THREADS 32 /**< Flush thread cache */
#define REFRESH_STATUS 16 /**< Flush status variables, FLUSH STATUS */
#define UNUSED_32 32 /**< Removed. Used to be flush thread cache */
#define REFRESH_REPLICA \
64 /**< Reset source info and restart replica \
thread, RESET REPLICA */
Expand Down
4 changes: 0 additions & 4 deletions libmysql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ SET(CLIENT_API_FUNCTIONS
mysql_info
mysql_init
mysql_insert_id
mysql_kill
mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_more_results
mysql_next_result
Expand All @@ -85,7 +82,6 @@ SET(CLIENT_API_FUNCTIONS
mysql_real_escape_string
mysql_real_escape_string_quote
mysql_real_query
mysql_refresh
mysql_rollback
mysql_row_seek
mysql_row_tell
Expand Down
Loading

0 comments on commit 15d9b4d

Please sign in to comment.