mirror of
https://github.com/MariaDB/server.git
synced 2025-06-15 00:02:46 +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
|
||||
*/
|
||||
|
||||
ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
SQL_SELECT *select, ha_rows special, ha_rows max_rows,
|
||||
ha_rows *examined_rows)
|
||||
ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
SQL_SELECT *select, ha_rows max_rows, ha_rows *examined_rows)
|
||||
{
|
||||
int error;
|
||||
ulong memavl;
|
||||
uint maxbuffer;
|
||||
uint i;
|
||||
BUFFPEK *buffpek;
|
||||
ha_rows records;
|
||||
uchar **sort_keys;
|
||||
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
|
||||
SORTPARAM param;
|
||||
THD *thd= current_thd;
|
||||
|
||||
DBUG_ENTER("filesort");
|
||||
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special););
|
||||
CHARSET_INFO *charset=table->table_charset;
|
||||
uint i;
|
||||
DBUG_ENTER("filesort");
|
||||
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length););
|
||||
#ifdef SKIP_DBUG_IN_FILESORT
|
||||
DBUG_PUSH(""); /* No DBUG here */
|
||||
#endif
|
||||
@ -111,27 +108,15 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
{
|
||||
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
|
||||
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),
|
||||
table->file->records)+EXTRA_RECORDS;
|
||||
selected_records_file=0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
{
|
||||
records=table->file->estimate_number_of_rows();
|
||||
selected_records_file= 0;
|
||||
|
@ -611,7 +611,7 @@ pthread_handler_decl(handle_manager, arg);
|
||||
#ifndef DBUG_OFF
|
||||
void print_where(COND *cond,const char *info);
|
||||
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
|
||||
void mysql_print_status(THD *thd);
|
||||
/* key.cc */
|
||||
@ -792,9 +792,9 @@ void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
|
||||
SQL_SELECT *select,
|
||||
int use_record_cache, bool print_errors);
|
||||
void end_read_record(READ_RECORD *info);
|
||||
ha_rows filesort(TABLE *form,struct st_sort_field *sortorder, uint s_length,
|
||||
SQL_SELECT *select, ha_rows special,ha_rows max_rows,
|
||||
ha_rows *examined_rows);
|
||||
ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
|
||||
uint s_length, SQL_SELECT *select,
|
||||
ha_rows max_rows, ha_rows *examined_rows);
|
||||
void change_double_for_sort(double nr,byte *to);
|
||||
int get_quick_record(SQL_SELECT *select);
|
||||
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));
|
||||
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
||||
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
||||
(table->found_records = filesort(table, sortorder, length,
|
||||
(SQL_SELECT *) 0, 0L, HA_POS_ERROR,
|
||||
(table->found_records = filesort(thd, table, sortorder, length,
|
||||
(SQL_SELECT *) 0, HA_POS_ERROR,
|
||||
&examined_rows))
|
||||
== 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 bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,
|
||||
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,
|
||||
Item *having);
|
||||
static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field,
|
||||
@ -748,7 +749,7 @@ JOIN::exec()
|
||||
{
|
||||
DBUG_PRINT("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) ||
|
||||
make_sum_func_list(this, all_fields) ||
|
||||
alloc_group_fields(this, group_list))
|
||||
@ -763,7 +764,7 @@ JOIN::exec()
|
||||
{
|
||||
DBUG_PRINT("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))
|
||||
DBUG_VOID_RETURN;
|
||||
order=0;
|
||||
@ -866,7 +867,7 @@ JOIN::exec()
|
||||
if (group_list)
|
||||
{
|
||||
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))
|
||||
{
|
||||
free_tmp_table(thd,tmp_table2); /* purecov: inspected */
|
||||
@ -962,7 +963,7 @@ JOIN::exec()
|
||||
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,
|
||||
(having_list || group_list ||
|
||||
(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
|
||||
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;
|
||||
uint length;
|
||||
@ -5839,8 +5840,8 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
|
||||
}
|
||||
if (table->tmp_table)
|
||||
table->file->info(HA_STATUS_VARIABLE); // Get record count
|
||||
table->found_records=filesort(table,sortorder,length,
|
||||
select, 0L, select_limit, &examined_rows);
|
||||
table->found_records=filesort(thd, table,sortorder, length,
|
||||
select, select_limit, &examined_rows);
|
||||
tab->records=table->found_records; // For SQL_CALC_ROWS
|
||||
delete select; // filesort did select
|
||||
tab->select=0;
|
||||
@ -5938,7 +5939,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
|
||||
int error;
|
||||
ulong reclength,offset;
|
||||
uint field_count;
|
||||
THD *thd= current_thd;
|
||||
THD *thd= join->thd;
|
||||
DBUG_ENTER("remove_duplicates");
|
||||
|
||||
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) ||
|
||||
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
||||
(from->found_records = filesort(from, sortorder, length,
|
||||
(SQL_SELECT *) 0, 0L, HA_POS_ERROR,
|
||||
(from->found_records = filesort(thd, from, sortorder, length,
|
||||
(SQL_SELECT *) 0, HA_POS_ERROR,
|
||||
&examined_rows))
|
||||
== HA_POS_ERROR)
|
||||
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];
|
||||
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()
|
||||
DBUG_LOCK_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());
|
||||
DBUG_UNLOCK_FILE;
|
||||
DBUG_VOID_RETURN;
|
||||
|
@ -190,8 +190,8 @@ int mysql_update(THD *thd,
|
||||
MYF(MY_FAE | MY_ZEROFILL));
|
||||
if (setup_order(thd, &tables, fields, all_fields, order) ||
|
||||
!(sortorder=make_unireg_sortorder(order, &length)) ||
|
||||
(table->found_records = filesort(table, sortorder, length,
|
||||
(SQL_SELECT *) 0, 0L,
|
||||
(table->found_records = filesort(thd, table, sortorder, length,
|
||||
(SQL_SELECT *) 0,
|
||||
HA_POS_ERROR, &examined_rows))
|
||||
== HA_POS_ERROR)
|
||||
{
|
||||
|
Reference in New Issue
Block a user