mariadb/include/row0row.ic

121 lines
3.4 KiB
Text
Raw Normal View History

/*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. 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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/**************************************************//**
@file include/row0row.ic
2005-10-27 07:29:40 +00:00
General row routines
Created 4/20/1996 Heikki Tuuri
*******************************************************/
#include "dict0dict.h"
#include "rem0rec.h"
#include "trx0undo.h"
/*********************************************************************//**
Reads the trx id field from a clustered index record.
@return value of the field */
2005-10-27 07:29:40 +00:00
UNIV_INLINE
trx_id_t
2005-10-27 07:29:40 +00:00
row_get_rec_trx_id(
/*===============*/
const rec_t* rec, /*!< in: record */
dict_index_t* index, /*!< in: clustered index */
const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
2005-10-27 07:29:40 +00:00
{
ulint offset;
ut_ad(dict_index_is_clust(index));
2005-10-27 07:29:40 +00:00
ut_ad(rec_offs_validate(rec, index, offsets));
offset = index->trx_id_offset;
if (!offset) {
offset = row_get_trx_id_offset(rec, index, offsets);
2005-10-27 07:29:40 +00:00
}
return(trx_read_trx_id(rec + offset));
2005-10-27 07:29:40 +00:00
}
/*********************************************************************//**
Reads the roll pointer field from a clustered index record.
@return value of the field */
2005-10-27 07:29:40 +00:00
UNIV_INLINE
roll_ptr_t
2005-10-27 07:29:40 +00:00
row_get_rec_roll_ptr(
/*=================*/
const rec_t* rec, /*!< in: record */
dict_index_t* index, /*!< in: clustered index */
const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */
2005-10-27 07:29:40 +00:00
{
ulint offset;
ut_ad(dict_index_is_clust(index));
2005-10-27 07:29:40 +00:00
ut_ad(rec_offs_validate(rec, index, offsets));
offset = index->trx_id_offset;
if (!offset) {
offset = row_get_trx_id_offset(rec, index, offsets);
2005-10-27 07:29:40 +00:00
}
return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN));
2005-10-27 07:29:40 +00:00
}
/*******************************************************************//**
2005-10-27 07:29:40 +00:00
Builds from a secondary index record a row reference with which we can
search the clustered index record. */
UNIV_INLINE
void
row_build_row_ref_fast(
/*===================*/
dtuple_t* ref, /*!< in/out: typed data tuple where the
2005-10-27 07:29:40 +00:00
reference is built */
const ulint* map, /*!< in: array of field numbers in rec
2005-10-27 07:29:40 +00:00
telling how ref should be built from
the fields of rec */
const rec_t* rec, /*!< in: record in the index; must be
2005-10-27 07:29:40 +00:00
preserved while ref is used, as we do
not copy field values to heap */
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
2005-10-27 07:29:40 +00:00
{
dfield_t* dfield;
const byte* field;
2005-10-27 07:29:40 +00:00
ulint len;
ulint ref_len;
ulint field_no;
ulint i;
2005-10-27 07:29:40 +00:00
ut_ad(rec_offs_validate(rec, NULL, offsets));
branches/zip: Initialize dfield_t::ext as soon as possible. This should fix the bugs introduced in r1591. row_rec_to_index_entry_low(): Clear "n_ext". Do not allow it to be NULL. Add const qualifier to dict_index_t*. row_rec_to_index_entry(): Add the parameters "offsets" and "n_ext". btr_cur_optimistic_update(): Add an assertion that there are no externally stored columns. Remove the unreachable call to btr_cur_unmark_extern_fields() and the preceding unnecessary call to rec_get_offsets(). btr_push_update_extern_fields(): Remove the parameters index, offsets. Only report the additional externally stored columns of the update vector. row_build(), trx_undo_rec_get_partial_row(): Flag externally stored columns also with dfield_set_ext(). rec_copy_prefix_to_dtuple(): Assert that there are no externally stored columns in the prefix. row_build_row_ref(): Note and assert that the index is a secondary index, and assert that there are no externally stored columns. row_build_row_ref_fast(): Assert that there are no externally stored columns. rec_offs_get_n_alloc(): Expose the function. row_build_row_ref_in_tuple(): Assert that there are no externally stored columns in a record of a secondary index. row_build_row_ref_from_row(): Assert that there are no externally stored columns. row_upd_check_references_constraints(): Add the parameter offsets, to avoid a redundant call to rec_get_offsets(). row_upd_del_mark_clust_rec(): Add the parameter offsets. Remove duplicated code. row_ins_index_entry_set_vals(): Copy the external storage flag. sel_pop_prefetched_row(): Assert that there are no externally stored columns. row_scan_and_check_index(): Copy offsets to a temporary heap across the invocation of row_rec_to_index_entry().
2007-10-17 12:13:29 +00:00
ut_ad(!rec_offs_any_extern(offsets));
2005-10-27 07:29:40 +00:00
ref_len = dtuple_get_n_fields(ref);
2005-10-27 07:29:40 +00:00
for (i = 0; i < ref_len; i++) {
dfield = dtuple_get_nth_field(ref, i);
2005-10-27 07:29:40 +00:00
field_no = *(map + i);
if (field_no != ULINT_UNDEFINED) {
field = rec_get_nth_field(rec, offsets,
field_no, &len);
2005-10-27 07:29:40 +00:00
dfield_set_data(dfield, field, len);
}
}
}