mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Removed TABLE->sort to make it possible to have multiple active calls to
filesort and init_read_record() for the same table. This will simplify code for WINDOW FUNCTIONS (MDEV-6115) - Filesort_info renamed to SORT_INFO and moved to filesort.h - filesort now returns SORT_INFO - init_read_record() now takes a SORT_INFO parameter. - unique declaration is moved to uniques.h - subselect caching of buffers is now more explicit than before - filesort_buffer is now reusable even if rec_length has changed. - filsort_free_buffers() and free_io_cache() calls are removed - Remove one malloc() when using get_addon_fields() Other things: - Added --debug-assert-on-not-freed-memory option to make it easier to debug some not-freed-memory issues.
This commit is contained in:
@@ -9351,15 +9351,14 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
int error= 1;
|
||||
Copy_field *copy= NULL, *copy_end;
|
||||
ha_rows found_count= 0, delete_count= 0;
|
||||
uint length= 0;
|
||||
SORT_FIELD *sortorder;
|
||||
SORT_INFO *file_sort= 0;
|
||||
READ_RECORD info;
|
||||
TABLE_LIST tables;
|
||||
List<Item> fields;
|
||||
List<Item> all_fields;
|
||||
ha_rows examined_rows;
|
||||
ha_rows found_rows;
|
||||
bool auto_increment_field_copied= 0;
|
||||
bool init_read_record_done= 0;
|
||||
ulonglong save_sql_mode= thd->variables.sql_mode;
|
||||
ulonglong prev_insert_id, time_to_report_progress;
|
||||
Field **dfield_ptr= to->default_field;
|
||||
@@ -9442,9 +9441,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
}
|
||||
else
|
||||
{
|
||||
from->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
|
||||
MYF(MY_FAE | MY_ZEROFILL |
|
||||
MY_THREAD_SPECIFIC));
|
||||
uint length= 0;
|
||||
bzero((char *) &tables, sizeof(tables));
|
||||
tables.table= from;
|
||||
tables.alias= tables.table_name= from->s->table_name.str;
|
||||
@@ -9456,12 +9453,10 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
setup_order(thd, thd->lex->select_lex.ref_pointer_array,
|
||||
&tables, fields, all_fields, order) ||
|
||||
!(sortorder= make_unireg_sortorder(thd, order, &length, NULL)) ||
|
||||
(from->sort.found_records= filesort(thd, from, sortorder, length,
|
||||
NULL, HA_POS_ERROR,
|
||||
true,
|
||||
&examined_rows, &found_rows,
|
||||
&dummy_tracker)) ==
|
||||
HA_POS_ERROR)
|
||||
!(file_sort= filesort(thd, from, sortorder, length,
|
||||
NULL, HA_POS_ERROR,
|
||||
true,
|
||||
&dummy_tracker)))
|
||||
goto err;
|
||||
}
|
||||
thd_progress_next_stage(thd);
|
||||
@@ -9471,8 +9466,10 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
/* Tell handler that we have values for all columns in the to table */
|
||||
to->use_all_columns();
|
||||
to->mark_virtual_columns_for_write(TRUE);
|
||||
if (init_read_record(&info, thd, from, (SQL_SELECT *) 0, 1, 1, FALSE))
|
||||
if (init_read_record(&info, thd, from, (SQL_SELECT *) 0, file_sort, 1, 1,
|
||||
FALSE))
|
||||
goto err;
|
||||
init_read_record_done= 1;
|
||||
|
||||
if (ignore && !alter_ctx->fk_error_if_delete_row)
|
||||
to->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
@@ -9587,9 +9584,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
found_count++;
|
||||
thd->get_stmt_da()->inc_current_row_for_warning();
|
||||
}
|
||||
end_read_record(&info);
|
||||
free_io_cache(from);
|
||||
delete [] copy;
|
||||
|
||||
THD_STAGE_INFO(thd, stage_enabling_keys);
|
||||
thd_progress_next_stage(thd);
|
||||
@@ -9610,6 +9604,12 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
error= 1;
|
||||
|
||||
err:
|
||||
/* Free resources */
|
||||
if (init_read_record_done)
|
||||
end_read_record(&info);
|
||||
delete [] copy;
|
||||
delete file_sort;
|
||||
|
||||
thd->variables.sql_mode= save_sql_mode;
|
||||
thd->abort_on_warning= 0;
|
||||
*copied= found_count;
|
||||
|
Reference in New Issue
Block a user