mirror of
https://github.com/MariaDB/server.git
synced 2025-06-16 11:21:15 +03:00
Added THD as parameter to filesort. Removed not used 'special' argument.
This commit is contained in:
@ -63,24 +63,21 @@ static uint sortlength(SORT_FIELD *sortorder,uint length);
|
|||||||
table->record_pointers
|
table->record_pointers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||||
SQL_SELECT *select, ha_rows special, ha_rows max_rows,
|
SQL_SELECT *select, ha_rows max_rows, ha_rows *examined_rows)
|
||||||
ha_rows *examined_rows)
|
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
ulong memavl;
|
ulong memavl;
|
||||||
uint maxbuffer;
|
uint maxbuffer;
|
||||||
|
uint i;
|
||||||
BUFFPEK *buffpek;
|
BUFFPEK *buffpek;
|
||||||
ha_rows records;
|
ha_rows records;
|
||||||
uchar **sort_keys;
|
uchar **sort_keys;
|
||||||
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
|
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
|
||||||
SORTPARAM param;
|
SORTPARAM param;
|
||||||
THD *thd= current_thd;
|
|
||||||
|
|
||||||
DBUG_ENTER("filesort");
|
|
||||||
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special););
|
|
||||||
CHARSET_INFO *charset=table->table_charset;
|
CHARSET_INFO *charset=table->table_charset;
|
||||||
uint i;
|
DBUG_ENTER("filesort");
|
||||||
|
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length););
|
||||||
#ifdef SKIP_DBUG_IN_FILESORT
|
#ifdef SKIP_DBUG_IN_FILESORT
|
||||||
DBUG_PUSH(""); /* No DBUG here */
|
DBUG_PUSH(""); /* No DBUG here */
|
||||||
#endif
|
#endif
|
||||||
@ -111,27 +108,15 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
|||||||
{
|
{
|
||||||
statistic_increment(filesort_scan_count, &LOCK_status);
|
statistic_increment(filesort_scan_count, &LOCK_status);
|
||||||
}
|
}
|
||||||
if (select && my_b_inited(&select->file))
|
|
||||||
{
|
|
||||||
records=special=select->records; /* purecov: deadcode */
|
|
||||||
selected_records_file= &select->file; /* purecov: deadcode */
|
|
||||||
reinit_io_cache(selected_records_file,READ_CACHE,0L,0,0); /* purecov: deadcode */
|
|
||||||
}
|
|
||||||
else if (special)
|
|
||||||
{
|
|
||||||
records=special; /* purecov: deadcode */
|
|
||||||
selected_records_file= outfile; /* purecov: deadcode */
|
|
||||||
reinit_io_cache(selected_records_file,READ_CACHE,0L,0,0); /* purecov: deadcode */
|
|
||||||
}
|
|
||||||
#ifdef CAN_TRUST_RANGE
|
#ifdef CAN_TRUST_RANGE
|
||||||
else if (select && select->quick && select->quick->records > 0L)
|
if (select && select->quick && select->quick->records > 0L)
|
||||||
{
|
{
|
||||||
records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
|
records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
|
||||||
table->file->records)+EXTRA_RECORDS;
|
table->file->records)+EXTRA_RECORDS;
|
||||||
selected_records_file=0;
|
selected_records_file=0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
records=table->file->estimate_number_of_rows();
|
records=table->file->estimate_number_of_rows();
|
||||||
selected_records_file= 0;
|
selected_records_file= 0;
|
||||||
|
@ -611,7 +611,7 @@ pthread_handler_decl(handle_manager, arg);
|
|||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
void print_where(COND *cond,const char *info);
|
void print_where(COND *cond,const char *info);
|
||||||
void print_cached_tables(void);
|
void print_cached_tables(void);
|
||||||
void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special);
|
void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
|
||||||
#endif
|
#endif
|
||||||
void mysql_print_status(THD *thd);
|
void mysql_print_status(THD *thd);
|
||||||
/* key.cc */
|
/* key.cc */
|
||||||
@ -792,9 +792,9 @@ void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
|
|||||||
SQL_SELECT *select,
|
SQL_SELECT *select,
|
||||||
int use_record_cache, bool print_errors);
|
int use_record_cache, bool print_errors);
|
||||||
void end_read_record(READ_RECORD *info);
|
void end_read_record(READ_RECORD *info);
|
||||||
ha_rows filesort(TABLE *form,struct st_sort_field *sortorder, uint s_length,
|
ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
|
||||||
SQL_SELECT *select, ha_rows special,ha_rows max_rows,
|
uint s_length, SQL_SELECT *select,
|
||||||
ha_rows *examined_rows);
|
ha_rows max_rows, ha_rows *examined_rows);
|
||||||
void change_double_for_sort(double nr,byte *to);
|
void change_double_for_sort(double nr,byte *to);
|
||||||
int get_quick_record(SQL_SELECT *select);
|
int get_quick_record(SQL_SELECT *select);
|
||||||
int calc_weekday(long daynr,bool sunday_first_day_of_week);
|
int calc_weekday(long daynr,bool sunday_first_day_of_week);
|
||||||
|
@ -117,8 +117,8 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
|
|||||||
MYF(MY_FAE | MY_ZEROFILL));
|
MYF(MY_FAE | MY_ZEROFILL));
|
||||||
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
||||||
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
||||||
(table->found_records = filesort(table, sortorder, length,
|
(table->found_records = filesort(thd, table, sortorder, length,
|
||||||
(SQL_SELECT *) 0, 0L, HA_POS_ERROR,
|
(SQL_SELECT *) 0, HA_POS_ERROR,
|
||||||
&examined_rows))
|
&examined_rows))
|
||||||
== HA_POS_ERROR)
|
== HA_POS_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,8 @@ static Item* part_of_refkey(TABLE *form,Field *field);
|
|||||||
static uint find_shortest_key(TABLE *table, key_map usable_keys);
|
static uint find_shortest_key(TABLE *table, key_map usable_keys);
|
||||||
static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,
|
static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,
|
||||||
ha_rows select_limit, bool no_changes);
|
ha_rows select_limit, bool no_changes);
|
||||||
static int create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit);
|
static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order,
|
||||||
|
ha_rows select_limit);
|
||||||
static int remove_duplicates(JOIN *join,TABLE *entry,List<Item> &fields,
|
static int remove_duplicates(JOIN *join,TABLE *entry,List<Item> &fields,
|
||||||
Item *having);
|
Item *having);
|
||||||
static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field,
|
static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field,
|
||||||
@ -748,7 +749,7 @@ JOIN::exec()
|
|||||||
{
|
{
|
||||||
DBUG_PRINT("info",("Sorting for group"));
|
DBUG_PRINT("info",("Sorting for group"));
|
||||||
thd->proc_info="Sorting for group";
|
thd->proc_info="Sorting for group";
|
||||||
if (create_sort_index(&join_tab[const_tables], group_list,
|
if (create_sort_index(thd, &join_tab[const_tables], group_list,
|
||||||
HA_POS_ERROR) ||
|
HA_POS_ERROR) ||
|
||||||
make_sum_func_list(this, all_fields) ||
|
make_sum_func_list(this, all_fields) ||
|
||||||
alloc_group_fields(this, group_list))
|
alloc_group_fields(this, group_list))
|
||||||
@ -763,7 +764,7 @@ JOIN::exec()
|
|||||||
{
|
{
|
||||||
DBUG_PRINT("info",("Sorting for order"));
|
DBUG_PRINT("info",("Sorting for order"));
|
||||||
thd->proc_info="Sorting for order";
|
thd->proc_info="Sorting for order";
|
||||||
if (create_sort_index(&join_tab[const_tables], order,
|
if (create_sort_index(thd, &join_tab[const_tables], order,
|
||||||
HA_POS_ERROR))
|
HA_POS_ERROR))
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
order=0;
|
order=0;
|
||||||
@ -866,7 +867,7 @@ JOIN::exec()
|
|||||||
if (group_list)
|
if (group_list)
|
||||||
{
|
{
|
||||||
thd->proc_info="Creating sort index";
|
thd->proc_info="Creating sort index";
|
||||||
if (create_sort_index(join_tab, group_list, HA_POS_ERROR) ||
|
if (create_sort_index(thd, join_tab, group_list, HA_POS_ERROR) ||
|
||||||
alloc_group_fields(this, group_list))
|
alloc_group_fields(this, group_list))
|
||||||
{
|
{
|
||||||
free_tmp_table(thd,tmp_table2); /* purecov: inspected */
|
free_tmp_table(thd,tmp_table2); /* purecov: inspected */
|
||||||
@ -962,7 +963,7 @@ JOIN::exec()
|
|||||||
DBUG_EXECUTE("where",print_where(conds,"having after sort"););
|
DBUG_EXECUTE("where",print_where(conds,"having after sort"););
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (create_sort_index(&join_tab[const_tables],
|
if (create_sort_index(thd, &join_tab[const_tables],
|
||||||
group_list ? group_list : order,
|
group_list ? group_list : order,
|
||||||
(having_list || group_list ||
|
(having_list || group_list ||
|
||||||
(select_options & OPTION_FOUND_ROWS)) ?
|
(select_options & OPTION_FOUND_ROWS)) ?
|
||||||
@ -5795,7 +5796,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
|
create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
|
||||||
{
|
{
|
||||||
SORT_FIELD *sortorder;
|
SORT_FIELD *sortorder;
|
||||||
uint length;
|
uint length;
|
||||||
@ -5839,8 +5840,8 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
|
|||||||
}
|
}
|
||||||
if (table->tmp_table)
|
if (table->tmp_table)
|
||||||
table->file->info(HA_STATUS_VARIABLE); // Get record count
|
table->file->info(HA_STATUS_VARIABLE); // Get record count
|
||||||
table->found_records=filesort(table,sortorder,length,
|
table->found_records=filesort(thd, table,sortorder, length,
|
||||||
select, 0L, select_limit, &examined_rows);
|
select, select_limit, &examined_rows);
|
||||||
tab->records=table->found_records; // For SQL_CALC_ROWS
|
tab->records=table->found_records; // For SQL_CALC_ROWS
|
||||||
delete select; // filesort did select
|
delete select; // filesort did select
|
||||||
tab->select=0;
|
tab->select=0;
|
||||||
@ -5938,7 +5939,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
|
|||||||
int error;
|
int error;
|
||||||
ulong reclength,offset;
|
ulong reclength,offset;
|
||||||
uint field_count;
|
uint field_count;
|
||||||
THD *thd= current_thd;
|
THD *thd= join->thd;
|
||||||
DBUG_ENTER("remove_duplicates");
|
DBUG_ENTER("remove_duplicates");
|
||||||
|
|
||||||
entry->reginfo.lock_type=TL_WRITE;
|
entry->reginfo.lock_type=TL_WRITE;
|
||||||
|
@ -2099,8 +2099,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
|
|||||||
|
|
||||||
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
||||||
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
||||||
(from->found_records = filesort(from, sortorder, length,
|
(from->found_records = filesort(thd, from, sortorder, length,
|
||||||
(SQL_SELECT *) 0, 0L, HA_POS_ERROR,
|
(SQL_SELECT *) 0, HA_POS_ERROR,
|
||||||
&examined_rows))
|
&examined_rows))
|
||||||
== HA_POS_ERROR)
|
== HA_POS_ERROR)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -97,7 +97,7 @@ void print_cached_tables(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special)
|
void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
|
||||||
{
|
{
|
||||||
char buff[256],buff2[256];
|
char buff[256],buff2[256];
|
||||||
String str(buff,sizeof(buff),default_charset_info);
|
String str(buff,sizeof(buff),default_charset_info);
|
||||||
@ -131,8 +131,6 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special)
|
|||||||
out.append('\0'); // Purify doesn't like c_ptr()
|
out.append('\0'); // Purify doesn't like c_ptr()
|
||||||
DBUG_LOCK_FILE;
|
DBUG_LOCK_FILE;
|
||||||
VOID(fputs("\nInfo about FILESORT\n",DBUG_FILE));
|
VOID(fputs("\nInfo about FILESORT\n",DBUG_FILE));
|
||||||
if (special)
|
|
||||||
fprintf(DBUG_FILE,"Records to sort: %ld\n",special);
|
|
||||||
fprintf(DBUG_FILE,"Sortorder: %s\n",out.ptr());
|
fprintf(DBUG_FILE,"Sortorder: %s\n",out.ptr());
|
||||||
DBUG_UNLOCK_FILE;
|
DBUG_UNLOCK_FILE;
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
@ -190,8 +190,8 @@ int mysql_update(THD *thd,
|
|||||||
MYF(MY_FAE | MY_ZEROFILL));
|
MYF(MY_FAE | MY_ZEROFILL));
|
||||||
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
||||||
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
||||||
(table->found_records = filesort(table, sortorder, length,
|
(table->found_records = filesort(thd, table, sortorder, length,
|
||||||
(SQL_SELECT *) 0, 0L,
|
(SQL_SELECT *) 0,
|
||||||
HA_POS_ERROR, &examined_rows))
|
HA_POS_ERROR, &examined_rows))
|
||||||
== HA_POS_ERROR)
|
== HA_POS_ERROR)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user