mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
merged 5.1-bugteam into B37548 tree
This commit is contained in:
@@ -888,6 +888,7 @@ JOIN::optimize()
|
||||
{
|
||||
DBUG_PRINT("info",("No matching min/max row"));
|
||||
zero_result_cause= "No matching min/max row";
|
||||
tables= 0;
|
||||
error=0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@@ -901,6 +902,7 @@ JOIN::optimize()
|
||||
{
|
||||
DBUG_PRINT("info",("No matching min/max row"));
|
||||
zero_result_cause= "No matching min/max row";
|
||||
tables= 0;
|
||||
error=0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@@ -6752,6 +6754,12 @@ void JOIN::cleanup(bool full)
|
||||
if (tmp_join)
|
||||
tmp_table_param.copy_field= 0;
|
||||
group_fields.delete_elements();
|
||||
/*
|
||||
Ensure that the above delete_elements() would not be called
|
||||
twice for the same list.
|
||||
*/
|
||||
if (tmp_join && tmp_join != this)
|
||||
tmp_join->group_fields= group_fields;
|
||||
/*
|
||||
We can't call delete_elements() on copy_funcs as this will cause
|
||||
problems in free_elements() as some of the elements are then deleted.
|
||||
@@ -11711,7 +11719,7 @@ join_init_read_record(JOIN_TAB *tab)
|
||||
if (tab->select && tab->select->quick && tab->select->quick->reset())
|
||||
return 1;
|
||||
init_read_record(&tab->read_record, tab->join->thd, tab->table,
|
||||
tab->select,1,1);
|
||||
tab->select,1,1, FALSE);
|
||||
return (*tab->read_record.read_record)(&tab->read_record);
|
||||
}
|
||||
|
||||
@@ -12506,6 +12514,9 @@ part_of_refkey(TABLE *table,Field *field)
|
||||
@note
|
||||
used_key_parts is set to correct key parts used if return value != 0
|
||||
(On other cases, used_key_part may be changed)
|
||||
Note that the value may actually be greater than the number of index
|
||||
key parts. This can happen for storage engines that have the primary
|
||||
key parts as a suffix for every secondary key.
|
||||
|
||||
@retval
|
||||
1 key is ok.
|
||||
@@ -12578,11 +12589,27 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
|
||||
reverse=flag; // Remember if reverse
|
||||
key_part++;
|
||||
}
|
||||
*used_key_parts= on_primary_key ? table->key_info[idx].key_parts :
|
||||
(uint) (key_part - table->key_info[idx].key_part);
|
||||
if (reverse == -1 && !(table->file->index_flags(idx, *used_key_parts-1, 1) &
|
||||
HA_READ_PREV))
|
||||
reverse= 0; // Index can't be used
|
||||
if (on_primary_key)
|
||||
{
|
||||
uint used_key_parts_secondary= table->key_info[idx].key_parts;
|
||||
uint used_key_parts_pk=
|
||||
(uint) (key_part - table->key_info[table->s->primary_key].key_part);
|
||||
*used_key_parts= used_key_parts_pk + used_key_parts_secondary;
|
||||
|
||||
if (reverse == -1 &&
|
||||
(!(table->file->index_flags(idx, used_key_parts_secondary - 1, 1) &
|
||||
HA_READ_PREV) ||
|
||||
!(table->file->index_flags(table->s->primary_key,
|
||||
used_key_parts_pk - 1, 1) & HA_READ_PREV)))
|
||||
reverse= 0; // Index can't be used
|
||||
}
|
||||
else
|
||||
{
|
||||
*used_key_parts= (uint) (key_part - table->key_info[idx].key_part);
|
||||
if (reverse == -1 &&
|
||||
!(table->file->index_flags(idx, *used_key_parts-1, 1) & HA_READ_PREV))
|
||||
reverse= 0; // Index can't be used
|
||||
}
|
||||
DBUG_RETURN(reverse);
|
||||
}
|
||||
|
||||
@@ -13187,6 +13214,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
||||
tab->ref.key= -1;
|
||||
tab->ref.key_parts=0; // Don't use ref key.
|
||||
tab->read_first_record= join_init_read_record;
|
||||
if (tab->is_using_loose_index_scan())
|
||||
join->tmp_table_param.precomputed_group_by= TRUE;
|
||||
/*
|
||||
TODO: update the number of records in join->best_positions[tablenr]
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user