diff --git a/client/mysql.cc b/client/mysql.cc index 99eb463bec15..1550e2e473f7 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -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)))) { diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 763b856dc0e6..134b02b2d5ce 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -153,7 +153,6 @@ enum commands { ADMIN_FLUSH_PRIVILEGES, ADMIN_START_REPLICA, ADMIN_STOP_REPLICA, - ADMIN_FLUSH_THREADS, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE }; @@ -178,7 +177,6 @@ static const char *command_names[] = {"create", "flush-privileges", "start-replica", "stop-replica", - "flush-threads", "start-slave", "stop-slave", NullS}; @@ -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; @@ -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); diff --git a/client/mysqldump.cc b/client/mysqldump.cc index f745488bb17e..cadb539eefd3 100644 --- a/client/mysqldump.cc +++ b/client/mysqldump.cc @@ -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"); @@ -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"); @@ -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"); } @@ -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; } diff --git a/client/mysqlshow.cc b/client/mysqlshow.cc index 0fa317d38635..206c850d34cf 100644 --- a/client/mysqlshow.cc +++ b/client/mysqlshow.cc @@ -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; @@ -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"); diff --git a/include/my_command.h b/include/my_command.h index d38c9feaa77f..c38edb19874c 100644 --- a/include/my_command.h +++ b/include/my_command.h @@ -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 */ diff --git a/include/mysql.h b/include/mysql.h index b7658399622d..eee75f820fa1 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -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; @@ -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); @@ -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, @@ -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, @@ -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, diff --git a/include/mysql.h.pp b/include/mysql.h.pp index cfeffc9aff9c..c9255b05bd74 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -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, @@ -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); @@ -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, @@ -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, diff --git a/include/mysql/com_data.h b/include/mysql/com_data.h index 21cc0cb487b0..1f44770bc8e9 100644 --- a/include/mysql/com_data.h +++ b/include/mysql/com_data.h @@ -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; }; @@ -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; @@ -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 */ diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 39ad07f89901..68e80fea0e45 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -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, diff --git a/include/mysql/services.h.pp b/include/mysql/services.h.pp index a44181f4aeab..c29540937800 100644 --- a/include/mysql/services.h.pp +++ b/include/mysql/services.h.pp @@ -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; }; @@ -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; @@ -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" diff --git a/include/mysql_com.h b/include/mysql_com.h index bb0619e9a20a..780fc2bc3fb7 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -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 */ diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 9bb5a3e912e9..64b7c51f56fd 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -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 @@ -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 diff --git a/libmysql/libmysql.cc b/libmysql/libmysql.cc index ac3fda430cfa..ed135889cfa5 100644 --- a/libmysql/libmysql.cc +++ b/libmysql/libmysql.cc @@ -750,90 +750,6 @@ MYSQL_FIELD *cli_list_fields(MYSQL *mysql) { return result; } -/************************************************************************** - List all fields in a table - If wild is given then only the fields matching wild is returned - Instead of this use query: - show fields in 'table' like "wild" -**************************************************************************/ - -MYSQL_RES *STDCALL mysql_list_fields(MYSQL *mysql, const char *table, - const char *wild) { - MYSQL_RES *result; - MYSQL_FIELD *fields; - MEM_ROOT *new_root; - char buff[258], *end; - DBUG_TRACE; - DBUG_PRINT("enter", ("table: '%s' wild: '%s'", table, wild ? wild : "")); - - end = strmake(strmake(buff, table, 128) + 1, wild ? wild : "", 128); - free_old_query(mysql); - if (simple_command(mysql, COM_FIELD_LIST, (uchar *)buff, (ulong)(end - buff), - 1) || - !(fields = (*mysql->methods->list_fields)(mysql))) - return nullptr; - - if (!(new_root = (MEM_ROOT *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MEM_ROOT), - MYF(MY_WME | MY_ZEROFILL)))) - return nullptr; - if (!(result = (MYSQL_RES *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MYSQL_RES), - MYF(MY_WME | MY_ZEROFILL)))) { - my_free(new_root); - return nullptr; - } - - result->methods = mysql->methods; - result->field_alloc = mysql->field_alloc; - mysql->fields = nullptr; - mysql->field_alloc = new_root; - result->field_count = mysql->field_count; - result->fields = fields; - result->eof = true; - return result; -} - -/* List all running processes (threads) in server */ - -MYSQL_RES *STDCALL mysql_list_processes(MYSQL *mysql) { - uint field_count; - uchar *pos; - DBUG_TRACE; - - if (simple_command(mysql, COM_PROCESS_INFO, nullptr, 0, 0)) return nullptr; - free_old_query(mysql); - pos = (uchar *)mysql->net.read_pos; - field_count = (uint)net_field_length(&pos); - if (!(mysql->fields = - cli_read_metadata(mysql, field_count, protocol_41(mysql) ? 7 : 5))) - return nullptr; - mysql->status = MYSQL_STATUS_GET_RESULT; - mysql->field_count = field_count; - return mysql_store_result(mysql); -} - -int STDCALL mysql_refresh(MYSQL *mysql, uint options) { - uchar bits[1]; - DBUG_TRACE; - bits[0] = (uchar)options; - return simple_command(mysql, COM_REFRESH, bits, 1, 0); -} - -int STDCALL mysql_kill(MYSQL *mysql, ulong pid) { - uchar buff[4]; - DBUG_TRACE; - /* - Sanity check: if ulong is 64-bits, user can submit a PID here that - overflows our 32-bit parameter to the somewhat obsolete COM_PROCESS_KILL. - If this is the case, we'll flag an error here. - The SQL statement KILL CONNECTION is the safer option here. - There is an analog of this failsafe in the server as we might see old - libmysql connection to a new server as well as the other way around. - */ - if (pid & (~0xfffffffful)) return CR_INVALID_CONN_HANDLE; - int4store(buff, pid); - return simple_command(mysql, COM_PROCESS_KILL, buff, sizeof(buff), 0); -} - int STDCALL mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option) { uchar buff[2]; @@ -917,8 +833,6 @@ uint STDCALL mysql_warning_count(MYSQL *mysql) { return mysql->warning_count; } ulong STDCALL mysql_thread_id(MYSQL *mysql) { /* ulong may be 64-bit, but we currently only transmit 32-bit. - mysql_thread_id() is usually used in conjunction with mysql_kill() - which is similarly limited (and obsolete). SELECTION CONNECTION_ID() / KILL CONNECTION avoid this issue. */ return (mysql)->thread_id; diff --git a/libmysql/test_trace_plugin.cc b/libmysql/test_trace_plugin.cc index a6ce7d44a7e4..4978c3915c45 100644 --- a/libmysql/test_trace_plugin.cc +++ b/libmysql/test_trace_plugin.cc @@ -817,20 +817,6 @@ int check_event_READY_FOR_COMMAND(MYSQL *conn, struct st_trace_data *data, case COM_TABLE_DUMP: return 1; - /* - After COM_PROCESS_INFO server sends a regular result set. - */ - case COM_PROCESS_INFO: - NEXT_STAGE(WAIT_FOR_RESULT); - break; - - /* - After COM_FIELD_LIST server directly sends field descriptions. - */ - case COM_FIELD_LIST: - NEXT_STAGE(WAIT_FOR_FIELD_DEF); - break; - /* Server replies to COM_STATISTICS with a single packet containing a string with statistics information. diff --git a/mysql-test/r/mysql_client_test.result b/mysql-test/r/mysql_client_test.result index 81e650e61c05..f888ed2e0c5c 100644 --- a/mysql-test/r/mysql_client_test.result +++ b/mysql-test/r/mysql_client_test.result @@ -140,8 +140,6 @@ TRUNCATE TABLE mysql.slow_log; # First start the server with --initialize # Restart the server against DDIR. # restart: --datadir=DDIR --lower_case_table_names=1 --secure-file-priv= --no-console --log-error=MYSQLD_LOG -# Run the single test. -# Following command would crash if run without fix. # Shutdown server. # Cleanup. # Delete $DDIR. diff --git a/mysql-test/suite/perfschema/r/telemetry_traces_test_client.result b/mysql-test/suite/perfschema/r/telemetry_traces_test_client.result index 0231ea9d786c..3fe85351fd64 100644 --- a/mysql-test/suite/perfschema/r/telemetry_traces_test_client.result +++ b/mysql-test/suite/perfschema/r/telemetry_traces_test_client.result @@ -80,24 +80,6 @@ End of init tm_session_create: telemetry session started, increase refcount by user=root to 2 > tm_stmt_start: proceed further (depth=1, user=root, host=localhost, db=test, query='') > tm_stmt_notify_qa: skip tracing, no qa (depth=1, with_qa=0, user=root, query='') -> tm_stmt_start: proceed further (depth=1, user=root, host=localhost, db=test, query='') - > tm_stmt_notify_qa: skip tracing, no qa (depth=1, with_qa=0, user=root, query='') - tm_session_disconnect: client session ended (user=root) - tm_session_destroy: telemetry session ended, decrease refcount to 1 - tm_session_destroy: failed to get current THD - tm_session_connect: client session started (user=root) - tm_session_create: telemetry session started, increase refcount by user=root to 2 -> tm_stmt_start: proceed further (depth=1, user=root, host=localhost, db=test, query='') - > tm_stmt_notify_qa: skip tracing, no qa (depth=1, with_qa=0, user=root, query='') -> tm_stmt_start: proceed further (depth=1, user=root, host=localhost, db=test, query='') - > tm_stmt_notify_qa: skip tracing, no qa (depth=1, with_qa=0, user=root, query='') - tm_session_disconnect: client session ended (user=root) - tm_session_destroy: telemetry session ended, decrease refcount to 1 - tm_session_destroy: failed to get current THD - tm_session_connect: client session started (user=root) - tm_session_create: telemetry session started, increase refcount by user=root to 2 -> tm_stmt_start: proceed further (depth=1, user=root, host=localhost, db=test, query='') - > tm_stmt_notify_qa: skip tracing, no qa (depth=1, with_qa=0, user=root, query='') > tm_stmt_start: proceed further (depth=1, user=root, host=localhost, db=test, query='') > tm_stmt_notify_qa: skip tracing, no qa (depth=1, with_qa=0, user=root, query='') tm_session_disconnect: client session ended (user=root) diff --git a/mysql-test/suite/test_service_sql_api/r/test_sql_cmds_1.result b/mysql-test/suite/test_service_sql_api/r/test_sql_cmds_1.result index e8ac6fb38d7e..b15a783ec276 100644 --- a/mysql-test/suite/test_service_sql_api/r/test_sql_cmds_1.result +++ b/mysql-test/suite/test_service_sql_api/r/test_sql_cmds_1.result @@ -29,10 +29,6 @@ srv_session_close. current_db before init_db : (null) current_db after init_db : mysql ====================================================== -COM_KILL -session is dead? 0 -session is dead now? 1053 -====================================================== test_query_kill session is dead? 0 Executing select sleep(10) diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 4fc957a675dd..0f2a4c3e5f6e 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -72,10 +72,6 @@ EOF --replace_result $DDIR DDIR $MYSQLD_LOG MYSQLD_LOG --source include/start_mysqld.inc ---echo # Run the single test. ---echo # Following command would crash if run without fix. ---exec $MYSQL_CLIENT_TEST test_bug24963580 >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 - --echo # Shutdown server. --let $shutdown_server_timeout= 300 --source include/shutdown_mysqld.inc diff --git a/plugin/group_replication/src/sql_service/sql_service_command.cc b/plugin/group_replication/src/sql_service/sql_service_command.cc index 7503f2fafb5b..062be728a084 100644 --- a/plugin/group_replication/src/sql_service/sql_service_command.cc +++ b/plugin/group_replication/src/sql_service/sql_service_command.cc @@ -137,16 +137,18 @@ long Sql_service_commands::internal_kill_session( Sql_resultset rset; long srv_err = 0; if (!sql_interface->is_session_killed(sql_interface->get_session())) { - COM_DATA data; - data.com_kill.id = *((unsigned long *)session_id); - srv_err = sql_interface->execute(data, COM_PROCESS_KILL, &rset); + std::stringstream str; + str << "KILL " << *((unsigned long *)session_id); + srv_err = sql_interface->execute_query(str.str()); if (srv_err == 0) { LogPluginErr( - INFORMATION_LEVEL, ER_GRP_RPL_KILLED_SESSION_ID, data.com_kill.id, + INFORMATION_LEVEL, ER_GRP_RPL_KILLED_SESSION_ID, + (int)*((unsigned long *)session_id), sql_interface->is_session_killed(sql_interface->get_session())); } else { LogPluginErr(INFORMATION_LEVEL, ER_GRP_RPL_KILLED_FAILED_ID, - data.com_kill.id, srv_err); /* purecov: inspected */ + (int)*((unsigned long *)session_id), + srv_err); /* purecov: inspected */ } } return srv_err; diff --git a/plugin/test_service_sql_api/test_sql_cmds_1.cc b/plugin/test_service_sql_api/test_sql_cmds_1.cc index aaa1eedd1f83..642778a8a659 100644 --- a/plugin/test_service_sql_api/test_sql_cmds_1.cc +++ b/plugin/test_service_sql_api/test_sql_cmds_1.cc @@ -478,49 +478,6 @@ static int test_com_init_db(void *p) { return 0; } -/* -static int test_com_list_fields(void *p) -{ - DBUG_TRACE; - - MYSQL_SESSION st_session; - - ENSURE_API_NOT_NULL(st_session = srv_session_open(NULL, p)); - - COM_DATA cmd; - - cmd.com_init_db.db_name = "mysql"; - cmd.com_init_db.length = strlen("mysql"); - ENSURE_API_OK(command_service_run_command(st_session, COM_INIT_DB, &cmd, -&my_charset_utf8mb3_general_ci, &sql_cbs, CS_TEXT_REPRESENTATION, p)); - - WRITE_VAL("switched default db to: %s\n", -srv_session_info_get_current_db(st_session)); - - - WRITE_STR("field_list\n"); - cmd.com_field_list.table_name = (unsigned char*)"user"; - cmd.com_field_list.table_name_length = strlen((const -char*)cmd.com_field_list.table_name); cmd.com_field_list.query = (unsigned -char*)"%"; cmd.com_field_list.query_length = strlen((const -char*)cmd.com_field_list.query); - ENSURE_API_OK(command_service_run_command(st_session, COM_FIELD_LIST, &cmd, -&my_charset_utf8mb3_general_ci, &sql_cbs, CS_TEXT_REPRESENTATION, p)); - - WRITE_STR("-----------------------------------------------------------------\n"); - for (uint row_count=0;row_count < sql_num_rows;row_count++){ - for (uint col_count=0;col_count < sql_num_cols;col_count+=2){ - WRITE_VAL("%s\t\%s\n",sql_str_value[col_count][row_count], - sql_str_value[col_count+1][row_count]); - } - } - - ENSURE_API_OK(srv_session_close(st_session)); - - return 0; -} -*/ - struct Test_data { void *p; MYSQL_SESSION session; @@ -660,40 +617,6 @@ static int test_query_kill(void *p) { return 0; } -static int test_com_process_kill(void *p) { - DBUG_TRACE; - - MYSQL_SESSION st_session; - Callback_data cbd; - - WRITE_STR("COM_KILL\n"); - - ENSURE_API_NOT_NULL(st_session = srv_session_open(nullptr, p)); - - switch_user(st_session, user_privileged); - MYSQL_SESSION st_session_victim; - ENSURE_API_NOT_NULL(st_session_victim = - srv_session_open(session_error_cb, p)); - - WRITE_VAL("session is dead? %i\n", - thd_killed(srv_session_info_get_thd(st_session_victim))); - - COM_DATA cmd; - - cmd.com_kill.id = srv_session_info_get_session_id(st_session_victim); - ENSURE_API_OK(command_service_run_command( - st_session, COM_PROCESS_KILL, &cmd, &my_charset_utf8mb3_general_ci, - &sql_cbs, CS_TEXT_REPRESENTATION, &cbd)); - - WRITE_VAL("session is dead now? %i\n", - thd_killed(srv_session_info_get_thd(st_session_victim))); - - ENSURE_API_OK(srv_session_close(st_session)); - ENSURE_API_OK(srv_session_close(st_session_victim)); - - return 0; -} - static int test_priv(void *p) { DBUG_TRACE; @@ -758,10 +681,6 @@ static void test_sql(void *p [[maybe_unused]]) { WRITE_SEP(); test_com_init_db(p); WRITE_SEP(); - // test_com_list_fields(p); - // WRITE_SEP(); - test_com_process_kill(p); - WRITE_SEP(); test_query_kill(p); WRITE_SEP(); test_priv(p); diff --git a/router/src/routing/tests/mysql_client.h b/router/src/routing/tests/mysql_client.h index 83bcabaf622b..46e967a104d1 100644 --- a/router/src/routing/tests/mysql_client.h +++ b/router/src/routing/tests/mysql_client.h @@ -488,26 +488,6 @@ class MysqlClient { return {}; } - stdx::expected refresh(unsigned int options = 0) { - const auto r = mysql_refresh(m_.get(), options); - - if (r != 0) { - return stdx::make_unexpected(make_mysql_error_code(m_.get())); - } - - return {}; - } - - stdx::expected reload() { - const auto r = mysql_reload(m_.get()); - - if (r != 0) { - return stdx::make_unexpected(make_mysql_error_code(m_.get())); - } - - return {}; - } - stdx::expected shutdown() { const auto r = mysql_query(m_.get(), "SHUTDOWN"); @@ -518,16 +498,6 @@ class MysqlClient { return {}; } - stdx::expected kill(uint32_t id) { - const auto r = mysql_kill(m_.get(), id); - - if (r != 0) { - return stdx::make_unexpected(make_mysql_error_code(m_.get())); - } - - return {}; - } - stdx::expected stat() { const auto r = mysql_stat(m_.get()); @@ -895,17 +865,6 @@ class MysqlClient { return {std::in_place, m_.get(), res}; } - stdx::expected list_fields( - std::string tablename) { - const auto res = mysql_list_fields(m_.get(), tablename.c_str(), nullptr); - - if (res == nullptr) { - return stdx::make_unexpected(make_mysql_error_code(m_.get())); - } - - return {std::in_place, m_.get(), res}; - } - stdx::expected query( std::string_view stmt, const stdx::span ¶ms, const stdx::span &names) { diff --git a/router/tests/helpers/shared_server.cc b/router/tests/helpers/shared_server.cc index dff023828d51..90d35f817b45 100644 --- a/router/tests/helpers/shared_server.cc +++ b/router/tests/helpers/shared_server.cc @@ -442,7 +442,7 @@ stdx::expected SharedServer::close_all_connections( if (!ids_res) return stdx::make_unexpected(ids_res.error()); for (auto id : *ids_res) { - auto kill_res = cli.kill(id); + auto kill_res = cli.query("KILL " + std::to_string(id)); // either it succeeds or "Unknown thread id" because it closed itself // between the SELECT and this kill diff --git a/router/tests/integration/test_routing_direct.cc b/router/tests/integration/test_routing_direct.cc index 997b5589c08a..411d170a8ead 100644 --- a/router/tests/integration/test_routing_direct.cc +++ b/router/tests/integration/test_routing_direct.cc @@ -724,65 +724,6 @@ class ConnectionTestBase : public RouterComponentTest { class ConnectionTest : public ConnectionTestBase, public ::testing::WithParamInterface {}; -// check that CMD_KILL opens a new connection to the server. -TEST_P(ConnectionTest, classic_protocol_kill_zero) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - SCOPED_TRACE("// killing connection 0"); - { - auto kill_res = cli.kill(0); - ASSERT_ERROR(kill_res); - EXPECT_EQ(kill_res.error().value(), 1094) << kill_res.error(); - // unknown thread id. - } - - SCOPED_TRACE("// ping after kill"); - - // nothing was killed and PING should just work. - ASSERT_NO_ERROR(cli.ping()); -} - -TEST_P(ConnectionTest, classic_protocol_kill_current_connection) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - auto connection_id_res = fetch_connection_id(cli); - ASSERT_NO_ERROR(connection_id_res); - - auto connection_id = connection_id_res.value(); - - SCOPED_TRACE("// killing connection " + std::to_string(connection_id)); - { - auto kill_res = cli.kill(connection_id); - ASSERT_ERROR(kill_res); - EXPECT_EQ(kill_res.error().value(), 1317) << kill_res.error(); - // Query execution was interrupted - } - - EXPECT_NO_ERROR(shared_router()->wait_for_num_connections(GetParam(), 0, 1s)); - - SCOPED_TRACE("// ping after kill"); - { - auto ping_res = cli.ping(); - ASSERT_ERROR(ping_res); - EXPECT_EQ(ping_res.error().value(), 2013) << ping_res.error(); - // Lost connection to MySQL server during query - } -} - TEST_P(ConnectionTest, classic_protocol_wait_timeout) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; @@ -860,39 +801,6 @@ TEST_P(ConnectionTest, classic_protocol_list_dbs) { ASSERT_NO_ERROR(cli.list_dbs()); } -TEST_P(ConnectionTest, classic_protocol_list_fields_succeeds) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - cli.use_schema("mysql"); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - auto cmd_res = cli.list_fields("user"); - ASSERT_NO_ERROR(cmd_res); -} - -TEST_P(ConnectionTest, classic_protocol_list_fields_fails) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - cli.use_schema("mysql"); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - { - auto cmd_res = cli.list_fields("does_not_exist"); - ASSERT_ERROR(cmd_res); - EXPECT_EQ(cmd_res.error().value(), 1146) << cmd_res.error(); - } -} - TEST_P(ConnectionTest, classic_protocol_change_user_native_empty) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; @@ -1324,40 +1232,6 @@ TEST_P(ConnectionTest, classic_protocol_debug_fails) { } } -TEST_P(ConnectionTest, classic_protocol_refresh) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - EXPECT_NO_ERROR(cli.refresh()); - - EXPECT_NO_ERROR(cli.refresh()); -} - -TEST_P(ConnectionTest, classic_protocol_refresh_fail) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - auto account = SharedServer::native_empty_password_account(); - cli.username(account.username); - cli.password(account.password); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - { - auto cmd_res = cli.refresh(); - ASSERT_ERROR(cmd_res); - - EXPECT_EQ(cmd_res.error().value(), 1227); // Access Denied - } -} - TEST_P(ConnectionTest, classic_protocol_reset_connection) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; diff --git a/router/tests/integration/test_routing_reuse.cc b/router/tests/integration/test_routing_reuse.cc index 675aada776a7..ec1425e01183 100644 --- a/router/tests/integration/test_routing_reuse.cc +++ b/router/tests/integration/test_routing_reuse.cc @@ -843,39 +843,6 @@ TEST_P(ReuseConnectionTest, classic_protocol_debug_fails) { } } -TEST_P(ReuseConnectionTest, classic_protocol_kill) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - auto connect_res = - cli.connect(shared_router_->host(), shared_router_->port(GetParam())); - ASSERT_NO_ERROR(connect_res); - - auto connection_id_res = fetch_connection_id(cli); - ASSERT_NO_ERROR(connection_id_res); - - auto connection_id = connection_id_res.value(); - - SCOPED_TRACE("// killing connection " + std::to_string(connection_id)); - { - auto kill_res = cli.kill(connection_id); - ASSERT_ERROR(kill_res); - EXPECT_EQ(kill_res.error().value(), 1317) << kill_res.error(); - // Query execution was interrupted - } - - SCOPED_TRACE("// ping after kill"); - { - auto ping_res = cli.ping(); - ASSERT_ERROR(ping_res); - EXPECT_EQ(ping_res.error().value(), 2013) << ping_res.error(); - // Lost connection to MySQL server during query - } -} - TEST_P(ReuseConnectionTest, classic_protocol_kill_via_select) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; @@ -910,22 +877,6 @@ TEST_P(ReuseConnectionTest, classic_protocol_kill_via_select) { } } -TEST_P(ReuseConnectionTest, classic_protocol_kill_fail) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - auto connect_res = - cli.connect(shared_router_->host(), shared_router_->port(GetParam())); - ASSERT_NO_ERROR(connect_res); - - auto kill_res = cli.kill(0); // should fail. - ASSERT_FALSE(kill_res); - EXPECT_EQ(kill_res.error().value(), 1094); // Unknown thread id: 0 -} - TEST_P(ReuseConnectionTest, classic_protocol_change_user_native_empty) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; @@ -1108,20 +1059,6 @@ TEST_P(ReuseConnectionTest, classic_protocol_statistics) { EXPECT_NO_ERROR(cli.stat()); } -TEST_P(ReuseConnectionTest, classic_protocol_refresh) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - auto connect_res = - cli.connect(shared_router_->host(), shared_router_->port(GetParam())); - ASSERT_NO_ERROR(connect_res); - - EXPECT_NO_ERROR(cli.refresh()); -} - TEST_P(ReuseConnectionTest, classic_protocol_reset_connection) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; diff --git a/router/tests/integration/test_routing_sharing.cc b/router/tests/integration/test_routing_sharing.cc index 51075b9002a6..e7965ff709fa 100644 --- a/router/tests/integration/test_routing_sharing.cc +++ b/router/tests/integration/test_routing_sharing.cc @@ -1250,7 +1250,7 @@ TEST_P(ShareConnectionTest, classic_protocol_purge_after_connect_same_user) { EXPECT_THAT(ids, ::testing::SizeIs(1)); for (auto id : ids) { - ASSERT_NO_ERROR(srv_cli->kill(id)); + ASSERT_NO_ERROR(srv_cli->query("KILL " + std::to_string(id))); cli_ids[ndx] = std::make_pair(s->server_port(), id); } @@ -2172,65 +2172,6 @@ TEST_P(ShareConnectionTest, classic_protocol_server_status_after_command) { } } -// check that CMD_KILL opens a new connection to the server. -TEST_P(ShareConnectionTest, classic_protocol_kill_zero) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - SCOPED_TRACE("// killing connection 0"); - { - auto kill_res = cli.kill(0); - ASSERT_ERROR(kill_res); - EXPECT_EQ(kill_res.error().value(), 1094) << kill_res.error(); - // unknown thread id. - } - - SCOPED_TRACE("// ping after kill"); - - // nothing was killed and PING should open a new connection. - ASSERT_NO_ERROR(cli.ping()); -} - -TEST_P(ShareConnectionTest, classic_protocol_kill_current_connection) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - ASSERT_NO_ERROR(cli.query("BEGIN")); - - auto connection_id_res = fetch_connection_id(cli); - ASSERT_NO_ERROR(connection_id_res); - - auto connection_id = connection_id_res.value(); - - SCOPED_TRACE("// killing connection " + std::to_string(connection_id)); - { - auto kill_res = cli.kill(connection_id); - ASSERT_ERROR(kill_res); - EXPECT_EQ(kill_res.error().value(), 1317) << kill_res.error(); - // Query execution was interrupted - } - - SCOPED_TRACE("// ping after kill"); - { - auto ping_res = cli.ping(); - ASSERT_ERROR(ping_res); - EXPECT_EQ(ping_res.error().value(), 2013) << ping_res.error(); - // Lost connection to MySQL server during query - } -} - TEST_P(ShareConnectionTest, classic_protocol_kill_via_select) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; @@ -2266,21 +2207,6 @@ TEST_P(ShareConnectionTest, classic_protocol_kill_via_select) { } } -TEST_P(ShareConnectionTest, classic_protocol_kill_fail) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - auto kill_res = cli.kill(0); // should fail. - ASSERT_ERROR(kill_res); - EXPECT_EQ(kill_res.error().value(), 1094); // Unknown thread id: 0 -} - TEST_P(ShareConnectionTest, classic_protocol_list_dbs) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; @@ -2294,41 +2220,6 @@ TEST_P(ShareConnectionTest, classic_protocol_list_dbs) { ASSERT_NO_ERROR(cli.list_dbs()); } -// cmd_list_fields -> err -TEST_P(ShareConnectionTest, classic_protocol_list_fields_succeeds) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - cli.use_schema("mysql"); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - auto cmd_res = cli.list_fields("user"); - ASSERT_NO_ERROR(cmd_res); -} - -// cmd_list_fields -> ok -TEST_P(ShareConnectionTest, classic_protocol_list_fields_fails) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - cli.use_schema("mysql"); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - { - auto cmd_res = cli.list_fields("does_not_exist"); - ASSERT_ERROR(cmd_res); - EXPECT_EQ(cmd_res.error().value(), 1146) << cmd_res.error(); - } -} - TEST_P(ShareConnectionTest, classic_protocol_change_user_caching_sha2_with_attributes_with_pool) { // reset auth-cache for caching-sha2-password @@ -2488,40 +2379,6 @@ TEST_P(ShareConnectionTest, classic_protocol_statistics) { EXPECT_NO_ERROR(cli.stat()); } -TEST_P(ShareConnectionTest, classic_protocol_refresh) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - EXPECT_NO_ERROR(cli.refresh()); - - EXPECT_NO_ERROR(cli.refresh()); -} - -TEST_P(ShareConnectionTest, classic_protocol_refresh_fail) { - SCOPED_TRACE("// connecting to server"); - MysqlClient cli; - - auto account = SharedServer::native_empty_password_account(); - cli.username(account.username); - cli.password(account.password); - - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - { - auto cmd_res = cli.refresh(); - ASSERT_ERROR(cmd_res); - - EXPECT_EQ(cmd_res.error().value(), 1227); // Access Denied - } -} - TEST_P(ShareConnectionTest, classic_protocol_reset_connection) { SCOPED_TRACE("// connecting to server"); MysqlClient cli; diff --git a/router/tests/integration/test_routing_sharing_constrained_pools.cc b/router/tests/integration/test_routing_sharing_constrained_pools.cc index 308b6df69f70..c56db02bd552 100644 --- a/router/tests/integration/test_routing_sharing_constrained_pools.cc +++ b/router/tests/integration/test_routing_sharing_constrained_pools.cc @@ -1760,51 +1760,6 @@ TEST_P(ShareConnectionTinyPoolOneServerTest, } } -/* - * test the cmd_kill -> Ok path - * - * using one-server to ensure both connections end up on the same backend. - */ -TEST_P(ShareConnectionTinyPoolOneServerTest, - classic_protocol_kill_other_connection) { - SCOPED_TRACE("// connecting to server"); - - // open two connections on the same server: - // - // - one to be killed - // - one to kill - std::array clis; - std::array conn_ids; - - for (auto [ndx, cli] : stdx::views::enumerate(clis)) { - cli.username("root"); - cli.password(""); - - ASSERT_NO_ERROR(cli.connect(shared_router()->host(), - shared_router()->port(GetParam()))); - - // block the connection to ensure that even with connection-sharing, a new - // connection gets opened that can be successfully killed. - ASSERT_NO_ERROR(cli.query("SET @block_connection = 1")); - - auto conn_id_res = query_one<1>(cli, "SELECT CONNECTION_ID()"); - ASSERT_NO_ERROR(conn_id_res); - - auto conn_num_res = from_string((*conn_id_res)[0]); - ASSERT_NO_ERROR(conn_num_res); - - conn_ids[ndx] = *conn_num_res; - } - - // there should be no pooling. - ASSERT_NE(conn_ids[0], conn_ids[1]); - - ASSERT_NO_ERROR(clis[0].kill(conn_ids[1])); - - // should fail as connection is killed. - ASSERT_ERROR(clis[1].query("DO 1")); -} - /* * test the cmd_kill -> Ok path * @@ -1837,7 +1792,7 @@ TEST_P(ShareConnectionTinyPoolOneServerTest, auto conn_num_res = from_string((*conn_id_res)[0]); ASSERT_NO_ERROR(conn_num_res); - ASSERT_NO_ERROR(admin_cli.kill(*conn_num_res)); + ASSERT_NO_ERROR(admin_cli.query("KILL " + std::to_string(*conn_num_res))); ASSERT_NO_ERROR(admin_cli.query("SET PASSWORD FOR changeme='changeme2'")); diff --git a/router/tests/integration/test_routing_splitting.cc b/router/tests/integration/test_routing_splitting.cc index cec96eb1992c..aa3f2dbe48a3 100644 --- a/router/tests/integration/test_routing_splitting.cc +++ b/router/tests/integration/test_routing_splitting.cc @@ -2087,78 +2087,6 @@ TEST_P(SplittingConnectionTest, ping_succeeds) { } } -TEST_P(SplittingConnectionTest, list_fields_succeeds) { - RecordProperty("Worklog", "12794"); - RecordProperty("RequirementId", "FR9.2"); - RecordProperty("Requirement", - "If `access_mode` is 'auto' and the client sends a " - "a list-fields command, Router MUST target the current host"); - - MysqlClient cli; - - auto account = SharedServer::caching_sha2_empty_password_account(); - - cli.username(account.username); - cli.password(account.password); - cli.use_schema("testing"); - - // may start on the primary or secondary. - ASSERT_NO_ERROR( - cli.connect(shared_router()->host(), shared_router()->port(GetParam()))); - - // a noop statement which switches to the primary. - ASSERT_NO_ERROR(cli.query("TRUNCATE TABLE testing.t1")); - - SCOPED_TRACE("// list-fields from primary"); - ASSERT_NO_ERROR(cli.list_fields("t1")); - - // executed on the secondary: - // - // - SET trackers - // - SELECT @@super_read_only - // - SELECT * FROM performance_schema... [not seen by this query] - { - auto events_res = changed_event_counters(cli); - ASSERT_NO_ERROR(events_res); - - EXPECT_THAT(*events_res, - AnyOf( - // started on read-write - ElementsAre(Pair("statement/sql/select", 2), - Pair("statement/sql/set_option", 1)), - // started on read-only - ElementsAre(Pair("statement/com/Reset Connection", 1), - Pair("statement/sql/select", 4), - Pair("statement/sql/set_option", 2)))); - } - - SCOPED_TRACE("// list-fields from secondary"); - ASSERT_NO_ERROR(cli.list_fields("t1")); - - // executed on the secondary: - // - // - SET trackers - // - SELECT @@super_read_only - // - SELECT * FROM performance_schema... [not seen by this query] - { - auto events_res = changed_event_counters(cli); - ASSERT_NO_ERROR(events_res); - - EXPECT_THAT(*events_res, - AnyOf( - // started on read-write - ElementsAre(Pair("statement/com/Field List", 1), - Pair("statement/com/Reset Connection", 2), - Pair("statement/sql/select", 7), - Pair("statement/sql/set_option", 3)), - // started on read-only - ElementsAre(Pair("statement/com/Field List", 1), - Pair("statement/com/Reset Connection", 3), - Pair("statement/sql/select", 9), - Pair("statement/sql/set_option", 4)))); - } -} - TEST_P(SplittingConnectionTest, set_option_succeeds) { RecordProperty("Worklog", "12794"); RecordProperty("RequirementId", "FR9.3"); diff --git a/router/tests/integration/test_routing_tracing.cc b/router/tests/integration/test_routing_tracing.cc index fd2023b802ed..bc6f79bf87d2 100644 --- a/router/tests/integration/test_routing_tracing.cc +++ b/router/tests/integration/test_routing_tracing.cc @@ -192,27 +192,6 @@ stdx::expected, MysqlError> query_one( return out; } -static stdx::expected fetch_connection_id( - MysqlClient &cli) { - auto query_res = cli.query("SELECT connection_id()"); - if (!query_res) return query_res.get_unexpected(); - - // get the first field, of the first row of the first resultset. - for (const auto &result : *query_res) { - if (result.field_count() == 0) { - return stdx::make_unexpected(MysqlError(1, "not a resultset", "HY000")); - } - - for (auto row : result.rows()) { - auto connection_id = strtoull(row[0], nullptr, 10); - - return connection_id; - } - } - - return stdx::make_unexpected(MysqlError(1, "no rows", "HY000")); -} - struct ConnectionParam { std::string testname; @@ -1189,112 +1168,6 @@ const TracingCommandParam tracing_command_params[] = { } else { EXPECT_EQ(*warning_count_res, 0); - TracingTestBase::assert_warnings_no_trace(cli); - } - }}, - {"kill_ok", false, false, - [](const ConnectionParam &connect_param, MysqlClient &cli, - TracingCommandParam::Env env) { - const bool can_trace = connect_param.can_trace(); - - auto account = SharedServer::native_empty_password_account(); - - MysqlClient cli2; - - cli2.username(account.username); - cli2.password(account.password); - - auto *shared_router = TracingTestBase::shared_router(); - - ASSERT_NO_ERROR(cli2.connect(shared_router->host(), - shared_router->port(connect_param))); - - cli2.query("BEGIN"); // block the sharing to ensure that the kill really - // hits _this_ connection. - - auto connection_id_res = fetch_connection_id(cli2); - ASSERT_NO_ERROR(connection_id_res); - - auto connection_id = *connection_id_res; - - // kill the server connection. - ASSERT_NO_ERROR(cli.kill(connection_id)); - - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - if (can_trace && env.trace_enabled) { - EXPECT_EQ(*warning_count_res, 2); // deprecated + trace - - auto trace_res = TracingTestBase::get_trace(cli); - ASSERT_TRUE(trace_res); - - auto json_trace = *trace_res; - - rapidjson::Document doc; - doc.Parse(json_trace.data(), json_trace.size()); - ASSERT_TRUE(TracingTestBase::trace_is_valid(doc)); - - for (const auto &[pntr, val] : { - std::pair{"/name", rapidjson::Value("mysql/kill")}, - std::pair{"/attributes/mysql.sharing_blocked", - rapidjson::Value(env.expected_sharing_is_blocked)}, - std::pair{"/events/0/name", - rapidjson::Value("mysql/connect_and_forward")}, - std::pair{"/events/0/attributes/mysql.remote.is_connected", - rapidjson::Value(env.expected_is_connected)}, - }) { - ASSERT_TRUE(TracingTestBase::json_pointer_eq( - doc, rapidjson::Pointer(pntr), val)) - << json_trace; - } - } else { - EXPECT_EQ(*warning_count_res, 1); // deprecated - - TracingTestBase::assert_warnings_no_trace(cli); - } - }}, - {"kill_fail", false, false, - [](const ConnectionParam &connect_param, MysqlClient &cli, - TracingCommandParam::Env env) { - const bool can_trace = connect_param.can_trace(); - - auto cmd_res = cli.kill(0); - ASSERT_ERROR(cmd_res); - EXPECT_EQ(cmd_res.error().value(), 1094) << cmd_res.error(); - - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - if (can_trace && env.trace_enabled) { - EXPECT_EQ(*warning_count_res, 0); - - auto trace_res = TracingTestBase::get_trace(cli); - ASSERT_TRUE(trace_res); - - auto json_trace = *trace_res; - - rapidjson::Document doc; - doc.Parse(json_trace.data(), json_trace.size()); - ASSERT_TRUE(TracingTestBase::trace_is_valid(doc)); - - for (const auto &[pntr, val] : { - std::pair{"/name", rapidjson::Value("mysql/kill")}, - std::pair{"/status_code", rapidjson::Value("ERROR")}, - std::pair{"/attributes/mysql.sharing_blocked", - rapidjson::Value(env.expected_sharing_is_blocked)}, - std::pair{"/events/0/name", - rapidjson::Value("mysql/connect_and_forward")}, - std::pair{"/events/0/attributes/mysql.remote.is_connected", - rapidjson::Value(env.expected_is_connected)}, - }) { - ASSERT_TRUE(TracingTestBase::json_pointer_eq( - doc, rapidjson::Pointer(pntr), val)) - << json_trace; - } - } else { - EXPECT_EQ(*warning_count_res, 0); - TracingTestBase::assert_warnings_no_trace(cli); } }}, @@ -1707,97 +1580,6 @@ const TracingCommandParam tracing_command_params[] = { } else { EXPECT_EQ(*warning_count_res, 0); - TracingTestBase::assert_warnings_no_trace(cli); - } - }}, - {"list_fields_ok", false, false, - [](const ConnectionParam &connect_param, MysqlClient &cli, - TracingCommandParam::Env env) { - const bool can_trace = connect_param.can_trace(); - - cli.use_schema("performance_schema"); - - auto cmd_res = cli.list_fields("processlist"); - ASSERT_NO_ERROR(cmd_res); - - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - // Bug#... warnings are there but no warning count. - if (can_trace && env.trace_enabled) { - EXPECT_EQ(*warning_count_res, 1); // trace (+ deprecated) - - auto trace_res = TracingTestBase::get_trace(cli); - ASSERT_TRUE(trace_res); - - auto json_trace = *trace_res; - - rapidjson::Document doc; - doc.Parse(json_trace.data(), json_trace.size()); - ASSERT_TRUE(TracingTestBase::trace_is_valid(doc)); - - for (const auto &[pntr, val] : { - std::pair{"/name", rapidjson::Value("mysql/list_fields")}, - std::pair{"/attributes/mysql.sharing_blocked", - rapidjson::Value(env.expected_sharing_is_blocked)}, - std::pair{"/events/0/name", - rapidjson::Value("mysql/connect_and_forward")}, - std::pair{"/events/0/attributes/mysql.remote.is_connected", - rapidjson::Value(env.expected_is_connected)}, - }) { - ASSERT_TRUE(TracingTestBase::json_pointer_eq( - doc, rapidjson::Pointer(pntr), val)) - << json_trace; - } - } else { - EXPECT_EQ(*warning_count_res, 0); - - TracingTestBase::assert_warnings_no_trace(cli); - } - }}, - {"list_fields_fail", false, false, - [](const ConnectionParam &connect_param, MysqlClient &cli, - TracingCommandParam::Env env) { - const bool can_trace = connect_param.can_trace(); - - cli.use_schema("performance_schema"); - - auto cmd_res = cli.list_fields("table_does_not_exist"); - ASSERT_ERROR(cmd_res); - EXPECT_EQ(cmd_res.error().value(), 1146) << cmd_res.error(); - - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - if (can_trace && env.trace_enabled) { - EXPECT_EQ(*warning_count_res, 0); - - auto trace_res = TracingTestBase::get_trace(cli); - ASSERT_TRUE(trace_res); - - auto json_trace = *trace_res; - - rapidjson::Document doc; - doc.Parse(json_trace.data(), json_trace.size()); - ASSERT_TRUE(TracingTestBase::trace_is_valid(doc)); - - for (const auto &[pntr, val] : { - std::pair{"/name", rapidjson::Value("mysql/list_fields")}, - std::pair{"/status_code", rapidjson::Value("ERROR")}, - std::pair{"/attributes/mysql.sharing_blocked", - rapidjson::Value(env.expected_sharing_is_blocked)}, - std::pair{"/events/0/name", - rapidjson::Value("mysql/connect_and_forward")}, - std::pair{"/events/0/attributes/mysql.remote.is_connected", - rapidjson::Value(env.expected_is_connected)}, - }) { - ASSERT_TRUE(TracingTestBase::json_pointer_eq( - doc, rapidjson::Pointer(pntr), val)) - << json_trace; - } - } else { - EXPECT_EQ(*warning_count_res, 0); - TracingTestBase::assert_warnings_no_trace(cli); } }}, @@ -1843,107 +1625,6 @@ const TracingCommandParam tracing_command_params[] = { << json_trace; } } else { - TracingTestBase::assert_warnings_no_trace(cli); - } - }}, - {"refresh_ok", // - false, // - true, // needs-super-privs - [](const ConnectionParam &connect_param, MysqlClient &cli, - TracingCommandParam::Env env) { - const bool can_trace = connect_param.can_trace(); - { - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - EXPECT_EQ(*warning_count_res, 0); - } - - auto cmd_res = cli.refresh(); - ASSERT_NO_ERROR(cmd_res); - - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - if (can_trace && env.trace_enabled) { - EXPECT_EQ(*warning_count_res, 2); // deprecated + trace - - auto trace_res = TracingTestBase::get_trace(cli); - ASSERT_TRUE(trace_res); - - auto json_trace = *trace_res; - - rapidjson::Document doc; - doc.Parse(json_trace.data(), json_trace.size()); - ASSERT_TRUE(TracingTestBase::trace_is_valid(doc)); - - for (const auto &[pntr, val] : { - std::pair{"/name", rapidjson::Value("mysql/reload")}, - std::pair{"/attributes/mysql.sharing_blocked", - rapidjson::Value(env.expected_sharing_is_blocked)}, - std::pair{"/events/0/name", - rapidjson::Value("mysql/connect_and_forward")}, - std::pair{"/events/0/attributes/mysql.remote.is_connected", - rapidjson::Value(env.expected_is_connected)}, - }) { - ASSERT_TRUE(TracingTestBase::json_pointer_eq( - doc, rapidjson::Pointer(pntr), val)) - << json_trace; - } - } else { - EXPECT_EQ(*warning_count_res, 1); // deprecated - - TracingTestBase::assert_warnings_no_trace(cli); - } - }}, - {"refresh_fail", false, false, - [](const ConnectionParam &connect_param, MysqlClient &cli, - TracingCommandParam::Env env) { - const bool can_trace = connect_param.can_trace(); - { - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - EXPECT_EQ(*warning_count_res, 0); - } - - // a failing refresh still aborts transactions. - auto cmd_res = cli.refresh(); - ASSERT_ERROR(cmd_res); - EXPECT_EQ(cmd_res.error().value(), 1227) << cmd_res.error(); - - auto warning_count_res = cli.warning_count(); - ASSERT_NO_ERROR(warning_count_res); - - if (can_trace && env.trace_enabled) { - EXPECT_EQ(*warning_count_res, 0); - - auto trace_res = TracingTestBase::get_trace(cli); - ASSERT_TRUE(trace_res); - - auto json_trace = *trace_res; - - rapidjson::Document doc; - doc.Parse(json_trace.data(), json_trace.size()); - ASSERT_TRUE(TracingTestBase::trace_is_valid(doc)); - - for (const auto &[pntr, val] : { - std::pair{"/name", rapidjson::Value("mysql/reload")}, - std::pair{"/status_code", rapidjson::Value("ERROR")}, - std::pair{"/attributes/mysql.sharing_blocked", - rapidjson::Value(env.expected_sharing_is_blocked)}, - std::pair{"/events/0/name", - rapidjson::Value("mysql/connect_and_forward")}, - std::pair{"/events/0/attributes/mysql.remote.is_connected", - rapidjson::Value(env.expected_is_connected)}, - }) { - ASSERT_TRUE(TracingTestBase::json_pointer_eq( - doc, rapidjson::Pointer(pntr), val)) - << json_trace; - } - } else { - EXPECT_EQ(*warning_count_res, 0); - TracingTestBase::assert_warnings_no_trace(cli); } }}, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index aa6f6ec46e93..83db7b968b25 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3860,10 +3860,10 @@ extern "C" void *signal_hand(void *arg [[maybe_unused]]) { case SIGHUP: if (!connection_events_loop_aborted()) { int not_used; - handle_reload_request(nullptr, - (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | - REFRESH_GRANT | REFRESH_THREADS), - nullptr, ¬_used); // Flush logs + handle_reload_request( + nullptr, + (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | REFRESH_GRANT), + nullptr, ¬_used); // Flush logs // Re-enable query logs after the options were reloaded. query_logger.set_handlers(log_output_options); } diff --git a/sql/protocol_classic.cc b/sql/protocol_classic.cc index 4f30b24e5770..3b1761fdf7cc 100644 --- a/sql/protocol_classic.cc +++ b/sql/protocol_classic.cc @@ -182,11 +182,7 @@ - @subpage page_protocol_com_quit - @subpage page_protocol_com_init_db - - @subpage page_protocol_com_field_list - - @subpage page_protocol_com_refresh - @subpage page_protocol_com_statistics - - @subpage page_protocol_com_process_info - - @subpage page_protocol_com_process_kill - @subpage page_protocol_com_debug - @subpage page_protocol_com_ping - @subpage page_protocol_com_change_user @@ -1759,87 +1755,6 @@ int Protocol_classic::read_packet() { @sa THD::send_result_set_row, Protocol_text */ -/** - @page page_protocol_com_field_list COM_FIELD_LIST - - @note As of MySQL 5.7.11, COM_FIELD_LIST is deprecated and will be removed in - a future version of MySQL. Instead, use COM_QUERY to execute a SHOW COLUMNS - statement. - - - - - - - - - - - - - -
Payload
TypeNameDescription
@ref a_protocol_type_int1 "int<1>"command0x04: COM_FIELD_LIST
@ref sect_protocol_basic_dt_string_null "string<NUL>"tablethe name of the table to return column information for - (in the current database for the connection)
@ref sect_protocol_basic_dt_string_eof "string<EOF>"wildcardfield wildcard
- - @return @ref sect_protocol_com_field_list_response - - @sa mysql_list_fields, mysqld_list_fields - - @section sect_protocol_com_field_list_response COM_FIELD_LIST Response - - The response to @ref page_protocol_com_field_list can be one of: - - @ref page_protocol_basic_err_packet - - zero or more - @ref page_protocol_com_query_response_text_resultset_column_definition - - a closing @ref page_protocol_basic_eof_packet - - @warning if ::CLIENT_OPTIONAL_RESULTSET_METADATA is on and the server side - variable ::Sys_resultset_metadata is not set to ::RESULTSET_METADATA_FULL - no rows will be sent, just an empty resultset. - - ~~~~~~~~ - 31 00 00 01 03 64 65 66 04 74 65 73 74 09 66 69 1....def.test.fi - 65 6c 64 6c 69 73 74 09 66 69 65 6c 64 6c 69 73 eldlist.fieldlis - 74 02 69 64 02 69 64 0c 3f 00 0b 00 00 00 03 00 t.id.id.?....... - 00 00 00 00 fb 05 00 00 02 fe 00 00 02 00 .............. - ~~~~~~~~ - - @sa mysql_list_fields, mysqld_list_fields, THD::send_result_metadata, - dispatch_command, cli_list_fields - -*/ - -/** - @page page_protocol_com_refresh COM_REFRESH - - @warning As of MySQL 5.7.11, COM_REFRESH is deprecated and will be removed - in a future version of MySQL. Instead, use COM_QUERY to execute a - FLUSH statement. - - A low-level version of several FLUSH ... and RESET ... statements. - - Calls REFRESH or FLUSH statements. - - - - - - - - - - -
Payload
TypeNameDescription
@ref a_protocol_type_int1 "int<1>"command0x07: COM_REFRESH
@ref a_protocol_type_int1 "int<1>"sub_commandA bitmask of sub-systems to refresh. - A combination of the first 8 bits of - @ref group_cs_com_refresh_flags
- - @return @ref page_protocol_basic_err_packet or - @ref page_protocol_basic_ok_packet - - @sa dispatch_command, handle_reload_request, mysql_refresh -*/ - - /** @page page_protocol_com_statistics COM_STATISTICS @@ -1862,58 +1777,6 @@ int Protocol_classic::read_packet() { @sa cli_read_statistics, mysql_stat, dispatch_command, calc_sum_of_all_status */ - -/** - @page page_protocol_com_process_info COM_PROCESS_INFO - - @warning As of 5.7.11 ::COM_PROCESS_INFO is deprecated in favor of ::COM_QUERY - with SHOW PROCESSLIST - - Get a list of active threads - - @return @ref page_protocol_com_query_response_text_resultset or a - @ref page_protocol_basic_err_packet - - - - - - - -
Payload
TypeNameDescription
@ref a_protocol_type_int1 "int<1>"command0x0A: COM_PROCESS_INFO
- - @sa mysql_list_processes, dispatch_command, mysqld_list_processes -*/ - - -/** - @page page_protocol_com_process_kill COM_PROCESS_KILL - - Ask the server to terminate a connection - - @warning As of MySQL 5.7.11, COM_PROCESS_KILL is deprecated and will be - removed in a future version of MySQL. Instead, use ::COM_QUERY and - a KILL command. - - Same as the SQL command `KILL `. - - - - - - - - - - -
Payload
TypeNameDescription
@ref a_protocol_type_int1 "int<1>"command0x0C: COM_PROCESS_KILL
@ref a_protocol_type_int4 "int<4>"connection_idThe connection to kill
- - @return @ref page_protocol_basic_err_packet or - @ref page_protocol_basic_ok_packet - - @sa dispatch_command, mysql_kill, sql_kill -*/ - /** @page page_protocol_com_debug COM_DEBUG @@ -2842,16 +2705,6 @@ bool Protocol_classic::parse_packet(union COM_DATA *data, data->com_init_db.length = input_packet_length; break; } - case COM_REFRESH: { - if (input_packet_length < 1) goto malformed; - data->com_refresh.options = input_raw_packet[0]; - break; - } - case COM_PROCESS_KILL: { - if (input_packet_length < 4) goto malformed; - data->com_kill.id = (ulong)uint4korr(input_raw_packet); - break; - } case COM_SET_OPTION: { if (input_packet_length < 2) goto malformed; data->com_set_option.opt_command = uint2korr(input_raw_packet); @@ -2953,22 +2806,6 @@ bool Protocol_classic::parse_packet(union COM_DATA *data, data->com_query.length = packet_left; break; } - case COM_FIELD_LIST: { - /* - We have name + wildcard in packet, separated by endzero - */ - const ulong len = - strend((char *)input_raw_packet) - (char *)input_raw_packet; - - if (len >= input_packet_length || len > NAME_LEN) goto malformed; - - data->com_field_list.table_name = input_raw_packet; - data->com_field_list.table_name_length = len; - - data->com_field_list.query = input_raw_packet + len + 1; - data->com_field_list.query_length = input_packet_length - len; - break; - } default: break; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c7e5bbc89bc6..98f6eb92b2c2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -516,10 +516,7 @@ void init_sql_command_flags() { server_command_flags[COM_SLEEP] = CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_INIT_DB] = CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_QUERY] = CF_ALLOW_PROTOCOL_PLUGIN; - server_command_flags[COM_FIELD_LIST] = CF_ALLOW_PROTOCOL_PLUGIN; - server_command_flags[COM_REFRESH] = CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_STATISTICS] = CF_SKIP_QUESTIONS; - server_command_flags[COM_PROCESS_KILL] = CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_PING] = CF_SKIP_QUESTIONS; server_command_flags[COM_STMT_PREPARE] = CF_SKIP_QUESTIONS | CF_ALLOW_PROTOCOL_PLUGIN; @@ -2243,103 +2240,6 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data, DBUG_PRINT("info", ("query ready")); break; } - case COM_FIELD_LIST: // This isn't actually needed - { - char *fields; - /* Locked closure of all tables */ - LEX_STRING table_name; - LEX_STRING db; - push_deprecated_warn(thd, "COM_FIELD_LIST", - "SHOW COLUMNS FROM statement"); - /* - SHOW statements should not add the used tables to the list of tables - used in a transaction. - */ - MDL_savepoint mdl_savepoint = thd->mdl_context.mdl_savepoint(); - - thd->status_var.com_stat[SQLCOM_SHOW_FIELDS]++; - global_aggregated_stats.get_shard(thd->thread_id()) - .com_stat[SQLCOM_SHOW_FIELDS]++; - if (thd->copy_db_to(&db.str, &db.length)) break; - thd->convert_string(&table_name, system_charset_info, - (char *)com_data->com_field_list.table_name, - com_data->com_field_list.table_name_length, - thd->charset()); - const Ident_name_check ident_check_status = - check_table_name(table_name.str, table_name.length); - if (ident_check_status == Ident_name_check::WRONG) { - /* this is OK due to convert_string() null-terminating the string */ - my_error(ER_WRONG_TABLE_NAME, MYF(0), table_name.str); - break; - } else if (ident_check_status == Ident_name_check::TOO_LONG) { - my_error(ER_TOO_LONG_IDENT, MYF(0), table_name.str); - break; - } - mysql_reset_thd_for_next_command(thd); - lex_start(thd); - /* Must be before we init the table list. */ - if (lower_case_table_names && !is_infoschema_db(db.str, db.length)) - table_name.length = my_casedn_str(files_charset_info, table_name.str); - Table_ref table_list(db.str, db.length, table_name.str, table_name.length, - table_name.str, TL_READ); - /* - Init Table_ref members necessary when the undelrying - table is view. - */ - table_list.query_block = thd->lex->query_block; - thd->lex->query_block->m_table_list.link_in_list(&table_list, - &table_list.next_local); - thd->lex->add_to_query_tables(&table_list); - - if (is_infoschema_db(table_list.db, table_list.db_length)) { - ST_SCHEMA_TABLE *schema_table = - find_schema_table(thd, table_list.alias); - if (schema_table) table_list.schema_table = schema_table; - } - - if (!(fields = - (char *)thd->memdup(com_data->com_field_list.query, - com_data->com_field_list.query_length))) - break; - // Don't count end \0 - thd->set_query(fields, com_data->com_field_list.query_length - 1); - query_logger.general_log_print(thd, command, "%s %s", - table_list.table_name, fields); - - if (open_temporary_tables(thd, &table_list)) break; - - if (check_table_access(thd, SELECT_ACL, &table_list, true, UINT_MAX, - false)) - break; - - thd->lex->sql_command = SQLCOM_SHOW_FIELDS; - // See comment in opt_trace_disable_if_no_security_context_access() - const Opt_trace_start ots(thd, &table_list, thd->lex->sql_command, - nullptr, nullptr, 0, nullptr, nullptr); - - mysqld_list_fields(thd, &table_list, fields); - - thd->lex->cleanup(true); - /* No need to rollback statement transaction, it's not started. */ - assert(thd->get_transaction()->is_empty(Transaction_ctx::STMT)); - close_thread_tables(thd); - thd->mdl_context.rollback_to_savepoint(mdl_savepoint); - - if (thd->transaction_rollback_request) { - /* - Transaction rollback was requested since MDL deadlock was - discovered while trying to open tables. Rollback transaction - in all storage engines including binary log and release all - locks. - */ - trans_rollback_implicit(thd); - thd->mdl_context.release_transactional_locks(); - } - - thd->cleanup_after_query(); - thd->lex->destroy(); - break; - } case COM_QUIT: /* Prevent results of the form, "n>0 rows sent, 0 bytes sent" */ thd->set_sent_row_count(0); @@ -2364,53 +2264,6 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data, thd, (char *)thd->get_protocol_classic()->get_raw_packet(), thd->get_protocol_classic()->get_packet_length()); break; - case COM_REFRESH: { - int not_used; - push_deprecated_warn(thd, "COM_REFRESH", "FLUSH statement"); - /* - Initialize thd->lex since it's used in many base functions, such as - open_tables(). Otherwise, it remains uninitialized and may cause crash - during execution of COM_REFRESH. - */ - lex_start(thd); - - thd->status_var.com_stat[SQLCOM_FLUSH]++; - global_aggregated_stats.get_shard(thd->thread_id()) - .com_stat[SQLCOM_FLUSH]++; - const ulong options = (ulong)com_data->com_refresh.options; - if (trans_commit_implicit(thd)) break; - thd->mdl_context.release_transactional_locks(); - if (check_global_access(thd, RELOAD_ACL)) break; - query_logger.general_log_print(thd, command, NullS); -#ifndef NDEBUG - bool debug_simulate = false; - DBUG_EXECUTE_IF("simulate_detached_thread_refresh", - debug_simulate = true;); - if (debug_simulate) { - /* - Simulate a reload without a attached thread session. - Provides a environment similar to that of when the - server receives a SIGHUP signal and reloads caches - and flushes tables. - */ - bool res; - current_thd = nullptr; - res = handle_reload_request(nullptr, options | REFRESH_FAST, nullptr, - ¬_used); - current_thd = thd; - if (res) break; - } else -#endif - if (handle_reload_request(thd, options, (Table_ref *)nullptr, - ¬_used)) - break; - if (trans_commit_implicit(thd)) break; - close_thread_tables(thd); - thd->mdl_context.release_transactional_locks(); - thd->lex->destroy(); - my_ok(thd); - break; - } case COM_STATISTICS: { System_status_var current_global_status_var; ulong uptime; @@ -2456,40 +2309,6 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data, global_aggregated_stats.get_shard(thd->thread_id()).com_other++; my_ok(thd); // Tell client we are alive break; - case COM_PROCESS_INFO: - bool global_access; - LEX_CSTRING db_saved; - thd->status_var.com_stat[SQLCOM_SHOW_PROCESSLIST]++; - global_aggregated_stats.get_shard(thd->thread_id()) - .com_stat[SQLCOM_SHOW_PROCESSLIST]++; - push_deprecated_warn(thd, "COM_PROCESS_INFO", - "SHOW PROCESSLIST statement"); - global_access = (check_global_access(thd, PROCESS_ACL) == 0); - if (!thd->security_context()->priv_user().str[0] && !global_access) break; - query_logger.general_log_print(thd, command, NullS); - db_saved = thd->db(); - - DBUG_EXECUTE_IF("force_db_name_to_null", thd->reset_db(NULL_CSTR);); - - mysqld_list_processes( - thd, global_access ? NullS : thd->security_context()->priv_user().str, - false, false); - - DBUG_EXECUTE_IF("force_db_name_to_null", thd->reset_db(db_saved);); - break; - case COM_PROCESS_KILL: { - push_deprecated_warn(thd, "COM_PROCESS_KILL", - "KILL CONNECTION/QUERY statement"); - if (thd_manager->get_thread_id() & (~0xfffffffful)) - my_error(ER_DATA_OUT_OF_RANGE, MYF(0), "thread_id", "mysql_kill()"); - else { - thd->status_var.com_stat[SQLCOM_KILL]++; - global_aggregated_stats.get_shard(thd->thread_id()) - .com_stat[SQLCOM_KILL]++; - sql_kill(thd, com_data->com_kill.id, false); - } - break; - } case COM_SET_OPTION: { thd->status_var.com_stat[SQLCOM_SET_OPTION]++; global_aggregated_stats.get_shard(thd->thread_id()) diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 2f3003f6f530..f3e0f460e386 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -335,8 +335,6 @@ bool handle_reload_request(THD *thd, unsigned long options, Table_ref *tables, } } if (thd && (options & REFRESH_STATUS)) refresh_status(); - if (options & REFRESH_THREADS) - Per_thread_connection_handler::kill_blocked_pthreads(); if (options & REFRESH_SOURCE) { assert(thd); tmp_write_to_binlog = 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f84535d5ada8..7fd6646ad2b3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1362,56 +1362,6 @@ bool mysqld_show_create_db(THD *thd, char *dbname, return false; } -/**************************************************************************** - Return only fields for API mysql_list_fields - Use "show table wildcard" in mysql instead of this -****************************************************************************/ - -void mysqld_list_fields(THD *thd, Table_ref *table_list, const char *wild) { - DBUG_TRACE; - DBUG_PRINT("enter", ("table: %s", table_list->table_name)); - - if (open_tables_for_query(thd, table_list, - MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL)) - return; - - if (table_list->is_view_or_derived()) { - // Setup materialized result table so that we can read the column list - if (table_list->resolve_derived(thd, false)) - return; /* purecov: inspected */ - if (table_list->setup_materialized_derived(thd)) - return; /* purecov: inspected */ - } - TABLE *table = table_list->table; - - mem_root_deque field_list(thd->mem_root); - - Field **ptr, *field; - for (ptr = table->field; (field = *ptr); ptr++) { - if (!wild || !wild[0] || - !wild_case_compare(system_charset_info, field->field_name, wild)) { - Item *item; - if (table_list->is_view()) { - item = new Item_ident_for_show(field, table_list->db, - table_list->table_name); - (void)item->fix_fields(thd, nullptr); - } else { - item = new Item_field(field); - } - field_list.push_back(item); - } - } - restore_record(table, s->default_values); // Get empty record - table->use_all_columns(); - if (thd->send_result_metadata(field_list, Protocol::SEND_DEFAULTS)) return; - if (table_list->is_view_or_derived()) { - close_tmp_table(table); - free_tmp_table(table); - table_list->table = nullptr; - } - my_eof(thd); -} - /* Go through all character combinations and ensure that sql_lex.cc can parse it as an identifier. diff --git a/sql/sql_show.h b/sql/sql_show.h index 2280dd74e46c..62e626fbfeb5 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -69,7 +69,6 @@ void append_identifier(const THD *thd, String *packet, const char *name, void append_identifier(const THD *thd, String *packet, const char *name, size_t length); -void mysqld_list_fields(THD *thd, Table_ref *table, const char *wild); bool mysqld_show_create(THD *thd, Table_ref *table_list); bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); diff --git a/testclients/mysql_client_test.cc b/testclients/mysql_client_test.cc index 116ac4286064..62446a84d39a 100644 --- a/testclients/mysql_client_test.cc +++ b/testclients/mysql_client_test.cc @@ -8180,69 +8180,6 @@ static void test_fetch_column() { myquery(mysql_query(mysql, "drop table t1")); } -/* Test mysql_list_fields() */ - -static void test_list_fields() { - MYSQL_RES *result; - int rc; - myheader("test_list_fields"); - - rc = mysql_query(mysql, "drop table if exists t1"); - myquery(rc); - - rc = mysql_query(mysql, - "create table t1(c1 int primary key auto_increment, c2 " - "char(10) default 'mysql')"); - myquery(rc); - - result = mysql_list_fields(mysql, "t1", nullptr); - mytest(result); - - rc = my_process_result_set(result); - DIE_UNLESS(rc == 0); - - verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG, "t1", "t1", - current_db, 11, "0"); - - verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING, "t1", "t1", - current_db, 10, "mysql"); - - mysql_free_result(result); - myquery(mysql_query(mysql, "drop table t1")); -} - -static void test_bug19671() { - MYSQL_RES *result; - int rc; - myheader("test_bug19671"); - - mysql_query(mysql, "set sql_mode=''"); - rc = mysql_query(mysql, "drop table if exists t1"); - myquery(rc); - - rc = mysql_query(mysql, "drop view if exists v1"); - myquery(rc); - - rc = mysql_query(mysql, "create table t1(f1 int)"); - myquery(rc); - - rc = mysql_query(mysql, "create view v1 as select va.* from t1 va"); - myquery(rc); - - result = mysql_list_fields(mysql, "v1", nullptr); - mytest(result); - - rc = my_process_result_set(result); - DIE_UNLESS(rc == 0); - - verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG, "v1", "v1", - current_db, 11, "0"); - - mysql_free_result(result); - myquery(mysql_query(mysql, "drop view v1")); - myquery(mysql_query(mysql, "drop table t1")); -} - /* Test a memory ovverun bug */ static void test_mem_overun() { @@ -12622,27 +12559,6 @@ static void test_truncation_option() { mysql_stmt_close(stmt); } -/* Bug#6761 - mysql_list_fields doesn't work */ - -static void test_bug6761() { - const char *stmt_text; - MYSQL_RES *res; - int rc; - myheader("test_bug6761"); - - stmt_text = "CREATE TABLE t1 (a int, b char(255), c decimal)"; - rc = mysql_real_query(mysql, stmt_text, (ulong)strlen(stmt_text)); - myquery(rc); - - res = mysql_list_fields(mysql, "t1", "%"); - DIE_UNLESS(res && mysql_num_fields(res) == 3); - mysql_free_result(res); - - stmt_text = "DROP TABLE t1"; - rc = mysql_real_query(mysql, stmt_text, (ulong)strlen(stmt_text)); - myquery(rc); -} - /* Bug#8330 - mysql_stmt_execute crashes (libmysql) */ static void test_bug8330() { @@ -12826,40 +12742,6 @@ static void restore_query_logs() { myquery(rc); } -static void test_view_sp_list_fields() { - int rc; - MYSQL_RES *res; - - myheader("test_view_sp_list_fields"); - - rc = mysql_query(mysql, "DROP FUNCTION IF EXISTS f1"); - myquery(rc); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS v1, t1, t2"); - myquery(rc); - rc = mysql_query(mysql, "DROP VIEW IF EXISTS v1, t1, t2"); - myquery(rc); - rc = mysql_query(mysql, "create function f1 () returns int return 5"); - myquery(rc); - rc = mysql_query(mysql, "create table t1 (s1 char,s2 char)"); - myquery(rc); - rc = mysql_query(mysql, "create table t2 (s1 int);"); - myquery(rc); - rc = mysql_query(mysql, - "create view v1 as select s2,sum(s1) - \ -count(s2) as vx from t1 group by s2 having sum(s1) - count(s2) < (select f1() \ -from t2);"); - myquery(rc); - res = mysql_list_fields(mysql, "v1", NullS); - DIE_UNLESS(res != nullptr && mysql_num_fields(res) != 0); - rc = mysql_query(mysql, "DROP FUNCTION f1"); - myquery(rc); - rc = mysql_query(mysql, "DROP VIEW v1"); - myquery(rc); - rc = mysql_query(mysql, "DROP TABLE t1, t2"); - mysql_free_result(res); - myquery(rc); -} - /* Test mysql_real_escape_string_quote() with gbk charset @@ -16335,48 +16217,6 @@ static void test_bug29692() { mysql_close(conn); } -/** - Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW -*/ - -static void test_bug29306() { - MYSQL_FIELD *field; - int rc; - MYSQL_RES *res; - - DBUG_TRACE; - myheader("test_bug29306"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS tab17557"); - myquery(rc); - rc = mysql_query(mysql, "DROP VIEW IF EXISTS view17557"); - myquery(rc); - rc = mysql_query(mysql, "CREATE TABLE tab17557 (dd decimal (3,1))"); - myquery(rc); - rc = mysql_query(mysql, "CREATE VIEW view17557 as SELECT dd FROM tab17557"); - myquery(rc); - rc = mysql_query(mysql, "INSERT INTO tab17557 VALUES (7.6)"); - myquery(rc); - - /* Checking the view */ - res = mysql_list_fields(mysql, "view17557", nullptr); - while ((field = mysql_fetch_field(res))) { - if (!opt_silent) { - printf("field name %s\n", field->name); - printf("field table %s\n", field->table); - printf("field decimals %d\n", field->decimals); - if (field->decimals < 1) printf("Error! No decimals! \n"); - printf("\n\n"); - } - DIE_UNLESS(field->decimals == 1); - } - mysql_free_result(res); - - rc = mysql_query(mysql, "DROP TABLE tab17557"); - myquery(rc); - rc = mysql_query(mysql, "DROP VIEW view17557"); - myquery(rc); -} /* Bug#30472: libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call row insertions. @@ -17388,56 +17228,6 @@ static void test_bug36004() { mysql_stmt_close(stmt); } -/** - Test that COM_REFRESH issues a implicit commit. -*/ - -static void test_wl4284_1() { - int rc; - MYSQL_ROW row; - MYSQL_RES *result; - - DBUG_TRACE; - myheader("test_wl4284_1"); - - /* set AUTOCOMMIT to OFF */ - rc = mysql_autocommit(mysql, false); - myquery(rc); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS trans"); - myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE trans (a INT) ENGINE= InnoDB"); - myquery(rc); - - rc = mysql_query(mysql, "INSERT INTO trans VALUES(1)"); - myquery(rc); - - rc = mysql_refresh(mysql, REFRESH_GRANT | REFRESH_TABLES); - myquery(rc); - - rc = mysql_rollback(mysql); - myquery(rc); - - rc = mysql_query(mysql, "SELECT * FROM trans"); - myquery(rc); - - result = mysql_use_result(mysql); - mytest(result); - - row = mysql_fetch_row(result); - mytest(row); - - mysql_free_result(result); - - /* set AUTOCOMMIT to ON */ - rc = mysql_autocommit(mysql, true); - myquery(rc); - - rc = mysql_query(mysql, "DROP TABLE trans"); - myquery(rc); -} - static void test_bug38486() { MYSQL_STMT *stmt; const char *stmt_text; @@ -17843,50 +17633,6 @@ static void test_bug44495() { myquery(rc); } -static void test_bug53371() { - int rc; - MYSQL_RES *result; - - myheader("test_bug53371"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); - myquery(rc); - rc = mysql_query(mysql, "DROP DATABASE IF EXISTS bug53371"); - myquery(rc); - rc = mysql_query(mysql, "DROP USER 'testbug'@localhost"); - rc = mysql_query(mysql, "CREATE USER 'testbug'@localhost"); - myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE t1 (a INT)"); - myquery(rc); - rc = mysql_query(mysql, "CREATE DATABASE bug53371"); - myquery(rc); - rc = mysql_query(mysql, "GRANT SELECT ON bug53371.* to 'testbug'@localhost"); - myquery(rc); - - rc = mysql_change_user(mysql, "testbug", nullptr, "bug53371"); - myquery(rc); - - rc = mysql_query(mysql, "SHOW COLUMNS FROM client_test_db.t1"); - DIE_UNLESS(rc); - DIE_UNLESS(mysql_errno(mysql) == 1142); - - result = mysql_list_fields(mysql, "../client_test_db/t1", nullptr); - DIE_IF(result); - - result = mysql_list_fields(mysql, "#mysql50#/../client_test_db/t1", nullptr); - DIE_IF(result); - - rc = mysql_change_user(mysql, opt_user, opt_password, current_db); - myquery(rc); - rc = mysql_query(mysql, "DROP TABLE t1"); - myquery(rc); - rc = mysql_query(mysql, "DROP DATABASE bug53371"); - myquery(rc); - rc = mysql_query(mysql, "DROP USER 'testbug'@localhost"); - myquery(rc); -} - /** Bug#42373: libmysql can mess a connection at connect */ @@ -18388,79 +18134,6 @@ static void test_bug11766854() { DIE_IF(mysql_errno(mysql)); } -/** - Bug#12337762: 60075: MYSQL_LIST_FIELDS() RETURNS WRONG CHARSET FOR - CHAR/VARCHAR/TEXT COLUMNS IN VIEWS -*/ -static void test_bug12337762() { - int rc, i = 0; - MYSQL_RES *result; - MYSQL_FIELD *field; - unsigned int tab_charsetnr[3] = {0}; - - DBUG_TRACE; - myheader("test_bug12337762"); - - /* - Creating table with specific charset. - */ - rc = mysql_query(mysql, "drop table if exists charset_tab"); - rc = mysql_query(mysql, - "create table charset_tab(" - "txt1 varchar(32) character set Latin1," - "txt2 varchar(32) character set Latin1 collate latin1_bin," - "txt3 varchar(32) character set utf8mb3 collate utf8mb3_bin" - ")"); - - DIE_UNLESS(rc == 0); - DIE_IF(mysql_errno(mysql)); - - /* - Creating view from table created earlier. - */ - rc = mysql_query(mysql, "drop view if exists charset_view"); - rc = mysql_query(mysql, - "create view charset_view as " - "select * from charset_tab;"); - DIE_UNLESS(rc == 0); - DIE_IF(mysql_errno(mysql)); - - /* - Checking field information for table. - */ - result = mysql_list_fields(mysql, "charset_tab", nullptr); - DIE_IF(mysql_errno(mysql)); - i = 0; - while ((field = mysql_fetch_field(result))) { - printf("field name %s\n", field->name); - printf("field table %s\n", field->table); - printf("field type %d\n", field->type); - printf("field charset %d\n", field->charsetnr); - tab_charsetnr[i++] = field->charsetnr; - printf("\n"); - } - mysql_free_result(result); - - /* - Checking field information for view. - */ - result = mysql_list_fields(mysql, "charset_view", nullptr); - DIE_IF(mysql_errno(mysql)); - i = 0; - while ((field = mysql_fetch_field(result))) { - printf("field name %s\n", field->name); - printf("field table %s\n", field->table); - printf("field type %d\n", field->type); - printf("field charset %d\n", field->charsetnr); - printf("\n"); - /* - charset value for field must be same for both, view and table. - */ - DIE_UNLESS(field->charsetnr == tab_charsetnr[i++]); - } - mysql_free_result(result); -} - /** Bug#54790: Use of non-blocking mode for sockets limits performance */ @@ -18524,87 +18197,6 @@ static void test_bug11754979() { mysql_close(conn); } -/* - Bug#13001491: MYSQL_REFRESH CRASHES WHEN STORED ROUTINES ARE RUN CONCURRENTLY. -*/ -static void test_bug13001491() { - int rc; - char query[MAX_TEST_QUERY_LENGTH]; - MYSQL *c; - - myheader("test_bug13001491"); - - snprintf(query, MAX_TEST_QUERY_LENGTH, "CREATE USER mysqltest_u1@%s", - opt_host ? opt_host : "'localhost'"); - - rc = mysql_query(mysql, query); - myquery(rc); - - snprintf(query, MAX_TEST_QUERY_LENGTH, - "GRANT ALL PRIVILEGES ON *.* TO mysqltest_u1@%s", - opt_host ? opt_host : "'localhost'"); - - rc = mysql_query(mysql, query); - myquery(rc); - - snprintf(query, MAX_TEST_QUERY_LENGTH, - "GRANT RELOAD ON *.* TO mysqltest_u1@%s", - opt_host ? opt_host : "'localhost'"); - - rc = mysql_query(mysql, query); - myquery(rc); - - c = mysql_client_init(nullptr); - - DIE_UNLESS(mysql_real_connect( - c, opt_host, "mysqltest_u1", nullptr, current_db, opt_port, - opt_unix_socket, CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS)); - - rc = mysql_query(c, "DROP PROCEDURE IF EXISTS p1"); - myquery(rc); - - rc = mysql_query(c, - "CREATE PROCEDURE p1() " - "BEGIN " - " DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; " - " SELECT COUNT(*) " - " FROM INFORMATION_SCHEMA.PROCESSLIST " - " GROUP BY user " - " ORDER BY NULL " - " INTO @a; " - "END"); - myquery(rc); - - rc = mysql_query(c, "CALL p1()"); - myquery(rc); - - mysql_free_result(mysql_store_result(c)); - - /* Check that mysql_refresh() succeeds without REFRESH_LOG. */ - rc = mysql_refresh( - c, REFRESH_GRANT | REFRESH_TABLES | REFRESH_STATUS | REFRESH_THREADS); - myquery(rc); - - /* - Check that mysql_refresh(REFRESH_LOG) does not crash the server even if it - fails. mysql_refresh(REFRESH_LOG) fails when error log points to unavailable - location. - */ - mysql_refresh(c, REFRESH_LOG); - - rc = mysql_query(c, "DROP PROCEDURE p1"); - myquery(rc); - - mysql_close(c); - c = nullptr; - - snprintf(query, MAX_TEST_QUERY_LENGTH, "DROP USER mysqltest_u1@%s", - opt_host ? opt_host : "'localhost'"); - - rc = mysql_query(mysql, query); - myquery(rc); -} - /* WL#5968: Implement START TRANSACTION READ (WRITE|ONLY); Check that the SERVER_STATUS_IN_TRANS_READONLY flag is set properly. @@ -19701,75 +19293,6 @@ static void test_bug20444737() { my_fclose(test_file, MYF(0)); } -/** - Bug#21104470 WL8132:ASSERTION `! IS_SET()' FAILED. -*/ -static void test_bug21104470() { - MYSQL_RES *result; - int rc; - - myheader("test_bug21104470"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); - myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE t1(j1 JSON, j2 JSON NOT NULL)"); - myquery(rc); - - /* This call used to crash the server. */ - result = mysql_list_fields(mysql, "t1", nullptr); - mytest(result); - - rc = my_process_result_set(result); - DIE_UNLESS(rc == 0); - - verify_prepare_field(result, 0, "j1", "j1", MYSQL_TYPE_JSON, "t1", "t1", - current_db, UINT_MAX32, nullptr); - - verify_prepare_field(result, 1, "j2", "j2", MYSQL_TYPE_JSON, "t1", "t1", - current_db, UINT_MAX32, nullptr); - - mysql_free_result(result); - myquery(mysql_query(mysql, "DROP TABLE t1")); -} - -/** - Bug#21293012 ASSERT `!IS_NULL()' FAILED AT FIELD_JSON::VAL_JSON - ON NEW CONN TO DB WITH VIEW -*/ -static void test_bug21293012() { - MYSQL_RES *result; - int rc; - - myheader("test_bug21293012"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); - myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE t1(j1 JSON, j2 JSON NOT NULL)"); - myquery(rc); - - rc = mysql_query(mysql, "CREATE VIEW v1 AS SELECT * FROM t1"); - myquery(rc); - - /* This call used to crash the server. */ - result = mysql_list_fields(mysql, "v1", nullptr); - mytest(result); - - rc = my_process_result_set(result); - DIE_UNLESS(rc == 0); - - verify_prepare_field(result, 0, "j1", "j1", MYSQL_TYPE_JSON, "v1", "v1", - current_db, UINT_MAX32, nullptr); - - verify_prepare_field(result, 1, "j2", "j2", MYSQL_TYPE_JSON, "v1", "v1", - current_db, UINT_MAX32, nullptr); - - mysql_free_result(result); - myquery(mysql_query(mysql, "DROP VIEW v1")); - myquery(mysql_query(mysql, "DROP TABLE t1")); -} - static void test_bug21199582() { int rc = 0; int recCnt[] = {3, 4, 1}; @@ -20004,88 +19527,6 @@ static void test_bug20821550() { mysql_close(mysql_ptr); } -static void check_warning(MYSQL *conn, int warn_count) { - MYSQL_RES *result; - int rc; - - rc = mysql_query(conn, "SHOW WARNINGS"); - myquery(rc); - result = mysql_store_result(conn); - mytest(result); - rc = my_process_result_set(result); - DIE_UNLESS(rc == warn_count); - mysql_free_result(result); -} - -static void check_warning(MYSQL *conn) { return check_warning(conn, 1); } - -static void test_wl8754() { - MYSQL_RES *res; - MYSQL *conn; - int rc; - unsigned long thread_id; - const char *stmt_text; - - myheader("test_wl8754"); - - /* Check that mysql_list_fields reports deprecated warning. */ - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); - myquery(rc); - stmt_text = "CREATE TABLE t1 (a int, b char(255), c decimal)"; - rc = mysql_real_query(mysql, stmt_text, (ulong)strlen(stmt_text)); - myquery(rc); - - res = mysql_list_fields(mysql, "t1", "%"); - mysql_free_result(res); - - check_warning(mysql); - - stmt_text = "DROP TABLE t1"; - rc = mysql_real_query(mysql, stmt_text, (ulong)strlen(stmt_text)); - myquery(rc); - - /* Check that mysql_refresh() reports deprecated warning. */ - rc = mysql_refresh(mysql, REFRESH_TABLES); - myquery(rc); - - check_warning(mysql); - - /* Run a dummy query to clear diagnostics. */ - rc = mysql_query(mysql, "SELECT 1"); - myquery(rc); - /* Get the result. */ - res = mysql_store_result(mysql); - mytest(res); - (void)my_process_result_set(res); - mysql_free_result(res); - - /* Check that mysql_list_processes() reports deprecated warning. */ - res = mysql_list_processes(mysql); - mysql_free_result(res); - - check_warning(mysql, 2); - - /* Check that mysql_kill() reports deprecated warning. */ - if (!(conn = mysql_client_init(nullptr))) { - myerror("mysql_client_init() failed"); - exit(1); - } - conn->reconnect = true; - if (!(mysql_real_connect(conn, opt_host, opt_user, opt_password, current_db, - opt_port, opt_unix_socket, 0))) { - myerror("connection failed"); - exit(1); - } - thread_id = mysql_thread_id(conn); - /* - Kill connection would have killed the existing connection which clears - the THD state and reconnects with a new THD thus there will be no - warnings. - */ - mysql_kill(conn, (unsigned long)thread_id); - mysql_close(conn); -} - /* BUG#17883203: MYSQL EMBEDDED MYSQL_STMT_EXECUTE RETURN "MALFORMED COMMUNICATION PACKET" ERROR @@ -20158,28 +19599,6 @@ static void test_bug22336527() { mysql_close(l_mysql); } -/** - Bug#24963580 INFORMATION_SCHEMA:MDL_REQUEST::INIT_WITH_SOURCE -*/ -static void test_bug24963580() { - MYSQL_RES *result; - int rc; - - myheader("test_bug24963580"); - - rc = mysql_query(mysql, "USE information_schema"); - myquery(rc); - - /* This call used to crash the server. */ - result = mysql_list_fields(mysql, "CHARACTER_SETS", nullptr); - mytest(result); - - rc = my_process_result_set(result); - DIE_UNLESS(rc == 0); - - mysql_free_result(result); -} - static int test_mysql_binlog_perform(MYSQL *mysql1, const char *binlog_name, ulong start_position, uint server_id, uint flags, size_t gtid_set_size, @@ -21793,17 +21212,6 @@ static void test_param_integer() { myquery(rc); } -static void test_bug30032302() { - MYSQL_RES *res; - - myheader("test_bug30032302"); - - res = mysql_list_processes(mysql); - mysql_free_result(res); - - check_warning(mysql, 2); -} - static void test_wl13168() { int rc; MYSQL *l_mysql; @@ -22773,6 +22181,9 @@ static void test_bug32892045() { int rc = mysql_query(mysql, command); myquery(rc); + rc = mysql_query(mysql, "drop table if exists t1"); + myquery(rc); + rc = mysql_query(mysql, "CREATE TABLE t1 (AAA INT, BBB INT, CCC INT, DDD INT)"); myquery(rc); @@ -23430,8 +22841,6 @@ static void test_server_telemetry_traces() { // (ordering not changed between multiple sessions) my_sleep(500000); // 500msec - test_zero_rpc(COM_REFRESH, true); - test_zero_rpc(COM_PROCESS_KILL, true); test_zero_rpc(COM_STMT_EXECUTE, true); test_zero_rpc(COM_STMT_SEND_LONG_DATA, true); test_zero_rpc(COM_STMT_CLOSE, true); @@ -23951,7 +23360,6 @@ static void test_wl15633(void) { static struct my_tests_st my_tests[] = { {"disable_query_logs", disable_query_logs}, - {"test_view_sp_list_fields", test_view_sp_list_fields}, {"client_query", client_query}, {"test_prepare_insert_update", test_prepare_insert_update}, {"test_fetch_seek", test_fetch_seek}, @@ -24042,7 +23450,6 @@ static struct my_tests_st my_tests[] = { {"test_fetch_offset", test_fetch_offset}, {"test_fetch_column", test_fetch_column}, {"test_mem_overun", test_mem_overun}, - {"test_list_fields", test_list_fields}, {"test_free_result", test_free_result}, {"test_free_store_result", test_free_store_result}, {"test_sqlmode", test_sqlmode}, @@ -24097,7 +23504,6 @@ static struct my_tests_st my_tests[] = { {"test_bug4172", test_bug4172}, {"test_conversion", test_conversion}, {"test_rewind", test_rewind}, - {"test_bug6761", test_bug6761}, {"test_view", test_view}, {"test_view_where", test_view_where}, {"test_view_2where", test_view_2where}, @@ -24155,7 +23561,6 @@ static struct my_tests_st my_tests[] = { {"test_bug17667", test_bug17667}, {"test_bug15752", test_bug15752}, {"test_mysql_insert_id", test_mysql_insert_id}, - {"test_bug19671", test_bug19671}, {"test_bug21206", test_bug21206}, {"test_bug21726", test_bug21726}, {"test_bug15518", test_bug15518}, @@ -24171,12 +23576,10 @@ static struct my_tests_st my_tests[] = { {"test_bug27592", test_bug27592}, {"test_bug29687", test_bug29687}, {"test_bug29692", test_bug29692}, - {"test_bug29306", test_bug29306}, {"test_change_user", test_change_user}, {"test_bug30472", test_bug30472}, {"test_bug20023", test_bug20023}, {"test_bug45010", test_bug45010}, - {"test_bug53371", test_bug53371}, {"test_bug31418", test_bug31418}, {"test_bug31669", test_bug31669}, {"test_bug28386", test_bug28386}, @@ -24185,7 +23588,6 @@ static struct my_tests_st my_tests[] = { {"test_wl4166_3", test_wl4166_3}, {"test_wl4166_4", test_wl4166_4}, {"test_bug36004", test_bug36004}, - {"test_wl4284_1", test_wl4284_1}, {"test_wl4435", test_wl4435}, {"test_wl4435_2", test_wl4435_2}, {"test_wl4435_3", test_wl4435_3}, @@ -24205,9 +23607,7 @@ static struct my_tests_st my_tests[] = { {"test_bug56976", test_bug56976}, {"test_bug11766854", test_bug11766854}, {"test_bug54790", test_bug54790}, - {"test_bug12337762", test_bug12337762}, {"test_bug11754979", test_bug11754979}, - {"test_bug13001491", test_bug13001491}, {"test_wl5968", test_wl5968}, {"test_wl5924", test_wl5924}, {"test_wl6587", test_wl6587}, @@ -24221,14 +23621,10 @@ static struct my_tests_st my_tests[] = { {"test_bug20645725", test_bug20645725}, {"test_bug19894382", test_bug19894382}, {"test_bug20444737", test_bug20444737}, - {"test_bug21104470", test_bug21104470}, - {"test_bug21293012", test_bug21293012}, {"test_bug21199582", test_bug21199582}, {"test_bug20821550", test_bug20821550}, - {"test_wl8754", test_wl8754}, {"test_bug17883203", test_bug17883203}, {"test_bug22336527", test_bug22336527}, - {"test_bug24963580", test_bug24963580}, {"test_mysql_binlog", test_mysql_binlog}, {"test_bug22028117", test_bug22028117}, {"test_skip_metadata", test_skip_metadata}, @@ -24241,7 +23637,6 @@ static struct my_tests_st my_tests[] = { {"test_wl12475", test_wl12475}, {"test_limit_syntax", test_limit_syntax}, {"test_param_integer", test_param_integer}, - {"test_bug30032302", test_bug30032302}, {"test_wl13168", test_wl13168}, {"test_wl13510", test_wl13510}, {"test_wl13510_multi_statements", test_wl13510_multi_statements},