Commit cd29aee5 authored by Sergei Golubchik's avatar Sergei Golubchik

misc cleanup

parent 1823ce73
......@@ -60,9 +60,7 @@ static bool save_index(Sort_param *param, uint count,
static uint suffix_length(ulong string_length);
static uint sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
bool *multi_byte_charset);
static SORT_ADDON_FIELD *get_addon_fields(ulong max_length_for_sort_data,
Field **ptabfield,
uint sortlength,
static SORT_ADDON_FIELD *get_addon_fields(TABLE *table, uint sortlength,
LEX_STRING *addon_buf);
static void unpack_addon_fields(struct st_sort_addon_field *addon_field,
uchar *buff, uchar *buff_end);
......@@ -71,7 +69,6 @@ static bool check_if_pq_applicable(Sort_param *param, SORT_INFO *info,
ha_rows records, size_t memory_available);
void Sort_param::init_for_filesort(uint sortlen, TABLE *table,
ulong max_length_for_sort_data,
ha_rows maxrows, bool sort_positions)
{
DBUG_ASSERT(addon_field == 0 && addon_buf.length == 0);
......@@ -85,8 +82,7 @@ void Sort_param::init_for_filesort(uint sortlen, TABLE *table,
Get the descriptors of all fields whose values are appended
to sorted fields and get its total length in addon_buf.length
*/
addon_field= get_addon_fields(max_length_for_sort_data,
table->field, sort_length, &addon_buf);
addon_field= get_addon_fields(table, sort_length, &addon_buf);
}
if (addon_field)
{
......@@ -190,9 +186,7 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
param.init_for_filesort(sortlength(thd, filesort->sortorder, s_length,
&multi_byte_charset),
table,
thd->variables.max_length_for_sort_data,
max_rows, filesort->sort_positions);
table, max_rows, filesort->sort_positions);
sort->addon_buf= param.addon_buf;
sort->addon_field= param.addon_field;
......@@ -1992,8 +1986,7 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
*/
static SORT_ADDON_FIELD *
get_addon_fields(ulong max_length_for_sort_data,
Field **ptabfield, uint sortlength, LEX_STRING *addon_buf)
get_addon_fields(TABLE *table, uint sortlength, LEX_STRING *addon_buf)
{
Field **pfield;
Field *field;
......@@ -2001,7 +1994,8 @@ get_addon_fields(ulong max_length_for_sort_data,
uint length= 0;
uint fields= 0;
uint null_fields= 0;
MY_BITMAP *read_set= (*ptabfield)->table->read_set;
MY_BITMAP *read_set= table->read_set;
ulong max_sort_len= table->in_use->variables.max_length_for_sort_data;
DBUG_ENTER("get_addon_fields");
/*
......@@ -2017,7 +2011,7 @@ get_addon_fields(ulong max_length_for_sort_data,
addon_buf->str= 0;
addon_buf->length= 0;
for (pfield= ptabfield; (field= *pfield) ; pfield++)
for (pfield= table->field; (field= *pfield) ; pfield++)
{
if (!bitmap_is_set(read_set, field->field_index))
continue;
......@@ -2032,7 +2026,7 @@ get_addon_fields(ulong max_length_for_sort_data,
DBUG_RETURN(0);
length+= (null_fields+7)/8;
if (length+sortlength > max_length_for_sort_data ||
if (length+sortlength > max_sort_len ||
!my_multi_malloc(MYF(MY_WME | MY_THREAD_SPECIFIC),
&addonf, sizeof(SORT_ADDON_FIELD) * (fields+1),
&addon_buf->str, length,
......@@ -2043,7 +2037,7 @@ get_addon_fields(ulong max_length_for_sort_data,
addon_buf->length= length;
length= (null_fields+7)/8;
null_fields= 0;
for (pfield= ptabfield; (field= *pfield) ; pfield++)
for (pfield= table->field; (field= *pfield) ; pfield++)
{
if (!bitmap_is_set(read_set, field->field_index))
continue;
......
......@@ -5795,7 +5795,7 @@ int
Ordered_key::cmp_keys_by_row_data(ha_rows a, ha_rows b)
{
uchar *rowid_a, *rowid_b;
int __attribute__((unused)) error;
int error;
int cmp_res;
/* The length in bytes of the rowids (positions) of tmp_table. */
uint rowid_length= tbl->file->ref_length;
......@@ -5892,7 +5892,7 @@ int Ordered_key::cmp_key_with_search_key(rownum_t row_num)
/* The length in bytes of the rowids (positions) of tmp_table. */
uint rowid_length= tbl->file->ref_length;
uchar *cur_rowid= row_num_to_rowid + row_num * rowid_length;
int __attribute__((unused)) error;
int error;
int cmp_res;
if (unlikely((error= tbl->file->ha_rnd_pos(tbl->record[0], cur_rowid))))
......
......@@ -2501,7 +2501,7 @@ int JOIN::optimize_stage2()
{
JOIN_TAB *tab= &join_tab[const_tables];
if (order)
if (order && !need_tmp)
{
/*
Force using of tmp table if sorting by a SP or UDF function due to
......@@ -3206,7 +3206,7 @@ bool JOIN::make_aggr_tables_info()
or end_write_group()) if JOIN::group is set to false.
*/
// the temporary table was explicitly requested
DBUG_ASSERT(MY_TEST(select_options & OPTION_BUFFER_RESULT));
DBUG_ASSERT(select_options & OPTION_BUFFER_RESULT);
// the temporary table does not have a grouping expression
DBUG_ASSERT(!curr_tab->table->group);
}
......@@ -13191,7 +13191,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
tab++)
tab->cached_eq_ref_table= FALSE;
*simple_order= *join->join_tab[join->const_tables].on_expr_ref ? 0 : 1;
JOIN_TAB *head= join->join_tab + join->const_tables;
*simple_order= head->on_expr_ref[0] == NULL;
}
else
{
......
......@@ -92,7 +92,6 @@ class Sort_param {
memset(this, 0, sizeof(*this));
}
void init_for_filesort(uint sortlen, TABLE *table,
ulong max_length_for_sort_data,
ha_rows maxrows, bool sort_positions);
};
......
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