Commit e41ae769 authored by Eugene Kosov's avatar Eugene Kosov

use dedicated heap for upd_node_t::historical_row and corresponding stuff to

make its lifetime as short as possible

for historical row ROW_COPY_DATA -> ROW_COPY_POINTER for lower memory
consumption and better performance
parent 19a182b1
...@@ -569,7 +569,11 @@ struct upd_node_t{ ...@@ -569,7 +569,11 @@ struct upd_node_t{
heap) of the row to update; this must be reset heap) of the row to update; this must be reset
to NULL after a successful update */ to NULL after a successful update */
dtuple_t* historical_row; /*!< historical row used in dtuple_t* historical_row; /*!< historical row used in
CASCADE UPDATE/SET NULL */ CASCADE UPDATE/SET NULL;
allocated from historical_heap */
mem_heap_t* historical_heap; /*!< heap for historical row insertion;
created when row to update is located;
freed right before row update */
row_ext_t* ext; /*!< NULL, or prefixes of the externally row_ext_t* ext; /*!< NULL, or prefixes of the externally
stored columns in the old row */ stored columns in the old row */
dtuple_t* upd_row;/* NULL, or a copy of the updated row */ dtuple_t* upd_row;/* NULL, or a copy of the updated row */
......
...@@ -1395,9 +1395,11 @@ row_ins_foreign_check_on_constraint( ...@@ -1395,9 +1395,11 @@ row_ins_foreign_check_on_constraint(
if (table->versioned() && cascade->is_delete != PLAIN_DELETE if (table->versioned() && cascade->is_delete != PLAIN_DELETE
&& cascade->update->affects_versioned()) { && cascade->update->affects_versioned()) {
cascade->historical_row = ut_ad(!cascade->historical_heap);
row_build(ROW_COPY_DATA, clust_index, clust_rec, NULL, cascade->historical_heap = mem_heap_create(128);
table, NULL, NULL, NULL, thr->prebuilt->heap); cascade->historical_row = row_build(
ROW_COPY_POINTERS, clust_index, clust_rec, NULL, table,
NULL, NULL, NULL, cascade->historical_heap);
} }
/* Store pcur position and initialize or store the cascade node /* Store pcur position and initialize or store the cascade node
......
...@@ -2162,16 +2162,18 @@ static dberr_t row_update_vers_insert(que_thr_t* thr, upd_node_t* node) ...@@ -2162,16 +2162,18 @@ static dberr_t row_update_vers_insert(que_thr_t* thr, upd_node_t* node)
node->historical_row = NULL; node->historical_row = NULL;
ins_node_t* insert_node = ins_node_t* insert_node =
ins_node_create(INS_DIRECT, table, thr->prebuilt->heap); ins_node_create(INS_DIRECT, table, node->historical_heap);
ins_node_set_new_row(insert_node, row); ins_node_set_new_row(insert_node, row);
dfield_t* row_end = dtuple_get_nth_field(row, table->vers_end); dfield_t* row_end = dtuple_get_nth_field(row, table->vers_end);
char* where = static_cast<char*>(dfield_get_data(row_end)); char where[8];
if (dict_table_get_nth_col(table, table->vers_end)->vers_native()) { if (dict_table_get_nth_col(table, table->vers_end)->vers_native()) {
mach_write_to_8(where, trx->id); mach_write_to_8(where, trx->id);
dfield_set_data(row_end, where, 8);
} else { } else {
thd_get_query_start_data(trx->mysql_thd, where); thd_get_query_start_data(trx->mysql_thd, where);
dfield_set_data(row_end, where, 7);
} }
for (;;) { for (;;) {
...@@ -2193,15 +2195,19 @@ static dberr_t row_update_vers_insert(que_thr_t* thr, upd_node_t* node) ...@@ -2193,15 +2195,19 @@ static dberr_t row_update_vers_insert(que_thr_t* thr, upd_node_t* node)
default: default:
/* Other errors are handled for the parent node. */ /* Other errors are handled for the parent node. */
thr->fk_cascade_depth = 0; thr->fk_cascade_depth = 0;
return trx->error_state; goto exit;
case DB_SUCCESS: case DB_SUCCESS:
srv_stats.n_rows_inserted.inc( srv_stats.n_rows_inserted.inc(
static_cast<size_t>(trx->id)); static_cast<size_t>(trx->id));
dict_stats_update_if_needed(table); dict_stats_update_if_needed(table);
return DB_SUCCESS; goto exit;
} }
} }
exit:
mem_heap_free(node->historical_heap);
node->historical_heap = NULL;
return trx->error_state;
} }
/**********************************************************************//** /**********************************************************************//**
......
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