InnoDB Plugin  1.0
Macros | Enumerations | Functions
row0row.h File Reference
#include "univ.i"
#include "data0data.h"
#include "dict0types.h"
#include "trx0types.h"
#include "que0types.h"
#include "mtr0mtr.h"
#include "rem0types.h"
#include "read0types.h"
#include "row0types.h"
#include "btr0types.h"
#include "row0row.ic"
Include dependency graph for row0row.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ROW_COPY_DATA   1
#define ROW_COPY_POINTERS   2

Enumerations

enum  row_search_result { ROW_FOUND = 0, ROW_NOT_FOUND, ROW_BUFFERED, ROW_NOT_DELETED_REF }

Functions

UNIV_INLINE ulint row_get_trx_id_offset (const dict_index_t *index, const ulint *offsets))
UNIV_INLINE trx_id_t row_get_rec_trx_id (const rec_t *rec, const dict_index_t *index, const ulint *offsets))
UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr (const rec_t *rec, const dict_index_t *index, const ulint *offsets))
UNIV_INTERN dtuple_trow_build_index_entry_low (const dtuple_t *row, const row_ext_t *ext, dict_index_t *index, mem_heap_t *heap)))
UNIV_INLINE dtuple_trow_build_index_entry (const dtuple_t *row, const row_ext_t *ext, dict_index_t *index, mem_heap_t *heap)))
UNIV_INTERN dtuple_trow_build (ulint type, const dict_index_t *index, const rec_t *rec, const ulint *offsets, const dict_table_t *col_table, const dtuple_t *add_cols, const ulint *col_map, row_ext_t **ext, mem_heap_t *heap)))
UNIV_INTERN dtuple_trow_rec_to_index_entry_low (const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint *n_ext, mem_heap_t *heap))
UNIV_INTERN dtuple_trow_rec_to_index_entry (const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint *n_ext, mem_heap_t *heap))
UNIV_INTERN dtuple_trow_build_row_ref (ulint type, dict_index_t *index, const rec_t *rec, mem_heap_t *heap))
UNIV_INTERN void row_build_row_ref_in_tuple (dtuple_t *ref, const rec_t *rec, const dict_index_t *index, ulint *offsets, trx_t *trx)))
UNIV_INLINE void row_build_row_ref_fast (dtuple_t *ref, const ulint *map, const rec_t *rec, const ulint *offsets)
UNIV_INTERN ibool row_search_on_row_ref (btr_pcur_t *pcur, ulint mode, const dict_table_t *table, const dtuple_t *ref, mtr_t *mtr))
UNIV_INTERN rec_t * row_get_clust_rec (ulint mode, const rec_t *rec, dict_index_t *index, dict_index_t **clust_index, mtr_t *mtr))
UNIV_INTERN enum row_search_result row_search_index_entry (dict_index_t *index, const dtuple_t *entry, ulint mode, btr_pcur_t *pcur, mtr_t *mtr))
UNIV_INTERN ulint row_raw_format (const char *data, ulint data_len, const dict_field_t *dict_field, char *buf, ulint buf_size))

Detailed Description

General row routines

Created 4/20/1996 Heikki Tuuri

Enumeration Type Documentation

Result of row_search_index_entry

Enumerator:
ROW_FOUND 

the record was found

ROW_NOT_FOUND 

record not found

ROW_BUFFERED 

one of BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK was specified, the secondary index leaf page was not in the buffer pool, and the operation was enqueued in the insert/delete buffer

ROW_NOT_DELETED_REF 

BTR_DELETE was specified, and row_purge_poss_sec() failed

Function Documentation

UNIV_INTERN dtuple_t* row_build ( ulint  type,
const dict_index_t index,
const rec_t *  rec,
const ulint *  offsets,
const dict_table_t col_table,
const dtuple_t add_cols,
const ulint *  col_map,
row_ext_t **  ext,
mem_heap_t heap 
)

An inverse function to row_build_index_entry. Builds a row from a record in a clustered index.

Returns
own: row built; see the NOTE below!
Parameters
typein: ROW_COPY_POINTERS or ROW_COPY_DATA; the latter copies also the data fields to heap while the first only places pointers to data fields on the index page, and thus is more efficient
indexin: clustered index
recin: record in the clustered index; NOTE: in the case ROW_COPY_POINTERS the data fields in the row 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 dtuple is used!
offsetsin: rec_get_offsets(rec,index) or NULL, in which case this function will invoke rec_get_offsets()
col_tablein: table, to check which externally stored columns occur in the ordering columns of an index, or NULL if index->table should be consulted instead; the user columns in this table should be the same columns as in index->table
add_colsin: default values of added columns, or NULL
col_mapin: mapping of old column numbers to new ones, or NULL
extout, own: cache of externally stored column prefixes, or NULL
heapin: memory heap from which the memory needed is allocated
UNIV_INLINE dtuple_t* row_build_index_entry ( const dtuple_t row,
const row_ext_t ext,
dict_index_t index,
mem_heap_t heap 
)

When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table.

Returns
index entry which should be inserted or purged, or NULL if the externally stored columns in the clustered index record are unavailable and ext != NULL
Parameters
rowin: row which should be inserted or purged
extin: externally stored column prefixes, or NULL
indexin: index on the table
heapin: memory heap from which the memory for the index entry is allocated
UNIV_INTERN dtuple_t* row_build_index_entry_low ( const dtuple_t row,
const row_ext_t ext,
dict_index_t index,
mem_heap_t heap 
)

When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table.

Returns
index entry which should be inserted or purged
Return values
NULLif the externally stored columns in the clustered index record are unavailable and ext != NULL, or row is missing some needed columns.
Parameters
rowin: row which should be inserted or purged
extin: externally stored column prefixes, or NULL
indexin: index on the table
heapin: memory heap from which the memory for the index entry is allocated
UNIV_INTERN dtuple_t* row_build_row_ref ( ulint  type,
dict_index_t index,
const rec_t *  rec,
mem_heap_t heap 
)

Builds from a secondary index record a row reference with which we can search the clustered index record.

Returns
own: row reference built; see the NOTE below!
Parameters
typein: ROW_COPY_DATA, or ROW_COPY_POINTERS: the former copies also the data fields to heap, whereas the latter only places pointers to data fields on the index page
indexin: secondary index
recin: record in the index; NOTE: in the case ROW_COPY_POINTERS the data fields in the row 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!
heapin: memory heap from which the memory needed is allocated
UNIV_INLINE void row_build_row_ref_fast ( dtuple_t ref,
const ulint *  map,
const rec_t *  rec,
const ulint *  offsets 
)

Builds from a secondary index record a row reference with which we can search the clustered index record. in: array returned by rec_get_offsets()

Builds from a secondary index record a row reference with which we can search the clustered index record.

Parameters
refin/out: typed data tuple where the reference is built
mapin: array of field numbers in rec telling how ref should be built from the fields of rec
recin: record in the index; must be preserved while ref is used, as we do not copy field values to heap
offsetsin: array returned by rec_get_offsets()
UNIV_INTERN void row_build_row_ref_in_tuple ( dtuple_t ref,
const rec_t *  rec,
const dict_index_t index,
ulint *  offsets,
trx_t trx 
)

Builds from a secondary index record a row reference with which we can search the clustered index record.

Parameters
refin/out: row reference built; see the NOTE below!
recin: 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!
indexin: secondary index
offsetsin: rec_get_offsets(rec, index) or NULL
trxin: transaction or NULL
UNIV_INTERN rec_t* row_get_clust_rec ( ulint  mode,
const rec_t *  rec,
dict_index_t index,
dict_index_t **  clust_index,
mtr_t mtr 
)

Fetches the clustered index record for a secondary index record. The latches on the secondary index record are preserved.

Returns
record or NULL, if no record found
Parameters
modein: BTR_MODIFY_LEAF, ...
recin: record in a secondary index
indexin: secondary index
clust_indexout: clustered index
mtrin: mtr
UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr ( const rec_t *  rec,
const dict_index_t index,
const ulint *  offsets 
)

Reads the roll pointer field from a clustered index record.

Returns
value of the field
Parameters
recin: record
indexin: clustered index
offsetsin: rec_get_offsets(rec, index)
UNIV_INLINE trx_id_t row_get_rec_trx_id ( const rec_t *  rec,
const dict_index_t index,
const ulint *  offsets 
)

Reads the trx id field from a clustered index record.

Returns
value of the field
Parameters
recin: record
indexin: clustered index
offsetsin: rec_get_offsets(rec, index)
UNIV_INLINE ulint row_get_trx_id_offset ( const dict_index_t index,
const ulint *  offsets 
)

Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of a clustered index record.

Returns
offset of DATA_TRX_ID
Parameters
indexin: clustered index
offsetsin: record offsets
UNIV_INTERN ulint row_raw_format ( const char *  data,
ulint  data_len,
const dict_field_t dict_field,
char *  buf,
ulint  buf_size 
)

Formats the raw data in "data" (in InnoDB on-disk format) using "dict_field" and writes the result to "buf". Not more than "buf_size" bytes are written to "buf". The result is always NUL-terminated (provided buf_size is positive) and the number of bytes that were written to "buf" is returned (including the terminating NUL).

Returns
number of bytes that were written
Parameters
datain: raw data
data_lenin: raw data length in bytes
dict_fieldin: index field
bufout: output buffer
buf_sizein: output buffer size in bytes
UNIV_INTERN dtuple_t* row_rec_to_index_entry ( const rec_t *  rec,
const dict_index_t index,
const ulint *  offsets,
ulint *  n_ext,
mem_heap_t heap 
)

Converts an index record to a typed data tuple. NOTE that externally stored (often big) fields are NOT copied to heap.

Returns
own: index entry built
Parameters
recin: record in the index
indexin: index
offsetsin/out: rec_get_offsets(rec)
n_extout: number of externally stored columns
heapin: memory heap from which the memory needed is allocated
UNIV_INTERN dtuple_t* row_rec_to_index_entry_low ( const rec_t *  rec,
const dict_index_t index,
const ulint *  offsets,
ulint *  n_ext,
mem_heap_t heap 
)

Converts an index record to a typed data tuple.

Returns
index entry built; does not set info_bits, and the data fields in the entry will point directly to rec
Parameters
recin: record in the index
indexin: index
offsetsin: rec_get_offsets(rec, index)
n_extout: number of externally stored columns
heapin: memory heap from which the memory needed is allocated
UNIV_INTERN enum row_search_result row_search_index_entry ( dict_index_t index,
const dtuple_t entry,
ulint  mode,
btr_pcur_t pcur,
mtr_t mtr 
)

Searches an index record.

Returns
whether the record was found or buffered
Parameters
indexin: index
entryin: index entry
modein: BTR_MODIFY_LEAF, ...
pcurin/out: persistent cursor, which must be closed by the caller
mtrin: mtr
UNIV_INTERN ibool row_search_on_row_ref ( btr_pcur_t pcur,
ulint  mode,
const dict_table_t table,
const dtuple_t ref,
mtr_t mtr 
)

Searches the clustered index record for a row, if we have the row reference.

Returns
TRUE if found
Parameters
pcurout: persistent cursor, which must be closed by the caller
modein: BTR_MODIFY_LEAF, ...
tablein: table
refin: row reference
mtrin/out: mtr