Commit 613d0194 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-33160 show_status_array() calls various functions via incompatible pointer

In commit b4ff6456 the
signature of mysql_show_var_func was changed, but not all functions
of that type were adjusted.

When the server is configured with `cmake -DWITH_ASAN=ON` and
compiled with clang, runtime errors would be flagged for invoking
functions through an incompatible function pointer.

Reviewed by: Michael 'Monty' Widenius
parent 54ed3939
......@@ -7180,8 +7180,8 @@ struct my_option my_long_options[]=
MYSQL_TO_BE_IMPLEMENTED_OPTION("validate-user-plugins") // NO_EMBEDDED_ACCESS_CHECKS
};
static int show_queries(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_queries(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONGLONG;
var->value= &thd->query_id;
......@@ -7189,16 +7189,16 @@ static int show_queries(THD *thd, SHOW_VAR *var, char *buff,
}
static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_net_compression(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
var->type= SHOW_MY_BOOL;
var->value= &thd->net.compress;
return 0;
}
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_starttime(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7207,8 +7207,8 @@ static int show_starttime(THD *thd, SHOW_VAR *var, char *buff,
}
#ifdef ENABLED_PROFILING
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_flushstatustime(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7218,32 +7218,28 @@ static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff,
#endif
#ifdef HAVE_REPLICATION
static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_rpl_status(THD *, SHOW_VAR *var, void *, system_status_var *,
enum_var_type)
{
var->type= SHOW_CHAR;
var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]);
return 0;
}
static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_slave_running(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
Master_info *mi= NULL;
bool UNINIT_VAR(tmp);
var->type= SHOW_MY_BOOL;
var->value= buff;
if ((mi= get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE)))
if (Master_info *mi=
get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE))
{
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_READING &&
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN);
*((my_bool*) buff)=
(mi->slave_running == MYSQL_SLAVE_RUN_READING &&
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN);
mi->release();
var->type= SHOW_MY_BOOL;
var->value= buff;
}
if (mi)
*((my_bool *)buff)= tmp;
else
var->type= SHOW_UNDEF;
return 0;
......@@ -7253,7 +7249,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff,
/* How many masters this slave is connected to */
static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff)
static int show_slaves_running(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONGLONG;
var->value= buff;
......@@ -7264,19 +7261,17 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff)
}
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
Master_info *mi;
var->type= SHOW_LONGLONG;
var->value= buff;
if ((mi= get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE)))
if (Master_info *mi=
get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE))
{
*((longlong *)buff)= mi->received_heartbeats;
mi->release();
var->type= SHOW_LONGLONG;
var->value= buff;
}
else
var->type= SHOW_UNDEF;
......@@ -7284,19 +7279,17 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff,
}
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
Master_info *mi;
var->type= SHOW_CHAR;
var->value= buff;
if ((mi= get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE)))
if (Master_info *mi=
get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE))
{
sprintf(buff, "%.3f", mi->heartbeat_period);
sprintf(static_cast<char*>(buff), "%.3f", mi->heartbeat_period);
mi->release();
var->type= SHOW_CHAR;
var->value= buff;
}
else
var->type= SHOW_UNDEF;
......@@ -7306,8 +7299,8 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff,
#endif /* HAVE_REPLICATION */
static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_open_tables(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7315,8 +7308,8 @@ static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_prepared_stmt_count(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7326,8 +7319,8 @@ static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_table_definitions(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7336,8 +7329,8 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
}
static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_flush_commands(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONGLONG;
var->value= buff;
......@@ -7356,8 +7349,8 @@ static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
inside an Event.
*/
static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_ssl_get_version(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
var->type= SHOW_CHAR;
if( thd->vio_ok() && thd->net.vio->ssl_arg )
......@@ -7367,8 +7360,8 @@ static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7379,8 +7372,8 @@ static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7395,8 +7388,8 @@ static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_LONG;
var->value= buff;
......@@ -7408,8 +7401,8 @@ static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_CHAR;
if( thd->vio_ok() && thd->net.vio->ssl_arg )
......@@ -7419,9 +7412,10 @@ static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, void *buf,
system_status_var *, enum_var_type)
{
char *buff= static_cast<char*>(buf);
var->type= SHOW_CHAR;
var->value= buff;
if (thd->vio_ok() && thd->net.vio->ssl_arg)
......@@ -7506,8 +7500,8 @@ my_asn1_time_to_string(const ASN1_TIME *time, char *buf, size_t len)
*/
static int
show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_CHAR;
if(thd->vio_ok() && thd->net.vio->ssl_arg)
......@@ -7516,7 +7510,7 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
X509 *cert= SSL_get_certificate(ssl);
const ASN1_TIME *not_before= X509_get0_notBefore(cert);
var->value= my_asn1_time_to_string(not_before, buff,
var->value= my_asn1_time_to_string(not_before, static_cast<char*>(buff),
SHOW_VAR_FUNC_BUFF_SIZE);
if (!var->value)
return 1;
......@@ -7540,8 +7534,8 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
*/
static int
show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_CHAR;
if(thd->vio_ok() && thd->net.vio->ssl_arg)
......@@ -7550,7 +7544,7 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
X509 *cert= SSL_get_certificate(ssl);
const ASN1_TIME *not_after= X509_get0_notAfter(cert);
var->value= my_asn1_time_to_string(not_after, buff,
var->value= my_asn1_time_to_string(not_after, static_cast<char*>(buff),
SHOW_VAR_FUNC_BUFF_SIZE);
if (!var->value)
return 1;
......@@ -7604,7 +7598,7 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, void *buff,
}
static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff,
static int show_memory_used(THD *thd, SHOW_VAR *var, void *buff,
struct system_status_var *status_var,
enum enum_var_type scope)
{
......@@ -7660,8 +7654,8 @@ static int debug_status_func(THD *thd, SHOW_VAR *var, void *buff,
#endif
#ifdef HAVE_POOL_OF_THREADS
int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
int show_threadpool_idle_threads(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_INT;
var->value= buff;
......@@ -7670,8 +7664,8 @@ int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
}
static int show_threadpool_threads(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_threadpool_threads(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{
var->type= SHOW_INT;
var->value= buff;
......
......@@ -11869,8 +11869,8 @@ static my_bool count_column_grants(void *grant_table,
This must be performed under the mutex in order to make sure the
iteration does not fail.
*/
static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_column_grants(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum enum_var_type scope)
{
var->type= SHOW_ULONG;
var->value= buff;
......@@ -11886,8 +11886,8 @@ static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
static int show_database_grants(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
static int show_database_grants(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum enum_var_type scope)
{
var->type= SHOW_UINT;
var->value= buff;
......
......@@ -1345,8 +1345,8 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
}
int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum enum_var_type scope)
{
var->type= SHOW_UINT;
var->value= buff;
......
......@@ -97,8 +97,8 @@ extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
bool no_dups= false);
extern uint tc_records(void);
int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope);
int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff,
system_status_var *, enum enum_var_type scope);
extern void tc_purge(bool mark_flushed= false);
extern void tc_add_table(THD *thd, TABLE *table);
extern void tc_release_table(TABLE *table);
......
......@@ -64,9 +64,6 @@ extern int tp_get_thread_count();
/* Activate threadpool scheduler */
extern void tp_scheduler(void);
extern int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope);
enum TP_PRIORITY {
TP_PRIORITY_HIGH,
TP_PRIORITY_LOW,
......
......@@ -3548,7 +3548,8 @@ CSphSEStats * sphinx_get_stats ( THD * thd, SHOW_VAR * out )
return 0;
}
int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * )
static int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{
CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats )
......@@ -3559,7 +3560,8 @@ int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * )
return 0;
}
int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * )
static int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{
CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats )
......@@ -3570,7 +3572,8 @@ int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * )
return 0;
}
int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * )
static int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{
CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats )
......@@ -3581,7 +3584,8 @@ int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * )
return 0;
}
int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * )
static int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{
CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats )
......@@ -3592,9 +3596,11 @@ int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * )
return 0;
}
int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer )
static int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, void * buf,
system_status_var *, enum_var_type )
{
#if MYSQL_VERSION_ID>50100
char *sBuffer = static_cast<char*>(buf);
if ( sphinx_hton_ptr )
{
CSphTLS * pTls = (CSphTLS *) *thd_ha_data ( thd, sphinx_hton_ptr );
......@@ -3649,7 +3655,8 @@ int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer )
return 0;
}
int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, char * )
static int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{
CSphSEStats * pStats = sphinx_get_stats ( thd, out );
out->type = SHOW_CHAR;
......
......@@ -164,12 +164,6 @@ class ha_sphinx : public handler
bool sphinx_show_status ( THD * thd );
#endif
int sphinx_showfunc_total_found ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_total ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_time ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_word_count ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_words ( THD *, SHOW_VAR *, char * );
//
// $Id: ha_sphinx.h 4818 2014-09-24 08:53:38Z tomat $
//
......@@ -115,7 +115,8 @@ extern volatile ulonglong spider_mon_table_cache_version_req;
}
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
static int spider_direct_update(THD *thd, SHOW_VAR *var, char *buff)
static int spider_direct_update(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
int error_num = 0;
SPIDER_TRX *trx;
......@@ -126,7 +127,8 @@ static int spider_direct_update(THD *thd, SHOW_VAR *var, char *buff)
DBUG_RETURN(error_num);
}
static int spider_direct_delete(THD *thd, SHOW_VAR *var, char *buff)
static int spider_direct_delete(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
int error_num = 0;
SPIDER_TRX *trx;
......@@ -138,7 +140,8 @@ static int spider_direct_delete(THD *thd, SHOW_VAR *var, char *buff)
}
#endif
static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, char *buff)
static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
int error_num = 0;
SPIDER_TRX *trx;
......@@ -149,7 +152,8 @@ static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, char *buff)
DBUG_RETURN(error_num);
}
static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff)
static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
int error_num = 0;
SPIDER_TRX *trx;
......@@ -160,7 +164,8 @@ static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff)
DBUG_RETURN(error_num);
}
static int spider_parallel_search(THD *thd, SHOW_VAR *var, char *buff)
static int spider_parallel_search(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
int error_num = 0;
SPIDER_TRX *trx;
......@@ -172,7 +177,8 @@ static int spider_parallel_search(THD *thd, SHOW_VAR *var, char *buff)
}
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
static int spider_hs_result_free(THD *thd, SHOW_VAR *var, char *buff)
static int spider_hs_result_free(THD *thd, SHOW_VAR *var, void *,
system_status_var *, enum_var_type)
{
int error_num = 0;
SPIDER_TRX *trx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment