From bb64e39e0aa6d209a47dea7ed48753752ec003f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 May 2007 13:41:40 -0600 Subject: 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. include/my_global.h: General cleanup of thread_safe_increment / statistic_increment include/my_pthread.h: General cleanup of thread_safe_increment / statistic_increment sql/filesort.cc: General cleanup of thread_safe_increment / statistic_increment sql/handler.cc: General cleanup of thread_safe_increment / statistic_increment sql/sql_insert.cc: General cleanup of thread_safe_increment / statistic_increment sql/sql_parse.cc: General cleanup of thread_safe_increment / statistic_increment sql/sql_prepare.cc: General cleanup of thread_safe_increment / statistic_increment sql/sql_select.cc: General cleanup of thread_safe_increment / statistic_increment --- sql/handler.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'sql/handler.cc') diff --git a/sql/handler.cc b/sql/handler.cc index 48600c68daf..83785ec579b 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -639,7 +639,7 @@ int ha_prepare(THD *thd) for (; *ht; ht++) { int err; - statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status); + status_var_increment(thd->status_var.ha_prepare_count); if ((*ht)->prepare) { if ((err= (*(*ht)->prepare)(*ht, thd, all))) @@ -734,7 +734,7 @@ int ha_commit_trans(THD *thd, bool all) my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); error= 1; } - statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status); + status_var_increment(thd->status_var.ha_prepare_count); } DBUG_EXECUTE_IF("crash_commit_after_prepare", abort();); if (error || (is_real_trans && xid && @@ -781,7 +781,7 @@ int ha_commit_one_phase(THD *thd, bool all) my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); error=1; } - statistic_increment(thd->status_var.ha_commit_count,&LOCK_status); + status_var_increment(thd->status_var.ha_commit_count); *ht= 0; } trans->nht=0; @@ -837,7 +837,7 @@ int ha_rollback_trans(THD *thd, bool all) my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); error=1; } - statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status); + status_var_increment(thd->status_var.ha_rollback_count); *ht= 0; } trans->nht=0; @@ -1252,8 +1252,7 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv) my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); error=1; } - statistic_increment(thd->status_var.ha_savepoint_rollback_count, - &LOCK_status); + status_var_increment(thd->status_var.ha_savepoint_rollback_count); trans->no_2pc|=(*ht)->prepare == 0; } /* @@ -1268,7 +1267,7 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv) my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); error=1; } - statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status); + status_var_increment(thd->status_var.ha_rollback_count); *ht=0; // keep it conveniently zero-filled } DBUG_RETURN(error); @@ -1301,7 +1300,7 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv) my_error(ER_GET_ERRNO, MYF(0), err); error=1; } - statistic_increment(thd->status_var.ha_savepoint_count,&LOCK_status); + status_var_increment(thd->status_var.ha_savepoint_count); } sv->nht=trans->nht; #endif /* USING_TRANSACTIONS */ @@ -1489,7 +1488,7 @@ handler *handler::clone(MEM_ROOT *mem_root) void handler::ha_statistic_increment(ulong SSV::*offset) const { - statistic_increment(table->in_use->status_var.*offset, &LOCK_status); + status_var_increment(table->in_use->status_var.*offset); } void **handler::ha_data(THD *thd) const @@ -2836,7 +2835,7 @@ int ha_discover(THD *thd, const char *db, const char *name, error= 0; if (!error) - statistic_increment(thd->status_var.ha_discover_count,&LOCK_status); + status_var_increment(thd->status_var.ha_discover_count); DBUG_RETURN(error); } -- cgit v1.2.1