Drizzled Public API Documentation

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"

Go to the source code of this file.

Macros

#define row0row_h
 
#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_INTERN ulint row_get_trx_id_offset (const rec_t *rec, dict_index_t *index, const ulint *offsets)
 
UNIV_INLINE trx_id_t row_get_rec_trx_id (const rec_t *rec, dict_index_t *index, const ulint *offsets)
 
UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr (const rec_t *rec, dict_index_t *index, const ulint *offsets)
 
UNIV_INTERN dtuple_trow_build_index_entry (const dtuple_t *row, 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, 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 (ulint type, const rec_t *rec, const dict_index_t *index, 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

Definition in file row0row.h.

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

Definition at line 263 of file row0row.h.

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,
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! in: memory heap from which the memory needed is allocated

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
extout, own: cache of externally stored column prefixes, or NULL
heapin: memory heap from which the memory needed is allocated

Definition at line 175 of file row0row.cc.

References dfield_set_data(), dfield_set_ext(), dict_col_get_no(), dict_field_get_col(), dict_index_is_clust(), dict_table_get_format(), dict_table_get_n_cols(), dict_table_is_comp(), dict_table_zip_size(), DICT_TF_FORMAT_ZIP, dtuple_check_typed(), dtuple_create(), dtuple_set_info_bits(), mem_heap_alloc(), mem_heap_free, dict_col_struct::ord_part, dict_field_struct::prefix_len, rec_copy(), rec_get_info_bits(), rec_offs_n_extern(), rec_offs_n_fields(), rec_offs_nth_extern(), rec_offs_size(), rec_offs_validate(), row_build(), row_ext_create(), dict_index_struct::table, ut_a, and ut_ad.

Referenced by row_build(), row_undo_search_clust_to_pcur(), row_vers_impl_x_locked_off_kernel(), and row_vers_old_has_index_entry().

UNIV_INTERN dtuple_t* row_build_index_entry ( const dtuple_t row,
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 in: memory heap from which the memory for the index entry is allocated

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

Definition at line 87 of file row0row.cc.

References BTR_EXTERN_FIELD_REF_SIZE, dict_field_struct::col, dfield_copy(), dfield_get_len(), dfield_is_ext(), dfield_is_null(), dfield_set_data(), dfield_set_len(), dict_col_get_no(), dict_index_get_n_fields(), dict_index_get_n_unique_in_tree(), dict_index_is_clust(), DICT_UNIVERSAL, dtuple_check_typed(), dtuple_create(), dtuple_set_n_fields_cmp(), dict_col_struct::mbminmaxlen, dict_col_struct::ord_part, dict_field_struct::prefix_len, dict_col_struct::prtype, row_build_index_entry(), row_ext_lookup(), dict_index_struct::type, ut_a, and ut_ad.

Referenced by ins_node_create_entry_list(), row_build_index_entry(), row_undo_ins(), row_vers_impl_x_locked_off_kernel(), and row_vers_old_has_index_entry().

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! in: memory heap from which the memory needed is allocated

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

Definition at line 434 of file row0row.cc.

References dfield_set_data(), dfield_set_len(), dict_index_get_n_unique(), dict_index_is_clust(), dtuple_check_typed(), dtuple_create(), dtype_struct::mbminmaxlen, mem_heap_alloc(), mem_heap_free, dtype_struct::prtype, rec_copy(), rec_offs_any_extern(), rec_offs_size(), row_build_row_ref(), dict_index_struct::table, ut_a, and ut_ad.

Referenced by row_build_row_ref(), and row_get_clust_rec().

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()

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
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. in: transaction

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

Definition at line 543 of file row0row.cc.

References dfield_set_data(), dfield_set_len(), dict_index_get_n_unique(), dict_index_is_clust(), dtuple_check_typed(), dtuple_get_n_fields(), dtype_struct::mbminmaxlen, mem_heap_free, dict_index_struct::name, dtype_struct::prtype, rec_offs_any_extern(), rec_offs_validate(), row_build_row_ref_in_tuple(), dict_index_struct::table, dict_index_struct::table_name, ut_a, ut_ad, ut_error, and ut_print_name().

Referenced by row_build_row_ref_in_tuple().

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 in: 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

Definition at line 699 of file row0row.cc.

References btr_pcur_close(), btr_pcur_get_rec(), dict_index_is_clust(), mem_heap_create, mem_heap_free, row_build_row_ref(), row_get_clust_rec(), row_search_on_row_ref(), dict_index_struct::table, and ut_ad.

Referenced by row_get_clust_rec(), and row_vers_impl_x_locked_off_kernel().

UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr ( const rec_t *  rec,
dict_index_t index,
const ulint *  offsets 
)

Reads the roll pointer field from a clustered index record.

Returns
value of the field in: rec_get_offsets(rec, index)
Parameters
recin: record
indexin: clustered index

Referenced by row_undo_search_clust_to_pcur(), row_vers_build_for_consistent_read(), and trx_undo_prev_version_build().

UNIV_INLINE trx_id_t row_get_rec_trx_id ( const rec_t *  rec,
dict_index_t index,
const ulint *  offsets 
)

Reads the trx id field from a clustered index record.

Returns
value of the field in: rec_get_offsets(rec, index)
Parameters
recin: record
indexin: clustered index

Referenced by lock_clust_rec_cons_read_sees(), row_unlock_for_mysql(), row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), row_vers_impl_x_locked_off_kernel(), and trx_undo_prev_version_build().

UNIV_INTERN ulint row_get_trx_id_offset ( const rec_t *  ,
dict_index_t index,
const ulint *  offsets 
)

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

Returns
offset of DATA_TRX_ID in: rec_get_offsets(rec, index)

Gets the offset of 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: rec_get_offsets(rec, index)

Definition at line 56 of file row0row.cc.

References dict_index_get_sys_col_pos(), dict_index_is_clust(), rec_get_nth_field_offs(), rec_offs_validate(), row_get_trx_id_offset(), and ut_ad.

Referenced by row_get_trx_id_offset().

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 in: output buffer size in bytes

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

Definition at line 913 of file row0row.cc.

References dict_field_struct::col, dict_col_struct::mtype, dict_col_struct::prtype, row_raw_format(), ut_min(), ut_raw_to_hex(), and ut_snprintf.

Referenced by row_raw_format().

UNIV_INTERN dtuple_t* row_rec_to_index_entry ( ulint  type,
const rec_t *  rec,
const dict_index_t index,
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; see the NOTE below! in: memory heap from which the memory needed is allocated

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; see the NOTE below!
Parameters
typein: ROW_COPY_DATA, or ROW_COPY_POINTERS: the former copies also the data fields to heap as the latter only places pointers to data fields on the index page
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 dtuple is used!
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

Definition at line 382 of file row0row.cc.

References dtuple_set_info_bits(), mem_heap_alloc(), rec_copy(), rec_get_info_bits(), rec_offs_comp(), rec_offs_size(), rec_offs_validate(), row_rec_to_index_entry(), row_rec_to_index_entry_low(), and ut_ad.

Referenced by btr_cur_optimistic_update(), row_check_index_for_mysql(), row_rec_to_index_entry(), and trx_undo_prev_version_build().

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 in: memory heap from which the memory needed is allocated

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

Definition at line 324 of file row0row.cc.

References dfield_set_data(), dfield_set_ext(), dict_index_get_n_fields(), dict_index_get_n_unique_in_tree(), dtuple_check_typed(), dtuple_create(), dtuple_set_n_fields_cmp(), rec_offs_n_fields(), rec_offs_nth_extern(), row_rec_to_index_entry_low(), and ut_ad.

Referenced by row_rec_to_index_entry(), and row_rec_to_index_entry_low().

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 in: 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

Definition at line 740 of file row0row.cc.

References BTR_CUR_BINARY, BTR_CUR_DEL_MARK_IBUF, BTR_CUR_DELETE_IBUF, BTR_CUR_DELETE_REF, BTR_CUR_HASH, BTR_CUR_HASH_FAIL, BTR_CUR_INSERT_TO_IBUF, BTR_DELETE, btr_pcur_get_low_match(), btr_pcur_get_rec(), dtuple_check_typed(), dtuple_get_n_fields(), page_rec_is_infimum(), ROW_BUFFERED, ROW_FOUND, ROW_NOT_DELETED_REF, ROW_NOT_FOUND, row_search_index_entry(), ut_a, and ut_ad.

Referenced by row_search_index_entry().

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 in/out: 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

Definition at line 655 of file row0row.cc.

References btr_pcur_get_low_match(), btr_pcur_get_rec(), dict_index_get_n_unique(), dtuple_check_typed(), dtuple_get_n_fields(), page_rec_is_infimum(), row_search_on_row_ref(), ut_a, and ut_ad.

Referenced by row_get_clust_rec(), row_search_on_row_ref(), and row_undo_search_clust_to_pcur().