Commit 5e9b8038 authored by Michael Widenius's avatar Michael Widenius

Fixed wrong queue_replace(), which caused timeout failure in pbxt.flush_read_lock_kill

Fixed compiler warnings.

include/queues.h:
  Added prototype for queue_replace()
mysys/queues.c:
  Fixed wrong queue_replace()
mysys/thr_alarm.c:
  Added DBUG_PRINT
sql/item_subselect.cc:
  Check return value of ha_rnd_init().
  (Fixes compiler warnings)
sql/sql_class.cc:
  Fixed wrong test
sql/sql_show.cc:
  Removed not used variable.
parent f8a338a3
...@@ -51,7 +51,6 @@ typedef struct st_queue { ...@@ -51,7 +51,6 @@ typedef struct st_queue {
#define queue_top(queue) ((queue)->root[1]) #define queue_top(queue) ((queue)->root[1])
#define queue_element(queue,index) ((queue)->root[index]) #define queue_element(queue,index) ((queue)->root[index])
#define queue_end(queue) ((queue)->root[(queue)->elements]) #define queue_end(queue) ((queue)->root[(queue)->elements])
#define queue_replace(queue, idx) _downheap(queue, idx, (queue)->root[idx])
#define queue_replace_top(queue) _downheap(queue, 1, (queue)->root[1]) #define queue_replace_top(queue) _downheap(queue, 1, (queue)->root[1])
#define queue_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg #define queue_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg
#define queue_set_max_at_top(queue, set_arg) \ #define queue_set_max_at_top(queue, set_arg) \
...@@ -72,6 +71,8 @@ void delete_queue(QUEUE *queue); ...@@ -72,6 +71,8 @@ void delete_queue(QUEUE *queue);
void queue_insert(QUEUE *queue,uchar *element); void queue_insert(QUEUE *queue,uchar *element);
int queue_insert_safe(QUEUE *queue, uchar *element); int queue_insert_safe(QUEUE *queue, uchar *element);
uchar *queue_remove(QUEUE *queue,uint idx); uchar *queue_remove(QUEUE *queue,uint idx);
void queue_replace(QUEUE *queue,uint idx);
#define queue_remove_all(queue) { (queue)->elements= 0; } #define queue_remove_all(queue) { (queue)->elements= 0; }
#define queue_is_full(queue) (queue->elements == queue->max_elements) #define queue_is_full(queue) (queue->elements == queue->max_elements)
void _downheap(QUEUE *queue, uint idx, uchar *element); void _downheap(QUEUE *queue, uint idx, uchar *element);
......
...@@ -280,6 +280,9 @@ uchar *queue_remove(register QUEUE *queue, uint idx) ...@@ -280,6 +280,9 @@ uchar *queue_remove(register QUEUE *queue, uint idx)
queue Queue to use queue Queue to use
idx Index of element to change idx Index of element to change
element Element to store at 'idx' element Element to store at 'idx'
NOTE
This only works if element is >= all elements <= start_idx
*/ */
void _downheap(register QUEUE *queue, uint start_idx, uchar *element) void _downheap(register QUEUE *queue, uint start_idx, uchar *element)
...@@ -353,3 +356,22 @@ void queue_fix(QUEUE *queue) ...@@ -353,3 +356,22 @@ void queue_fix(QUEUE *queue)
for (i= queue->elements >> 1; i > 0; i--) for (i= queue->elements >> 1; i > 0; i--)
_downheap(queue, i, queue_element(queue, i)); _downheap(queue, i, queue_element(queue, i));
} }
/*
Change element at fixed position
SYNOPSIS
queue_replace()
queue Queue to use
idx Index of element to change
element Element to store at 'idx'
*/
void queue_replace(QUEUE *queue, uint idx)
{
uchar *element= queue->root[idx];
DBUG_ASSERT(idx >= 1 && idx <= queue->elements);
queue_remove(queue, idx);
queue_insert(queue, element);
}
...@@ -465,6 +465,8 @@ void end_thr_alarm(my_bool free_structures) ...@@ -465,6 +465,8 @@ void end_thr_alarm(my_bool free_structures)
void thr_alarm_kill(my_thread_id thread_id) void thr_alarm_kill(my_thread_id thread_id)
{ {
uint i; uint i;
DBUG_ENTER("thr_alarm_kill");
if (alarm_aborted) if (alarm_aborted)
return; return;
pthread_mutex_lock(&LOCK_alarm); pthread_mutex_lock(&LOCK_alarm);
...@@ -475,6 +477,7 @@ void thr_alarm_kill(my_thread_id thread_id) ...@@ -475,6 +477,7 @@ void thr_alarm_kill(my_thread_id thread_id)
ALARM *element= (ALARM*) queue_element(&alarm_queue,i); ALARM *element= (ALARM*) queue_element(&alarm_queue,i);
if (element->thread_id == thread_id) if (element->thread_id == thread_id)
{ {
DBUG_PRINT("info", ("found thread; Killing it"));
element->expire_time= 0; element->expire_time= 0;
queue_replace(&alarm_queue, i); queue_replace(&alarm_queue, i);
reschedule_alarms(); reschedule_alarms();
...@@ -482,6 +485,7 @@ void thr_alarm_kill(my_thread_id thread_id) ...@@ -482,6 +485,7 @@ void thr_alarm_kill(my_thread_id thread_id)
} }
} }
pthread_mutex_unlock(&LOCK_alarm); pthread_mutex_unlock(&LOCK_alarm);
DBUG_VOID_RETURN;
} }
......
...@@ -4827,7 +4827,8 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts, ...@@ -4827,7 +4827,8 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
DBUG_ASSERT(cur_keyid == keys_count); DBUG_ASSERT(cur_keyid == keys_count);
/* Populate the indexes with data from the temporary table. */ /* Populate the indexes with data from the temporary table. */
tmp_table->file->ha_rnd_init(1); if (tmp_table->file->ha_rnd_init_with_error(1))
return TRUE;
tmp_table->file->extra_opt(HA_EXTRA_CACHE, tmp_table->file->extra_opt(HA_EXTRA_CACHE,
current_thd->variables.read_buff_size); current_thd->variables.read_buff_size);
tmp_table->null_row= 0; tmp_table->null_row= 0;
...@@ -5008,7 +5009,11 @@ bool subselect_rowid_merge_engine::partial_match() ...@@ -5008,7 +5009,11 @@ bool subselect_rowid_merge_engine::partial_match()
DBUG_ASSERT(!pq.elements); DBUG_ASSERT(!pq.elements);
/* All data accesses during execution are via handler::ha_rnd_pos() */ /* All data accesses during execution are via handler::ha_rnd_pos() */
tmp_table->file->ha_rnd_init(0); if (tmp_table->file->ha_rnd_init_with_error(0))
{
res= FALSE;
goto end;
}
/* Check if there is a match for the columns of the only non-NULL key. */ /* Check if there is a match for the columns of the only non-NULL key. */
if (non_null_key && !non_null_key->lookup()) if (non_null_key && !non_null_key->lookup())
...@@ -5175,7 +5180,12 @@ bool subselect_table_scan_engine::partial_match() ...@@ -5175,7 +5180,12 @@ bool subselect_table_scan_engine::partial_match()
int error; int error;
bool res; bool res;
tmp_table->file->ha_rnd_init(1); if (tmp_table->file->ha_rnd_init_with_error(1))
{
res= FALSE;
goto end;
}
tmp_table->file->extra_opt(HA_EXTRA_CACHE, tmp_table->file->extra_opt(HA_EXTRA_CACHE,
current_thd->variables.read_buff_size); current_thd->variables.read_buff_size);
/* /*
......
...@@ -3017,7 +3017,7 @@ create_result_table(THD *thd_arg, List<Item> *column_types, ...@@ -3017,7 +3017,7 @@ create_result_table(THD *thd_arg, List<Item> *column_types,
col_stat= (Column_statistics*) table->in_use->alloc(table->s->fields * col_stat= (Column_statistics*) table->in_use->alloc(table->s->fields *
sizeof(Column_statistics)); sizeof(Column_statistics));
if (!stat) if (!col_stat)
return TRUE; return TRUE;
reset(); reset();
......
...@@ -4103,7 +4103,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, ...@@ -4103,7 +4103,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
} }
else else
{ {
char option_buff[350],*ptr; char option_buff[350];
String str(option_buff,sizeof(option_buff), system_charset_info); String str(option_buff,sizeof(option_buff), system_charset_info);
TABLE *show_table= tables->table; TABLE *show_table= tables->table;
TABLE_SHARE *share= show_table->s; TABLE_SHARE *share= show_table->s;
......
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