mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#21554 (sp_cache.cc: violates C++ aliasing rules)
The problem reported is a compile bug, reported by the development GCC team with GCC 4.2. The original issue can no longer be reproduced in MySQL 5.1, since the configure script no longer define HAVE_ATOMIC_ADD, which caused the Linux atomic functions to be used (and cause a problem with an invalid cast). This patch implements some code cleanup for 5.1 only, which was identified during the investigation of this issue. With this patch, statistics maintained in THD::status_var are by definition owned by the running thread, and do not need to be protected against race conditions. These statistics are maintained by the status_var_* helpers, which do not require any lock.
This commit is contained in:
@ -721,8 +721,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
case COM_INIT_DB:
|
||||
{
|
||||
LEX_STRING tmp;
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB]);
|
||||
thd->convert_string(&tmp, system_charset_info,
|
||||
packet, packet_length-1, thd->charset());
|
||||
if (!mysql_change_db(thd, &tmp, FALSE))
|
||||
@ -757,7 +756,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
}
|
||||
|
||||
statistic_increment(thd->status_var.com_other, &LOCK_status);
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
thd->enable_slow_log= opt_log_slow_admin_statements;
|
||||
db.str= thd->alloc(db_len + tbl_len + 2);
|
||||
db.length= db_len;
|
||||
@ -773,7 +772,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
}
|
||||
case COM_CHANGE_USER:
|
||||
{
|
||||
statistic_increment(thd->status_var.com_other, &LOCK_status);
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
char *user= (char*) packet, *packet_end= packet+ packet_length;
|
||||
char *passwd= strend(user)+1;
|
||||
|
||||
@ -956,8 +955,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
/* used as fields initializator */
|
||||
lex_start(thd);
|
||||
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS]);
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
if (thd->copy_db_to(&table_list.db, &dummy))
|
||||
break;
|
||||
@ -1023,8 +1021,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
LEX_STRING db, alias;
|
||||
HA_CREATE_INFO create_info;
|
||||
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB]);
|
||||
if (thd->LEX_STRING_make(&db, packet, packet_length -1) ||
|
||||
thd->LEX_STRING_make(&alias, db.str, db.length) ||
|
||||
check_db_name(&db))
|
||||
@ -1043,8 +1040,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
}
|
||||
case COM_DROP_DB: // QQ: To be removed
|
||||
{
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_DROP_DB],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_DROP_DB]);
|
||||
LEX_STRING db;
|
||||
|
||||
if (thd->LEX_STRING_make(&db, packet, packet_length - 1) ||
|
||||
@ -1073,7 +1069,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
ushort flags;
|
||||
uint32 slave_server_id;
|
||||
|
||||
statistic_increment(thd->status_var.com_other,&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
thd->enable_slow_log= opt_log_slow_admin_statements;
|
||||
if (check_global_access(thd, REPL_SLAVE_ACL))
|
||||
break;
|
||||
@ -1099,8 +1095,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
case COM_REFRESH:
|
||||
{
|
||||
bool not_used;
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_FLUSH],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_FLUSH]);
|
||||
ulong options= (ulong) (uchar) packet[0];
|
||||
if (check_global_access(thd,RELOAD_ACL))
|
||||
break;
|
||||
@ -1112,7 +1107,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
case COM_SHUTDOWN:
|
||||
{
|
||||
statistic_increment(thd->status_var.com_other, &LOCK_status);
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
if (check_global_access(thd,SHUTDOWN_ACL))
|
||||
break; /* purecov: inspected */
|
||||
/*
|
||||
@ -1164,8 +1159,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
#endif
|
||||
|
||||
general_log_print(thd, command, NullS);
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS]);
|
||||
calc_sum_of_all_status(¤t_global_status_var);
|
||||
if (!(uptime= (ulong) (thd->start_time - server_start_time)))
|
||||
queries_per_second1000= 0;
|
||||
@ -1201,12 +1195,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
}
|
||||
case COM_PING:
|
||||
statistic_increment(thd->status_var.com_other, &LOCK_status);
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
send_ok(thd); // Tell client we are alive
|
||||
break;
|
||||
case COM_PROCESS_INFO:
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_PROCESSLIST],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_PROCESSLIST]);
|
||||
if (!thd->security_ctx->priv_user[0] &&
|
||||
check_global_access(thd, PROCESS_ACL))
|
||||
break;
|
||||
@ -1217,15 +1210,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
case COM_PROCESS_KILL:
|
||||
{
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_KILL], &LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_KILL]);
|
||||
ulong id=(ulong) uint4korr(packet);
|
||||
sql_kill(thd,id,false);
|
||||
break;
|
||||
}
|
||||
case COM_SET_OPTION:
|
||||
{
|
||||
statistic_increment(thd->status_var.com_stat[SQLCOM_SET_OPTION],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_SET_OPTION]);
|
||||
uint opt_command= uint2korr(packet);
|
||||
|
||||
switch (opt_command) {
|
||||
@ -1244,7 +1236,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
}
|
||||
case COM_DEBUG:
|
||||
statistic_increment(thd->status_var.com_other, &LOCK_status);
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
if (check_global_access(thd, SUPER_ACL))
|
||||
break; /* purecov: inspected */
|
||||
mysql_print_status();
|
||||
@ -1783,8 +1775,7 @@ mysql_execute_command(THD *thd)
|
||||
#ifdef HAVE_REPLICATION
|
||||
} /* endif unlikely slave */
|
||||
#endif
|
||||
statistic_increment(thd->status_var.com_stat[lex->sql_command],
|
||||
&LOCK_status);
|
||||
status_var_increment(thd->status_var.com_stat[lex->sql_command]);
|
||||
|
||||
switch (lex->sql_command) {
|
||||
case SQLCOM_SHOW_EVENTS:
|
||||
|
Reference in New Issue
Block a user