2009-02-17 09:33:38 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************//**
|
|
|
|
@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"
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
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
|
2009-04-23 05:32:36 +00:00
|
|
|
trx_id_t
|
2005-10-27 07:29:40 +00:00
|
|
|
row_get_rec_trx_id(
|
|
|
|
/*===============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
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;
|
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
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;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-02-10 15:06:17 +00:00
|
|
|
if (!offset) {
|
|
|
|
offset = row_get_trx_id_offset(rec, index, offsets);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-10 15:06:17 +00:00
|
|
|
|
|
|
|
return(trx_read_trx_id(rec + offset));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +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
|
2009-04-23 05:32:36 +00:00
|
|
|
roll_ptr_t
|
2005-10-27 07:29:40 +00:00
|
|
|
row_get_rec_roll_ptr(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
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;
|
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
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;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-02-10 15:06:17 +00:00
|
|
|
if (!offset) {
|
|
|
|
offset = row_get_trx_id_offset(rec, index, offsets);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-02-10 15:06:17 +00:00
|
|
|
return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +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(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
dtuple_t* ref, /*!< in/out: typed data tuple where the
|
2005-10-27 07:29:40 +00:00
|
|
|
reference is built */
|
2009-05-25 05:30:14 +00:00
|
|
|
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 */
|
2009-05-25 05:30:14 +00:00
|
|
|
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 */
|
2009-05-25 05:30:14 +00:00
|
|
|
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
dfield_t* dfield;
|
2006-10-20 13:50:40 +00:00
|
|
|
const byte* field;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint len;
|
|
|
|
ulint ref_len;
|
|
|
|
ulint field_no;
|
|
|
|
ulint i;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(rec_offs_validate(rec, NULL, offsets));
|
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);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = 0; i < ref_len; i++) {
|
2006-10-19 07:27:26 +00:00
|
|
|
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,
|
2006-08-29 09:30:31 +00:00
|
|
|
field_no, &len);
|
2005-10-27 07:29:40 +00:00
|
|
|
dfield_set_data(dfield, field, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|