mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Prevent bugs by making DBUG_* expressions syntactically equivalent
to a single statement. --- Bug#24795: SHOW PROFILE Profiling is only partially functional on some architectures. Where there is no getrusage() system call, presently Null values are returned where it would be required. Notably, Windows needs some love applied to make it as useful. Syntax this adds: SHOW PROFILES SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n] where "n" is an integer and "types" is zero or many (comma-separated) of "CPU" "MEMORY" (not presently supported) "BLOCK IO" "CONTEXT SWITCHES" "PAGE FAULTS" "IPC" "SWAPS" "SOURCE" "ALL" It also adds a session variable (boolean) "profiling", set to "no" by default, and (integer) profiling_history_size, set to 15 by default. This patch abstracts setting THDs' "proc_info" behind a macro that can be used as a hook into the profiling code when profiling support is compiled in. All future code in this line should use that mechanism for setting thd->proc_info. --- Tests are now set to omit the statistics. --- Adds an Information_schema table, "profiling" for access to "show profile" data. --- Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community-3--bug24795 into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-community --- Fix merge problems. --- Fixed one bug in the query_source being NULL. Updated test results. --- Include more thorough profiling tests. Improve support for prepared statements. Use session-specific query IDs, starting at zero. --- Selecting from I_S.profiling is no longer quashed in profiling, as requested by Giuseppe. Limit the size of captured query text. No longer log queries that are zero length.
This commit is contained in:
@ -397,7 +397,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
if (res || thd->is_fatal_error)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
THD_PROC_INFO(thd, "init");
|
||||
thd_proc_info(thd, "init");
|
||||
thd->used_tables=0;
|
||||
values= its++;
|
||||
|
||||
@ -470,7 +470,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
|
||||
error=0;
|
||||
id=0;
|
||||
THD_PROC_INFO(thd, "update");
|
||||
thd_proc_info(thd, "update");
|
||||
if (duplic != DUP_ERROR || ignore)
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
if (duplic == DUP_REPLACE)
|
||||
@ -676,7 +676,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
thd->lock=0;
|
||||
}
|
||||
}
|
||||
THD_PROC_INFO(thd, "end");
|
||||
thd_proc_info(thd, "end");
|
||||
table->next_number_field=0;
|
||||
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||
thd->next_insert_id=0; // Reset this if wrongly used
|
||||
@ -1407,7 +1407,7 @@ I_List<delayed_insert> delayed_threads;
|
||||
|
||||
delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
|
||||
{
|
||||
THD_PROC_INFO(thd, "waiting for delay_list");
|
||||
thd_proc_info(thd, "waiting for delay_list");
|
||||
pthread_mutex_lock(&LOCK_delayed_insert); // Protect master list
|
||||
I_List_iterator<delayed_insert> it(delayed_threads);
|
||||
delayed_insert *tmp;
|
||||
@ -1444,7 +1444,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
|
||||
*/
|
||||
if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
|
||||
DBUG_RETURN(0);
|
||||
THD_PROC_INFO(thd, "Creating delayed handler");
|
||||
thd_proc_info(thd, "Creating delayed handler");
|
||||
pthread_mutex_lock(&LOCK_delayed_create);
|
||||
/*
|
||||
The first search above was done without LOCK_delayed_create.
|
||||
@ -1486,13 +1486,13 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
|
||||
}
|
||||
|
||||
/* Wait until table is open */
|
||||
THD_PROC_INFO(thd, "waiting for handler open");
|
||||
thd_proc_info(thd, "waiting for handler open");
|
||||
while (!tmp->thd.killed && !tmp->table && !thd->killed)
|
||||
{
|
||||
pthread_cond_wait(&tmp->cond_client,&tmp->mutex);
|
||||
}
|
||||
pthread_mutex_unlock(&tmp->mutex);
|
||||
THD_PROC_INFO(thd, "got old table");
|
||||
thd_proc_info(thd, "got old table");
|
||||
if (tmp->thd.killed)
|
||||
{
|
||||
if (tmp->thd.is_fatal_error)
|
||||
@ -1552,13 +1552,13 @@ TABLE *delayed_insert::get_local_table(THD* client_thd)
|
||||
tables_in_use++;
|
||||
if (!thd.lock) // Table is not locked
|
||||
{
|
||||
THD_PROC_INFO(client_thd, "waiting for handler lock");
|
||||
thd_proc_info(client_thd, "waiting for handler lock");
|
||||
pthread_cond_signal(&cond); // Tell handler to lock table
|
||||
while (!dead && !thd.lock && ! client_thd->killed)
|
||||
{
|
||||
pthread_cond_wait(&cond_client,&mutex);
|
||||
}
|
||||
THD_PROC_INFO(client_thd, "got handler lock");
|
||||
thd_proc_info(client_thd, "got handler lock");
|
||||
if (client_thd->killed)
|
||||
goto error;
|
||||
if (dead)
|
||||
@ -1576,7 +1576,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd)
|
||||
bytes. Since the table copy is used for creating one record only,
|
||||
the other record buffers and alignment are unnecessary.
|
||||
*/
|
||||
THD_PROC_INFO(client_thd, "allocating local table");
|
||||
thd_proc_info(client_thd, "allocating local table");
|
||||
copy= (TABLE*) client_thd->alloc(sizeof(*copy)+
|
||||
(table->s->fields+1)*sizeof(Field**)+
|
||||
table->s->reclength);
|
||||
@ -1656,11 +1656,11 @@ static int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic, bool igno
|
||||
delayed_insert *di=thd->di;
|
||||
DBUG_ENTER("write_delayed");
|
||||
|
||||
THD_PROC_INFO(thd, "waiting for handler insert");
|
||||
thd_proc_info(thd, "waiting for handler insert");
|
||||
pthread_mutex_lock(&di->mutex);
|
||||
while (di->stacked_inserts >= delayed_queue_size && !thd->killed)
|
||||
pthread_cond_wait(&di->cond_client,&di->mutex);
|
||||
THD_PROC_INFO(thd, "storing row into queue");
|
||||
thd_proc_info(thd, "storing row into queue");
|
||||
|
||||
if (thd->killed || !(row= new delayed_row(duplic, ignore, log_on)))
|
||||
goto err;
|
||||
@ -1869,7 +1869,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
||||
/* Information for pthread_kill */
|
||||
di->thd.mysys_var->current_mutex= &di->mutex;
|
||||
di->thd.mysys_var->current_cond= &di->cond;
|
||||
THD_PROC_INFO(&(di->thd), "Waiting for INSERT");
|
||||
thd_proc_info(&(di->thd), "Waiting for INSERT");
|
||||
|
||||
DBUG_PRINT("info",("Waiting for someone to insert rows"));
|
||||
while (!thd->killed)
|
||||
@ -1904,7 +1904,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
|
||||
pthread_mutex_unlock(&di->thd.mysys_var->mutex);
|
||||
pthread_mutex_lock(&di->mutex);
|
||||
}
|
||||
THD_PROC_INFO(&(di->thd), 0);
|
||||
thd_proc_info(&(di->thd), 0);
|
||||
|
||||
if (di->tables_in_use && ! thd->lock)
|
||||
{
|
||||
@ -2023,7 +2023,7 @@ bool delayed_insert::handle_inserts(void)
|
||||
|
||||
table->next_number_field=table->found_next_number_field;
|
||||
|
||||
THD_PROC_INFO(&thd, "upgrading lock");
|
||||
thd_proc_info(&thd, "upgrading lock");
|
||||
if (thr_upgrade_write_delay_lock(*thd.lock->locks))
|
||||
{
|
||||
/* This can only happen if thread is killed by shutdown */
|
||||
@ -2031,7 +2031,7 @@ bool delayed_insert::handle_inserts(void)
|
||||
goto err;
|
||||
}
|
||||
|
||||
THD_PROC_INFO(&thd, "insert");
|
||||
thd_proc_info(&thd, "insert");
|
||||
max_rows= delayed_insert_limit;
|
||||
if (thd.killed || table->s->version != refresh_version)
|
||||
{
|
||||
@ -2149,7 +2149,7 @@ bool delayed_insert::handle_inserts(void)
|
||||
{
|
||||
if (tables_in_use)
|
||||
pthread_cond_broadcast(&cond_client); // If waiting clients
|
||||
THD_PROC_INFO(&thd, "reschedule");
|
||||
thd_proc_info(&thd, "reschedule");
|
||||
pthread_mutex_unlock(&mutex);
|
||||
if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
|
||||
{
|
||||
@ -2168,14 +2168,14 @@ bool delayed_insert::handle_inserts(void)
|
||||
if (!using_bin_log)
|
||||
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
pthread_mutex_lock(&mutex);
|
||||
THD_PROC_INFO(&thd, "insert");
|
||||
thd_proc_info(&thd, "insert");
|
||||
}
|
||||
if (tables_in_use)
|
||||
pthread_cond_broadcast(&cond_client); // If waiting clients
|
||||
}
|
||||
}
|
||||
|
||||
THD_PROC_INFO(&thd, 0);
|
||||
thd_proc_info(&thd, 0);
|
||||
table->next_number_field=0;
|
||||
pthread_mutex_unlock(&mutex);
|
||||
if ((error=table->file->extra(HA_EXTRA_NO_CACHE)))
|
||||
|
Reference in New Issue
Block a user