Commit 6554977f authored by Sergei Golubchik's avatar Sergei Golubchik

Added ha_write_tmp_row() for slightly faster write_row for internal temp tables.

This will also enable us in the future to collect statistics for
writes to internal tmp tables.

sql/handler.h:
  Added ha_write_tmp_row()
sql/opt_subselect.cc:
  ha_write_row -> ha_write_tmp_row
sql/sql_class.h:
  Added ha_write_tmp_row()
sql/sql_select.cc:
  ha_write_row -> ha_write_tmp_row
parent f5ea301a
...@@ -2415,6 +2415,7 @@ public: ...@@ -2415,6 +2415,7 @@ public:
/* XXX to be removed, see ha_partition::partition_ht() */ /* XXX to be removed, see ha_partition::partition_ht() */
virtual handlerton *partition_ht() const virtual handlerton *partition_ht() const
{ return ht; } { return ht; }
inline int ha_write_tmp_row(uchar *buf);
}; };
#include "multi_range_read.h" #include "multi_range_read.h"
......
...@@ -2907,7 +2907,7 @@ int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl) ...@@ -2907,7 +2907,7 @@ int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
} }
} }
error= sjtbl->tmp_table->file->ha_write_row(sjtbl->tmp_table->record[0]); error= sjtbl->tmp_table->file->ha_write_tmp_row(sjtbl->tmp_table->record[0]);
if (error) if (error)
{ {
/* create_internal_tmp_table_from_heap will generate error if needed */ /* create_internal_tmp_table_from_heap will generate error if needed */
......
...@@ -3639,5 +3639,10 @@ inline int handler::ha_read_first_row(uchar *buf, uint primary_key) ...@@ -3639,5 +3639,10 @@ inline int handler::ha_read_first_row(uchar *buf, uint primary_key)
return error; return error;
} }
inline int handler::ha_write_tmp_row(uchar *buf)
{
increment_statistics(&SSV::ha_write_count);
return write_row(buf);
}
#endif /* MYSQL_SERVER */ #endif /* MYSQL_SERVER */
...@@ -7515,7 +7515,7 @@ end_sj_materialize(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) ...@@ -7515,7 +7515,7 @@ end_sj_materialize(JOIN *join, JOIN_TAB *join_tab, bool end_of_records)
fill_record(thd, table->field, sjm->sjm_table_cols, TRUE, FALSE); fill_record(thd, table->field, sjm->sjm_table_cols, TRUE, FALSE);
if (thd->is_error()) if (thd->is_error())
DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
if ((error= table->file->ha_write_row(table->record[0]))) if ((error= table->file->ha_write_tmp_row(table->record[0])))
{ {
/* create_myisam_from_heap will generate error if needed */ /* create_myisam_from_heap will generate error if needed */
if (table->file->is_fatal_error(error, HA_CHECK_DUP) && if (table->file->is_fatal_error(error, HA_CHECK_DUP) &&
...@@ -12833,13 +12833,13 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table, ...@@ -12833,13 +12833,13 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table,
*/ */
while (!table->file->ha_rnd_next(new_table.record[1])) while (!table->file->ha_rnd_next(new_table.record[1]))
{ {
write_err= new_table.file->ha_write_row(new_table.record[1]); write_err= new_table.file->ha_write_tmp_row(new_table.record[1]);
DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;); DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;);
if (write_err) if (write_err)
goto err; goto err;
} }
/* copy row that filled HEAP table */ /* copy row that filled HEAP table */
if ((write_err=new_table.file->ha_write_row(table->record[0]))) if ((write_err=new_table.file->ha_write_tmp_row(table->record[0])))
{ {
if (new_table.file->is_fatal_error(write_err, HA_CHECK_DUP) || if (new_table.file->is_fatal_error(write_err, HA_CHECK_DUP) ||
!ignore_last_dupp_key_error) !ignore_last_dupp_key_error)
...@@ -14725,7 +14725,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -14725,7 +14725,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{ {
int error; int error;
join->found_records++; join->found_records++;
if ((error= table->file->ha_write_row(table->record[0]))) if ((error= table->file->ha_write_tmp_row(table->record[0])))
{ {
if (!table->file->is_fatal_error(error, HA_CHECK_DUP)) if (!table->file->is_fatal_error(error, HA_CHECK_DUP))
goto end; goto end;
...@@ -14814,7 +14814,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -14814,7 +14814,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
init_tmptable_sum_functions(join->sum_funcs); init_tmptable_sum_functions(join->sum_funcs);
if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd)) if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd))
DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
if ((error= table->file->ha_write_row(table->record[0]))) if ((error= table->file->ha_write_tmp_row(table->record[0])))
{ {
if (create_internal_tmp_table_from_heap(join->thd, table, if (create_internal_tmp_table_from_heap(join->thd, table,
join->tmp_table_param.start_recinfo, join->tmp_table_param.start_recinfo,
...@@ -14857,7 +14857,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -14857,7 +14857,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd)) if (copy_funcs(join->tmp_table_param.items_to_copy, join->thd))
DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
if (!(error= table->file->ha_write_row(table->record[0]))) if (!(error= table->file->ha_write_tmp_row(table->record[0])))
join->send_records++; // New group join->send_records++; // New group
else else
{ {
...@@ -14917,7 +14917,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -14917,7 +14917,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
join->sum_funcs_end[send_group_parts]); join->sum_funcs_end[send_group_parts]);
if (!join->having || join->having->val_int()) if (!join->having || join->having->val_int())
{ {
int error= table->file->ha_write_row(table->record[0]); int error= table->file->ha_write_tmp_row(table->record[0]);
if (error && if (error &&
create_internal_tmp_table_from_heap(join->thd, table, create_internal_tmp_table_from_heap(join->thd, table,
join->tmp_table_param.start_recinfo, join->tmp_table_param.start_recinfo,
...@@ -18592,7 +18592,7 @@ int JOIN::rollup_write_data(uint idx, TABLE *table_arg) ...@@ -18592,7 +18592,7 @@ int JOIN::rollup_write_data(uint idx, TABLE *table_arg)
item->save_in_result_field(1); item->save_in_result_field(1);
} }
copy_sum_funcs(sum_funcs_end[i+1], sum_funcs_end[i]); copy_sum_funcs(sum_funcs_end[i+1], sum_funcs_end[i]);
if ((write_error= table_arg->file->ha_write_row(table_arg->record[0]))) if ((write_error= table_arg->file->ha_write_tmp_row(table_arg->record[0])))
{ {
if (create_internal_tmp_table_from_heap(thd, table_arg, if (create_internal_tmp_table_from_heap(thd, table_arg,
tmp_table_param.start_recinfo, tmp_table_param.start_recinfo,
......
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