diff options
Diffstat (limited to 'storage/innobase/row/row0vers.cc')
-rw-r--r-- | storage/innobase/row/row0vers.cc | 88 |
1 files changed, 36 insertions, 52 deletions
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc index 0aad8675ff8..2c3191928fd 100644 --- a/storage/innobase/row/row0vers.cc +++ b/storage/innobase/row/row0vers.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -114,7 +114,6 @@ row_vers_impl_x_locked_low( on rec. */ for (version = clust_rec;; version = prev_version) { - ulint err; row_ext_t* ext; const dtuple_t* row; dtuple_t* entry; @@ -128,24 +127,22 @@ row_vers_impl_x_locked_low( heap = mem_heap_create(1024); - err = trx_undo_prev_version_build( + trx_undo_prev_version_build( clust_rec, mtr, version, clust_index, clust_offsets, heap, &prev_version); - /* Free version and clust_offsets. */ + /* Free version and clust_offsets. */ mem_heap_free(old_heap); if (prev_version == NULL) { - /* clust_rec must be a fresh insert, because + /* clust_rec should be a fresh insert, because no previous version was found or the transaction has committed. The caller has to recheck as the synopsis of this function states, whether trx_id is active or not. */ - ut_a(err == DB_SUCCESS || err == DB_MISSING_HISTORY); - break; } @@ -155,15 +152,16 @@ row_vers_impl_x_locked_low( vers_del = rec_get_deleted_flag(prev_version, comp); - prev_trx_id = row_get_rec_trx_id( - prev_version, clust_index, clust_offsets); + prev_trx_id = row_get_rec_trx_id(prev_version, clust_index, + clust_offsets); /* The stack of versions is locked by mtr. Thus, it is safe to fetch the prefixes for externally stored columns. */ row = row_build(ROW_COPY_POINTERS, clust_index, prev_version, - clust_offsets, NULL, &ext, heap); + clust_offsets, + NULL, NULL, NULL, &ext, heap); entry = row_build_index_entry(row, ext, index, heap); @@ -183,8 +181,6 @@ row_vers_impl_x_locked_low( There is no guarantee that the transaction is still active. */ - ut_ad(err == DB_SUCCESS); - /* We check if entry and rec are identified in the alphabetical ordering */ @@ -355,7 +351,6 @@ row_vers_old_has_index_entry( mem_heap_t* heap2; const dtuple_t* row; const dtuple_t* entry; - ulint err; ulint comp; ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX) @@ -383,7 +378,8 @@ row_vers_old_has_index_entry( Thus, it is safe to fetch the prefixes for externally stored columns. */ row = row_build(ROW_COPY_POINTERS, clust_index, - rec, clust_offsets, NULL, &ext, heap); + rec, clust_offsets, + NULL, NULL, NULL, &ext, heap); entry = row_build_index_entry(row, ext, index, heap); /* If entry == NULL, the record contains unset BLOB @@ -420,12 +416,12 @@ row_vers_old_has_index_entry( for (;;) { heap2 = heap; heap = mem_heap_create(1024); - err = trx_undo_prev_version_build(rec, mtr, version, - clust_index, clust_offsets, - heap, &prev_version); + trx_undo_prev_version_build(rec, mtr, version, + clust_index, clust_offsets, + heap, &prev_version); mem_heap_free(heap2); /* free version and clust_offsets */ - if (err != DB_SUCCESS || !prev_version) { + if (!prev_version) { /* Versions end here */ mem_heap_free(heap); @@ -444,7 +440,7 @@ row_vers_old_has_index_entry( externally stored columns. */ row = row_build(ROW_COPY_POINTERS, clust_index, prev_version, clust_offsets, - NULL, &ext, heap); + NULL, NULL, NULL, &ext, heap); entry = row_build_index_entry(row, ext, index, heap); /* If entry == NULL, the record contains unset @@ -477,7 +473,7 @@ read should see. We assume that the trx id stored in rec is such that the consistent read should not see rec in its present version. @return DB_SUCCESS or DB_MISSING_HISTORY */ UNIV_INTERN -ulint +dberr_t row_vers_build_for_consistent_read( /*===============================*/ const rec_t* rec, /*!< in: record in a clustered index; the @@ -495,8 +491,9 @@ row_vers_build_for_consistent_read( *old_vers is allocated; memory for possible intermediate versions is allocated and freed locally within the function */ - rec_t** old_vers)/*!< out, own: old version, or NULL if the - record does not exist in the view, that is, + rec_t** old_vers)/*!< out, own: old version, or NULL + if the history is missing or the record + does not exist in the view, that is, it was freshly inserted afterwards */ { const rec_t* version; @@ -504,7 +501,7 @@ row_vers_build_for_consistent_read( trx_id_t trx_id; mem_heap_t* heap = NULL; byte* buf; - ulint err; + dberr_t err; ut_ad(dict_index_is_clust(index)); ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX) @@ -558,27 +555,21 @@ row_vers_build_for_consistent_read( rec_offs_make_valid(*old_vers, index, *offsets); err = DB_SUCCESS; - break; } } err = trx_undo_prev_version_build(rec, mtr, version, index, *offsets, heap, - &prev_version); + &prev_version) + ? DB_SUCCESS : DB_MISSING_HISTORY; if (heap2) { mem_heap_free(heap2); /* free version */ } - if (err != DB_SUCCESS) { - break; - } - if (prev_version == NULL) { /* It was a freshly inserted version */ *old_vers = NULL; - err = DB_SUCCESS; - break; } @@ -602,8 +593,6 @@ row_vers_build_for_consistent_read( *old_vers = rec_copy(buf, prev_version, *offsets); rec_offs_make_valid(*old_vers, index, *offsets); - err = DB_SUCCESS; - break; } @@ -617,10 +606,9 @@ row_vers_build_for_consistent_read( /*****************************************************************//** Constructs the last committed version of a clustered index record, -which should be seen by a semi-consistent read. -@return DB_SUCCESS or DB_MISSING_HISTORY */ +which should be seen by a semi-consistent read. */ UNIV_INTERN -ulint +void row_vers_build_for_semi_consistent_read( /*====================================*/ const rec_t* rec, /*!< in: record in a clustered index; the @@ -644,7 +632,6 @@ row_vers_build_for_semi_consistent_read( const rec_t* version; mem_heap_t* heap = NULL; byte* buf; - ulint err; trx_id_t rec_trx_id = 0; ut_ad(dict_index_is_clust(index)); @@ -683,7 +670,7 @@ row_vers_build_for_semi_consistent_read( mutex_exit(&trx_sys->mutex); if (!version_trx) { - +committed_version_trx: /* We found a version that belongs to a committed transaction: return it. */ @@ -693,7 +680,6 @@ row_vers_build_for_semi_consistent_read( if (rec == version) { *old_vers = rec; - err = DB_SUCCESS; break; } @@ -721,30 +707,30 @@ row_vers_build_for_semi_consistent_read( *old_vers = rec_copy(buf, version, *offsets); rec_offs_make_valid(*old_vers, index, *offsets); - err = DB_SUCCESS; - break; } + DEBUG_SYNC_C("after_row_vers_check_trx_active"); + heap2 = heap; heap = mem_heap_create(1024); - err = trx_undo_prev_version_build(rec, mtr, version, index, - *offsets, heap, - &prev_version); - if (heap2) { - mem_heap_free(heap2); /* free version */ + if (!trx_undo_prev_version_build(rec, mtr, version, index, + *offsets, heap, + &prev_version)) { + mem_heap_free(heap); + heap = heap2; + heap2 = NULL; + goto committed_version_trx; } - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { - break; + if (heap2) { + mem_heap_free(heap2); /* free version */ } if (prev_version == NULL) { /* It was a freshly inserted version */ *old_vers = NULL; - err = DB_SUCCESS; - break; } @@ -759,6 +745,4 @@ row_vers_build_for_semi_consistent_read( if (heap) { mem_heap_free(heap); } - - return(err); } |