Commit c4a5cf11 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 d48a8b60
......@@ -51,7 +51,6 @@ typedef struct st_queue {
#define queue_top(queue) ((queue)->root[1])
#define queue_element(queue,index) ((queue)->root[index])
#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_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg
#define queue_set_max_at_top(queue, set_arg) \
......@@ -72,6 +71,8 @@ void delete_queue(QUEUE *queue);
void queue_insert(QUEUE *queue,uchar *element);
int queue_insert_safe(QUEUE *queue, uchar *element);
uchar *queue_remove(QUEUE *queue,uint idx);
void queue_replace(QUEUE *queue,uint idx);
#define queue_remove_all(queue) { (queue)->elements= 0; }
#define queue_is_full(queue) (queue->elements == queue->max_elements)
void _downheap(QUEUE *queue, uint idx, uchar *element);
......
......@@ -280,6 +280,9 @@ uchar *queue_remove(register QUEUE *queue, uint idx)
queue Queue to use
idx Index of element to change
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)
......@@ -353,3 +356,22 @@ void queue_fix(QUEUE *queue)
for (i= queue->elements >> 1; i > 0; 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)
void thr_alarm_kill(my_thread_id thread_id)
{
uint i;
DBUG_ENTER("thr_alarm_kill");
if (alarm_aborted)
return;
pthread_mutex_lock(&LOCK_alarm);
......@@ -475,6 +477,7 @@ void thr_alarm_kill(my_thread_id thread_id)
ALARM *element= (ALARM*) queue_element(&alarm_queue,i);
if (element->thread_id == thread_id)
{
DBUG_PRINT("info", ("found thread; Killing it"));
element->expire_time= 0;
queue_replace(&alarm_queue, i);
reschedule_alarms();
......@@ -482,6 +485,7 @@ void thr_alarm_kill(my_thread_id thread_id)
}
}
pthread_mutex_unlock(&LOCK_alarm);
DBUG_VOID_RETURN;
}
......
......@@ -4827,7 +4827,8 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
DBUG_ASSERT(cur_keyid == keys_count);
/* 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,
current_thd->variables.read_buff_size);
tmp_table->null_row= 0;
......@@ -5008,7 +5009,11 @@ bool subselect_rowid_merge_engine::partial_match()
DBUG_ASSERT(!pq.elements);
/* 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. */
if (non_null_key && !non_null_key->lookup())
......@@ -5175,7 +5180,12 @@ bool subselect_table_scan_engine::partial_match()
int error;
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,
current_thd->variables.read_buff_size);
/*
......
......@@ -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 *
sizeof(Column_statistics));
if (!stat)
if (!col_stat)
return TRUE;
reset();
......
......@@ -4103,7 +4103,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
}
else
{
char option_buff[350],*ptr;
char option_buff[350];
String str(option_buff,sizeof(option_buff), system_charset_info);
TABLE *show_table= tables->table;
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