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