From abaca58855d465b3ebd6af905c72271596494069 Mon Sep 17 00:00:00 2001 From: marko <> Date: Tue, 25 Sep 2007 07:20:56 +0000 Subject: [PATCH] branches/zip: row_build_row_ref_in_tuple(): Add the parameter "offsets", to avoid a rec_get_offsets() call. Add some const qualifiers. row_sel_get_clust_rec_for_mysql(): Note that "offsets" will also be an input parameter. --- include/row0row.h | 24 ++++++++++++--------- row/row0row.c | 55 +++++++++++++++++++++++++++-------------------- row/row0sel.c | 7 ++++-- 3 files changed, 51 insertions(+), 35 deletions(-) diff --git a/include/row0row.h b/include/row0row.h index b0b7e291560..48dd40fbc49 100644 --- a/include/row0row.h +++ b/include/row0row.h @@ -165,16 +165,20 @@ search the clustered index record. */ void row_build_row_ref_in_tuple( /*=======================*/ - dtuple_t* ref, /* in/out: row reference built; see the - NOTE below! */ - dict_index_t* index, /* in: index */ - const rec_t* rec, /* in: record in the index; - NOTE: the data fields in ref will point - directly into this record, therefore, - the buffer page of this record must be - at least s-latched and the latch held - as long as the row reference is used! */ - trx_t* trx); /* in: transaction */ + dtuple_t* ref, /* in/out: row reference built; + see the NOTE below! */ + const rec_t* rec, /* in: record in the index; + NOTE: the data fields in ref + will point directly into this + record, therefore, the buffer + page of this record must be at + least s-latched and the latch + held as long as the row + reference is used! */ + const dict_index_t* index, /* in: secondary index */ + ulint* offsets,/* in: rec_get_offsets(rec, index) + or NULL */ + trx_t* trx); /* in: transaction */ /*********************************************************************** From a row build a row reference with which we can search the clustered index record. */ diff --git a/row/row0row.c b/row/row0row.c index 43a5938534c..5eebeb5589b 100644 --- a/row/row0row.c +++ b/row/row0row.c @@ -481,33 +481,37 @@ search the clustered index record. */ void row_build_row_ref_in_tuple( /*=======================*/ - dtuple_t* ref, /* in/out: row reference built; see the - NOTE below! */ - dict_index_t* index, /* in: index */ - const rec_t* rec, /* in: record in the index; - NOTE: the data fields in ref will point - directly into this record, therefore, - the buffer page of this record must be - at least s-latched and the latch held - as long as the row reference is used! */ - trx_t* trx) /* in: transaction */ + dtuple_t* ref, /* in/out: row reference built; + see the NOTE below! */ + const rec_t* rec, /* in: record in the index; + NOTE: the data fields in ref + will point directly into this + record, therefore, the buffer + page of this record must be at + least s-latched and the latch + held as long as the row + reference is used! */ + const dict_index_t* index, /* in: secondary index */ + ulint* offsets,/* in: rec_get_offsets(rec, index) + or NULL */ + trx_t* trx) /* in: transaction */ { - dict_index_t* clust_index; - dfield_t* dfield; - const byte* field; - ulint len; - ulint ref_len; - ulint pos; - ulint clust_col_prefix_len; - ulint i; - mem_heap_t* heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; + const dict_index_t* clust_index; + dfield_t* dfield; + const byte* field; + ulint len; + ulint ref_len; + ulint pos; + ulint clust_col_prefix_len; + ulint i; + mem_heap_t* heap = NULL; + ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; ut_a(ref); ut_a(index); ut_a(rec); + ut_ad(!dict_index_is_clust(index)); if (UNIV_UNLIKELY(!index->table)) { fputs("InnoDB: table ", stderr); @@ -521,12 +525,17 @@ notfound: clust_index = dict_table_get_first_index(index->table); - if (!clust_index) { + if (UNIV_UNLIKELY(!clust_index)) { fputs("InnoDB: clust index for table ", stderr); goto notfound; } - offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); + if (!offsets) { + offsets = rec_get_offsets(rec, index, offsets_, + ULINT_UNDEFINED, &heap); + } else { + ut_ad(rec_offs_validate(rec, index, offsets)); + } ref_len = dict_index_get_n_unique(clust_index); diff --git a/row/row0sel.c b/row/row0sel.c index e09a752d377..214937f5af3 100644 --- a/row/row0sel.c +++ b/row/row0sel.c @@ -2836,7 +2836,9 @@ row_sel_get_clust_rec_for_mysql( it, NULL if the old version did not exist in the read view, i.e., it was a fresh inserted version */ - ulint** offsets,/* out: offsets returned by + ulint** offsets,/* in: offsets returned by + rec_get_offsets(rec, sec_index); + out: offsets returned by rec_get_offsets(out_rec, clust_index) */ mem_heap_t** offset_heap,/* in/out: memory heap from which the offsets are allocated */ @@ -2853,7 +2855,8 @@ row_sel_get_clust_rec_for_mysql( *out_rec = NULL; trx = thr_get_trx(thr); - row_build_row_ref_in_tuple(prebuilt->clust_ref, sec_index, rec, trx); + row_build_row_ref_in_tuple(prebuilt->clust_ref, rec, + sec_index, *offsets, trx); clust_index = dict_table_get_first_index(sec_index->table);