Commit 7889aae8 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Define less of bulk insert inline

trx_mod_table_time_t::write_bulk(): Define non-inline.
There are 2 callers, so this will avoid some code duplication.

trx_t::bulk_insert_apply(): In the inline function, only check for
the condition, and invoke the actual operation in the non-inline
function trx_t::bulk_insert_apply_low().
parent 549e84b4
......@@ -525,15 +525,7 @@ class trx_mod_table_time_t
/** Do bulk insert operation present in the buffered operation
@return DB_SUCCESS or error code */
dberr_t write_bulk(dict_table_t *table, trx_t *trx)
{
if (!bulk_store)
return DB_SUCCESS;
dberr_t err= bulk_store->write_to_table(table, trx);
delete bulk_store;
bulk_store= nullptr;
return err;
}
dberr_t write_bulk(dict_table_t *table, trx_t *trx);
/** @return whether the buffer storage exist */
bool bulk_buffer_exist() const
......@@ -1171,43 +1163,18 @@ struct trx_t : ilist_node<>
return &it->second;
}
/** Rollback all bulk insert operations */
void bulk_rollback()
{
undo_no_t low_limit= UINT64_MAX;
for (auto& t : mod_tables)
{
if (!t.second.is_bulk_insert())
continue;
if (t.second.get_first() < low_limit)
low_limit= t.second.get_first();
delete t.second.bulk_store;
}
trx_savept_t bulk_save{low_limit};
rollback(&bulk_save);
}
/** Do the bulk insert for the buffered insert operation
for the transaction.
@return DB_SUCCESS or error code */
dberr_t bulk_insert_apply()
{
if (UNIV_LIKELY(!bulk_insert))
return DB_SUCCESS;
ut_ad(!check_unique_secondary);
ut_ad(!check_foreigns);
for (auto& t : mod_tables)
if (t.second.is_bulk_insert())
if (dberr_t err= t.second.write_bulk(t.first, this))
{
bulk_rollback();
return err;
}
return DB_SUCCESS;
return UNIV_UNLIKELY(bulk_insert) ? bulk_insert_apply_low(): DB_SUCCESS;
}
private:
/** Apply the buffered bulk inserts. */
dberr_t bulk_insert_apply_low();
/** Assign a rollback segment for modifying temporary tables.
@return the assigned rollback segment */
trx_rseg_t *assign_temp_rseg();
......
......@@ -5362,3 +5362,40 @@ dberr_t row_merge_bulk_t::write_to_table(dict_table_t *table, trx_t *trx)
return DB_SUCCESS;
}
dberr_t trx_mod_table_time_t::write_bulk(dict_table_t *table, trx_t *trx)
{
if (!bulk_store)
return DB_SUCCESS;
dberr_t err= bulk_store->write_to_table(table, trx);
delete bulk_store;
bulk_store= nullptr;
return err;
}
dberr_t trx_t::bulk_insert_apply_low()
{
ut_ad(bulk_insert);
ut_ad(!check_unique_secondary);
ut_ad(!check_foreigns);
dberr_t err;
for (auto& t : mod_tables)
if (t.second.is_bulk_insert())
if ((err= t.second.write_bulk(t.first, this)) != DB_SUCCESS)
goto bulk_rollback;
return DB_SUCCESS;
bulk_rollback:
undo_no_t low_limit= UINT64_MAX;
for (auto& t : mod_tables)
{
if (t.second.is_bulk_insert())
{
if (t.second.get_first() < low_limit)
low_limit= t.second.get_first();
delete t.second.bulk_store;
}
}
trx_savept_t bulk_save{low_limit};
rollback(&bulk_save);
return err;
}
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