diff options
Diffstat (limited to 'storage/innobase/api/api0api.cc')
-rw-r--r-- | storage/innobase/api/api0api.cc | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/storage/innobase/api/api0api.cc b/storage/innobase/api/api0api.cc index 647ebcde6f0..d2f1a468f25 100644 --- a/storage/innobase/api/api0api.cc +++ b/storage/innobase/api/api0api.cc @@ -355,7 +355,9 @@ ib_read_tuple( /*==========*/ const rec_t* rec, /*!< in: Record to read */ ib_bool_t page_format, /*!< in: IB_TRUE if compressed format */ - ib_tuple_t* tuple) /*!< in: tuple to read into */ + ib_tuple_t* tuple, /*!< in: tuple to read into */ + void** rec_buf, /*!< in/out: row buffer */ + ulint* len) /*!< in/out: buffer len */ { ulint i; void* ptr; @@ -366,6 +368,7 @@ ib_read_tuple( ulint* offsets = offsets_; dtuple_t* dtuple = tuple->ptr; const dict_index_t* index = tuple->index; + ulint offset_size; rec_offs_init(offsets_); @@ -375,8 +378,20 @@ ib_read_tuple( rec_meta_data = rec_get_info_bits(rec, page_format); dtuple_set_info_bits(dtuple, rec_meta_data); - /* Make a copy of the rec. */ - ptr = mem_heap_alloc(tuple->heap, rec_offs_size(offsets)); + offset_size = rec_offs_size(offsets); + + if (rec_buf && *rec_buf) { + if (*len < offset_size) { + free(*rec_buf); + *rec_buf = malloc(offset_size); + *len = offset_size; + } + ptr = *rec_buf; + } else { + /* Make a copy of the rec. */ + ptr = mem_heap_alloc(tuple->heap, offset_size); + } + copy = rec_copy(ptr, rec, offsets); n_index_fields = ut_min( @@ -557,6 +572,10 @@ ib_trx_start( /*=========*/ ib_trx_t ib_trx, /*!< in: transaction to restart */ ib_trx_level_t ib_trx_level, /*!< in: trx isolation level */ + ib_bool_t read_write, /*!< in: true if read write + transaction */ + ib_bool_t auto_commit, /*!< in: auto commit after each + single DML */ void* thd) /*!< in: THD */ { ib_err_t err = DB_SUCCESS; @@ -564,6 +583,10 @@ ib_trx_start( ut_a(ib_trx_level <= IB_TRX_SERIALIZABLE); + trx->api_trx = true; + trx->api_auto_commit = auto_commit; + trx->read_write = read_write; + trx_start_if_not_started(trx); trx->isolation_level = ib_trx_level; @@ -583,16 +606,22 @@ UNIV_INTERN ib_trx_t ib_trx_begin( /*=========*/ - ib_trx_level_t ib_trx_level) /*!< in: trx isolation level */ + ib_trx_level_t ib_trx_level, /*!< in: trx isolation level */ + ib_bool_t read_write, /*!< in: true if read write + transaction */ + ib_bool_t auto_commit) /*!< in: auto commit after each + single DML */ { trx_t* trx; ib_bool_t started; trx = trx_allocate_for_mysql(); - started = ib_trx_start((ib_trx_t) trx, ib_trx_level, NULL); + + started = ib_trx_start(static_cast<ib_trx_t>(trx), ib_trx_level, + read_write, auto_commit, NULL); ut_a(started); - return((ib_trx_t) trx); + return(static_cast<ib_trx_t>(trx)); } /*****************************************************************//** @@ -652,15 +681,11 @@ ib_trx_commit( trx_t* trx = (trx_t*) ib_trx; if (trx->state == TRX_STATE_NOT_STARTED) { - err = ib_trx_release(ib_trx); return(err); } trx_commit(trx); - err = ib_trx_release(ib_trx); - ut_a(err == DB_SUCCESS); - return(DB_SUCCESS); } @@ -682,9 +707,6 @@ ib_trx_rollback( /* It should always succeed */ ut_a(err == DB_SUCCESS); - err = ib_trx_release(ib_trx); - ut_a(err == DB_SUCCESS); - ib_wake_master_thread(); return(err); @@ -1371,11 +1393,12 @@ ib_cursor_commit_trx( { ib_err_t err = DB_SUCCESS; ib_cursor_t* cursor = (ib_cursor_t*) ib_crsr; +#ifdef UNIV_DEBUG row_prebuilt_t* prebuilt = cursor->prebuilt; ut_ad(prebuilt->trx == (trx_t*) ib_trx); - err = ib_trx_commit(ib_trx); - prebuilt->trx = NULL; +#endif /* UNIV_DEBUG */ + ib_trx_commit(ib_trx); cursor->valid_trx = FALSE; return(err); } @@ -1955,7 +1978,7 @@ ib_delete_row( upd = ib_update_vector_create(cursor); page_format = dict_table_is_comp(index->table); - ib_read_tuple(rec, page_format, tuple); + ib_read_tuple(rec, page_format, tuple, NULL, NULL); upd->n_fields = ib_tuple_get_n_cols(ib_tpl); @@ -2056,7 +2079,9 @@ ib_err_t ib_cursor_read_row( /*===============*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ - ib_tpl_t ib_tpl) /*!< out: read cols into this tuple */ + ib_tpl_t ib_tpl, /*!< out: read cols into this tuple */ + void** row_buf, /*!< in/out: row buffer */ + ib_ulint_t* row_len) /*!< in/out: row buffer len */ { ib_err_t err; ib_tuple_t* tuple = (ib_tuple_t*) ib_tpl; @@ -2100,7 +2125,8 @@ ib_cursor_read_row( } if (!rec_get_deleted_flag(rec, page_format)) { - ib_read_tuple(rec, page_format, tuple); + ib_read_tuple(rec, page_format, tuple, + row_buf, (ulint*) row_len); err = DB_SUCCESS; } else{ err = DB_RECORD_NOT_FOUND; @@ -3845,7 +3871,7 @@ ib_table_truncate( ib_trx_t ib_trx = NULL; ib_crsr_t ib_crsr = NULL; - ib_trx = ib_trx_begin(IB_TRX_SERIALIZABLE); + ib_trx = ib_trx_begin(IB_TRX_SERIALIZABLE, true, false); dict_mutex_enter_for_mysql(); |