MySQL  8.0.22
Source Code Documentation
rem0rec.h File Reference

Record manager. More...

#include <ostream>
#include <sstream>
#include "univ.i"
#include "data0data.h"
#include "mtr0types.h"
#include "page0types.h"
#include "rem/rec.h"
#include "rem0types.h"
#include "trx0types.h"
#include "ut0class_life_cycle.h"
#include "rem0rec.ic"

Go to the source code of this file.

Classes

class  Rec_offsets
 A helper RAII wrapper for otherwise difficult to use sequence of: More...
 
struct  rec_index_print
 Wrapper for pretty-printing a record. More...
 
struct  rec_offsets_print
 Wrapper for pretty-printing a record. More...
 
class  rec_printer
 Pretty-printer of records and tuples. More...
 

Macros

#define rec_get_offsets(rec, index, offsets, n, heap)   rec_get_offsets_func(rec, index, offsets, n, __FILE__, __LINE__, heap)
 
#define rec_get_nth_field_old(rec, n, len)   ((rec) + rec_get_nth_field_offs_old(rec, n, len))
 
#define rec_offs_init(offsets)   rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)
 

Functions

UNIV_INLINE const rec_trec_get_next_ptr_const (const rec_t *rec, ulint comp)
 The following function is used to get the pointer of the next chained record on the same page. More...
 
UNIV_INLINE rec_trec_get_next_ptr (rec_t *rec, ulint comp)
 The following function is used to get the pointer of the next chained record on the same page. More...
 
UNIV_INLINE ulint rec_get_next_offs (const rec_t *rec, ulint comp)
 The following function is used to get the offset of the next chained record on the same page. More...
 
UNIV_INLINE void rec_set_next_offs_old (rec_t *rec, ulint next)
 The following function is used to set the next record offset field of an old-style record. More...
 
UNIV_INLINE void rec_set_next_offs_new (rec_t *rec, ulint next)
 The following function is used to set the next record offset field of a new-style record. More...
 
UNIV_INLINE ulint rec_get_n_owned_old (const rec_t *rec)
 The following function is used to get the number of records owned by the previous directory record. More...
 
UNIV_INLINE void rec_set_n_owned_old (rec_t *rec, ulint n_owned)
 The following function is used to set the number of owned records. More...
 
UNIV_INLINE ulint rec_get_n_owned_new (const rec_t *rec)
 The following function is used to get the number of records owned by the previous directory record. More...
 
UNIV_INLINE void rec_set_n_owned_new (rec_t *rec, page_zip_des_t *page_zip, ulint n_owned)
 The following function is used to set the number of owned records. More...
 
UNIV_INLINE void rec_set_info_bits_old (rec_t *rec, ulint bits)
 The following function is used to set the info bits of a record. More...
 
UNIV_INLINE void rec_set_info_bits_new (rec_t *rec, ulint bits)
 The following function is used to set the info bits of a record. More...
 
UNIV_INLINE void rec_set_status (rec_t *rec, ulint bits)
 The following function is used to set the status bits of a new-style record. More...
 
UNIV_INLINE ulint rec_get_info_and_status_bits (const rec_t *rec, ulint comp)
 The following function is used to retrieve the info and status bits of a record. More...
 
UNIV_INLINE void rec_set_info_and_status_bits (rec_t *rec, ulint bits)
 The following function is used to set the info and status bits of a record. More...
 
UNIV_INLINE ulint rec_get_deleted_flag (const rec_t *rec, ulint comp)
 The following function tells if record is delete marked. More...
 
UNIV_INLINE void rec_set_deleted_flag_old (rec_t *rec, ulint flag)
 The following function is used to set the deleted bit. More...
 
UNIV_INLINE void rec_set_deleted_flag_new (rec_t *rec, page_zip_des_t *page_zip, ulint flag)
 The following function is used to set the deleted bit. More...
 
UNIV_INLINE void rec_set_instant_flag_new (rec_t *rec, bool flag)
 The following function is used to set the instant bit. More...
 
UNIV_INLINE bool rec_get_node_ptr_flag (const rec_t *rec)
 The following function tells if a new-style record is a node pointer. More...
 
UNIV_INLINE ulint rec_get_heap_no_old (const rec_t *rec)
 The following function is used to get the order number of an old-style record in the heap of the index page. More...
 
UNIV_INLINE void rec_set_heap_no_old (rec_t *rec, ulint heap_no)
 The following function is used to set the heap number field in an old-style record. More...
 
UNIV_INLINE ulint rec_get_heap_no_new (const rec_t *rec)
 The following function is used to get the order number of a new-style record in the heap of the index page. More...
 
UNIV_INLINE void rec_set_heap_no_new (rec_t *rec, ulint heap_no)
 The following function is used to set the heap number field in a new-style record. More...
 
UNIV_INLINE ibool rec_get_1byte_offs_flag (const rec_t *rec)
 The following function is used to test whether the data offsets in the record are stored in one-byte or two-byte format. More...
 
UNIV_INLINE void rec_set_1byte_offs_flag (rec_t *rec, ibool flag)
 The following function is used to set the 1-byte offsets flag. More...
 
UNIV_INLINE ulint rec_1_get_field_end_info (const rec_t *rec, ulint n)
 Returns the offset of nth field end if the record is stored in the 1-byte offsets form. More...
 
UNIV_INLINE ulint rec_2_get_field_end_info (const rec_t *rec, ulint n)
 Returns the offset of nth field end if the record is stored in the 2-byte offsets form. More...
 
UNIV_INLINE ulint rec_2_is_field_extern (const rec_t *rec, ulint n)
 Returns nonzero if the field is stored off-page. More...
 
ulint rec_get_n_extern_new (const rec_t *rec, const dict_index_t *index, ulint n)
 Determine how many of the first n columns in a compact physical record are stored externally. More...
 
ulint rec_get_nth_field_offs_old (const rec_t *rec, ulint n, ulint *len)
 The following function is used to get the offset to the nth data field in an old-style record. More...
 
UNIV_INLINE const byterec_get_nth_field_old_instant (const rec_t *rec, uint16_t n, const dict_index_t *index, ulint *len)
 Gets the value of the specified field in the record in old style. More...
 
UNIV_INLINE ulint rec_get_nth_field_size (const rec_t *rec, ulint n)
 Gets the physical size of an old-style field. More...
 
UNIV_INLINE ulint rec_get_nth_field_offs (const ulint *offsets, ulint n, ulint *len)
 The following function is used to get an offset to the nth data field in a record. More...
 
byterec_get_nth_field (const rec_t *rec, const ulint *offsets, ulint n, ulint *len)
 Gets the value of the specified field in the record. More...
 
UNIV_INLINE const byterec_get_nth_field_instant (const rec_t *rec, const ulint *offsets, ulint n, const dict_index_t *index, ulint *len)
 Gets the value of the specified field in the record. More...
 
UNIV_INLINE bool rec_field_not_null_not_add_col_def (ulint len)
 Determine if the field is not NULL and not having default value after instant ADD COLUMN. More...
 
UNIV_INLINE ulint rec_offs_comp (const ulint *offsets)
 Determine if the offsets are for a record in the new compact format. More...
 
UNIV_INLINE ulint rec_offs_any_extern (const ulint *offsets)
 Determine if the offsets are for a record containing externally stored columns. More...
 
UNIV_INLINE const byterec_offs_any_null_extern (const rec_t *rec, const ulint *offsets)
 Determine if the offsets are for a record containing null BLOB pointers. More...
 
UNIV_INLINE ulint rec_offs_nth_extern (const ulint *offsets, ulint n)
 Returns nonzero if the extern bit is set in nth field of rec. More...
 
void rec_offs_make_nth_extern (ulint *offsets, const ulint n)
 Mark the nth field as externally stored. More...
 
UNIV_INLINE ulint rec_offs_nth_sql_null (const ulint *offsets, ulint n)
 Returns nonzero if the SQL NULL bit is set in nth field of rec. More...
 
UNIV_INLINE ulint rec_offs_nth_default (const ulint *offsets, ulint n)
 Returns nonzero if the default bit is set in nth field of rec. More...
 
UNIV_INLINE ulint rec_offs_nth_size (const ulint *offsets, ulint n)
 Gets the physical size of a field. More...
 
UNIV_INLINE ulint rec_offs_n_extern (const ulint *offsets)
 Returns the number of extern bits set in a record. More...
 
UNIV_INLINE void rec_set_nth_field (rec_t *rec, const ulint *offsets, ulint n, const void *data, ulint len)
 This is used to modify the value of an already existing field in a record. More...
 
UNIV_INLINE ulint rec_get_data_size_old (const rec_t *rec)
 The following function returns the data size of an old-style physical record, that is the sum of field lengths. More...
 
UNIV_INLINE ulint rec_offs_data_size (const ulint *offsets)
 The following function returns the data size of a physical record, that is the sum of field lengths. More...
 
UNIV_INLINE ulint rec_offs_extra_size (const ulint *offsets)
 Returns the total size of record minus data size of record. More...
 
UNIV_INLINE ulint rec_offs_size (const ulint *offsets)
 Returns the total size of a physical record. More...
 
UNIV_INLINE byterec_get_start (const rec_t *rec, const ulint *offsets)
 Returns a pointer to the start of the record. More...
 
UNIV_INLINE byterec_get_end (const rec_t *rec, const ulint *offsets)
 Returns a pointer to the end of the record. More...
 
UNIV_INLINE rec_trec_copy (void *buf, const rec_t *rec, const ulint *offsets)
 Copy a physical record to a buffer. More...
 
ulint rec_get_converted_size_temp (const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry, ulint *extra)
 Determines the size of a data tuple prefix in a temporary file. More...
 
void rec_init_offsets_temp (const rec_t *rec, const dict_index_t *index, ulint *offsets)
 Determine the offset to each field in temporary file. More...
 
void rec_convert_dtuple_to_temp (rec_t *rec, const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry)
 Builds a temporary file record out of a data tuple. More...
 
rec_trec_copy_prefix_to_buf (const rec_t *rec, const dict_index_t *index, ulint n_fields, byte **buf, size_t *buf_size)
 Copies the first n fields of a physical record to a new physical record in a buffer. More...
 
UNIV_INLINE ulint rec_fold (const rec_t *rec, const ulint *offsets, ulint n_fields, ulint n_bytes, ulint fold, const dict_index_t *index)
 Compute a hash value of a prefix of a leaf page record. More...
 
rec_trec_convert_dtuple_to_rec (byte *buf, const dict_index_t *index, const dtuple_t *dtuple)
 Builds a physical record out of a data tuple and stores it into the given buffer. More...
 
UNIV_INLINE ulint rec_get_converted_extra_size (ulint data_size, ulint n_fields, bool has_ext)
 Returns the extra size of an old-style physical record if we know its data size and number of fields. More...
 
ulint rec_get_converted_size_comp_prefix (const dict_index_t *index, const dfield_t *fields, ulint n_fields, ulint *extra)
 Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. More...
 
ulint rec_get_converted_size_comp (const dict_index_t *index, ulint status, const dfield_t *fields, ulint n_fields, ulint *extra)
 Determines the size of a data tuple in ROW_FORMAT=COMPACT. More...
 
UNIV_INLINE ulint rec_get_converted_size (const dict_index_t *index, const dtuple_t *dtuple)
 The following function returns the size of a data tuple when converted to a physical record. More...
 
void rec_copy_prefix_to_dtuple (dtuple_t *tuple, const rec_t *rec, const dict_index_t *index, ulint n_fields, mem_heap_t *heap)
 Copies the first n fields of a physical record to a data tuple. More...
 
UNIV_INLINE uint8_t rec_get_n_fields_length (ulint n_fields)
 Get the length of the number of fields for any new style record. More...
 
UNIV_INLINE uint8_t rec_set_n_fields (rec_t *rec, ulint n_fields)
 Set the number of fields for one new style leaf page record. More...
 
ibool rec_validate (const rec_t *rec, const ulint *offsets)
 Validates the consistency of a physical record. More...
 
void rec_print_old (FILE *file, const rec_t *rec)
 Prints an old-style physical record. More...
 
void rec_print_mbr_rec (FILE *file, const rec_t *rec, const ulint *offsets)
 Prints a spatial index record. More...
 
void rec_print_new (FILE *file, const rec_t *rec, const ulint *offsets)
 Prints a physical record. More...
 
void rec_print (FILE *file, const rec_t *rec, const dict_index_t *index)
 Prints a physical record. More...
 
void rec_print (std::ostream &o, const rec_t *rec, ulint info, const ulint *offsets)
 Pretty-print a record. More...
 
std::ostream & operator<< (std::ostream &o, const rec_index_print &r)
 Display a record. More...
 
std::ostream & operator<< (std::ostream &o, const rec_offsets_print &r)
 Display a record. More...
 
trx_id_t rec_get_trx_id (const rec_t *rec, const dict_index_t *index)
 Reads the DB_TRX_ID of a clustered index record. More...
 

Variables

constexpr ulint REC_1BYTE_OFFS_LIMIT = 0x7FUL
 
constexpr ulint REC_2BYTE_OFFS_LIMIT = 0x7FFFUL
 
constexpr ulint REC_MAX_DATA_SIZE = 16384
 

Detailed Description

Record manager.

Created 5/30/1994 Heikki Tuuri

Macro Definition Documentation

◆ rec_get_nth_field_old

#define rec_get_nth_field_old (   rec,
  n,
  len 
)    ((rec) + rec_get_nth_field_offs_old(rec, n, len))

◆ rec_get_offsets

#define rec_get_offsets (   rec,
  index,
  offsets,
  n,
  heap 
)    rec_get_offsets_func(rec, index, offsets, n, __FILE__, __LINE__, heap)

◆ rec_offs_init

#define rec_offs_init (   offsets)    rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets)

Function Documentation

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  o,
const rec_index_print r 
)

Display a record.

Parameters
[in,out]ooutput stream
[in]rrecord to display
Returns
the output stream

◆ operator<<() [2/2]

std::ostream& operator<< ( std::ostream &  o,
const rec_offsets_print r 
)

Display a record.

Parameters
[in,out]ooutput stream
[in]rrecord to display
Returns
the output stream

◆ rec_1_get_field_end_info()

UNIV_INLINE ulint rec_1_get_field_end_info ( const rec_t rec,
ulint  n 
)

Returns the offset of nth field end if the record is stored in the 1-byte offsets form.

If the field is SQL null, the flag is ORed in the returned value.

Returns
offset of the start of the field, SQL null flag ORed
Parameters
recin: record
nin: field index

◆ rec_2_get_field_end_info()

UNIV_INLINE ulint rec_2_get_field_end_info ( const rec_t rec,
ulint  n 
)

Returns the offset of nth field end if the record is stored in the 2-byte offsets form.

If the field is SQL null, the flag is ORed in the returned value.

Returns
offset of the start of the field, SQL null flag and extern storage flag ORed
Parameters
recin: record
nin: field index

◆ rec_2_is_field_extern()

UNIV_INLINE ulint rec_2_is_field_extern ( const rec_t rec,
ulint  n 
)

Returns nonzero if the field is stored off-page.

Return values
0if the field is stored in-page
REC_2BYTE_EXTERN_MASKif the field is stored externally
Parameters
recin: record
nin: field index

◆ rec_convert_dtuple_to_rec()

rec_t* rec_convert_dtuple_to_rec ( byte buf,
const dict_index_t index,
const dtuple_t dtuple 
)

Builds a physical record out of a data tuple and stores it into the given buffer.

Returns
pointer to the origin of physical record

Builds a physical record out of a data tuple and stores it into the given buffer.

Returns
pointer to the origin of physical record
Parameters
bufin: start address of the physical record
indexin: record descriptor
dtuplein: data tuple

◆ rec_convert_dtuple_to_temp()

void rec_convert_dtuple_to_temp ( rec_t rec,
const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry 
)

Builds a temporary file record out of a data tuple.

See also
rec_init_offsets_temp() in: dtuple contains virtual column data
rec_init_offsets_temp()
Parameters
recout: record
indexin: record descriptor
fieldsin: array of data fields
n_fieldsin: number of fields
v_entryin: dtuple contains virtual column data

◆ rec_copy()

UNIV_INLINE rec_t* rec_copy ( void *  buf,
const rec_t rec,
const ulint *  offsets 
)

Copy a physical record to a buffer.

Parameters
[in]bufbuffer
[in]recphysical record
[in]offsetsarray returned by rec_get_offsets()
Returns
pointer to the origin of the copy

◆ rec_copy_prefix_to_buf()

rec_t* rec_copy_prefix_to_buf ( const rec_t rec,
const dict_index_t index,
ulint  n_fields,
byte **  buf,
size_t *  buf_size 
)

Copies the first n fields of a physical record to a new physical record in a buffer.

Returns
own: copied record
Parameters
recin: physical record
indexin: record descriptor
n_fieldsin: number of fields to copy
bufin/out: memory buffer for the copied prefix, or NULL
buf_sizein/out: buffer size

◆ rec_copy_prefix_to_dtuple()

void rec_copy_prefix_to_dtuple ( dtuple_t tuple,
const rec_t rec,
const dict_index_t index,
ulint  n_fields,
mem_heap_t heap 
)

Copies the first n fields of a physical record to a data tuple.

The fields are copied to the memory heap. in: memory heap

The fields are copied to the memory heap.

Parameters
tupleout: data tuple
recin: physical record
indexin: record descriptor
n_fieldsin: number of fields to copy
heapin: memory heap

◆ rec_field_not_null_not_add_col_def()

UNIV_INLINE bool rec_field_not_null_not_add_col_def ( ulint  len)

Determine if the field is not NULL and not having default value after instant ADD COLUMN.

Parameters
[in]lenlength of a field
Returns
true if not NULL and not having default value

◆ rec_fold()

UNIV_INLINE ulint rec_fold ( const rec_t rec,
const ulint *  offsets,
ulint  n_fields,
ulint  n_bytes,
ulint  fold,
const dict_index_t index 
)

Compute a hash value of a prefix of a leaf page record.

Parameters
[in]recleaf page record
[in]offsetsrec_get_offsets(rec)
[in]n_fieldsnumber of complete fields to fold
[in]n_bytesnumber of bytes to fold in the last field
[in]foldfold value of the index identifier
[in]indexindex where the record resides
Returns
the folded value

◆ rec_get_1byte_offs_flag()

UNIV_INLINE ibool rec_get_1byte_offs_flag ( const rec_t rec)

The following function is used to test whether the data offsets in the record are stored in one-byte or two-byte format.

Returns
true if 1-byte form
Parameters
recin: physical record

◆ rec_get_converted_extra_size()

UNIV_INLINE ulint rec_get_converted_extra_size ( ulint  data_size,
ulint  n_fields,
bool  has_ext 
)

Returns the extra size of an old-style physical record if we know its data size and number of fields.

Parameters
[in]data_sizedata size
[in]n_fieldsnumber of fields
[in]has_exttrue if tuple has ext fields
Returns
extra size

◆ rec_get_converted_size()

UNIV_INLINE ulint rec_get_converted_size ( const dict_index_t index,
const dtuple_t dtuple 
)

The following function returns the size of a data tuple when converted to a physical record.

Parameters
[in]indexrecord descriptor
[in]dtupledata tuple
Returns
size

◆ rec_get_converted_size_comp()

ulint rec_get_converted_size_comp ( const dict_index_t index,
ulint  status,
const dfield_t fields,
ulint  n_fields,
ulint *  extra 
)

Determines the size of a data tuple in ROW_FORMAT=COMPACT.

Returns
total size out: extra size
total size
Parameters
indexin: record descriptor; dict_table_is_comp() is assumed to hold, even if it does not
statusin: status bits of the record
fieldsin: array of data fields
n_fieldsin: number of data fields
extraout: extra size

◆ rec_get_converted_size_comp_prefix()

ulint rec_get_converted_size_comp_prefix ( const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
ulint *  extra 
)

Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT.

Returns
total size
Parameters
indexin: record descriptor
fieldsin: array of data fields
n_fieldsin: number of data fields
extraout: extra size

◆ rec_get_converted_size_temp()

ulint rec_get_converted_size_temp ( const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry,
ulint *  extra 
)

Determines the size of a data tuple prefix in a temporary file.

Returns
total size

Determines the size of a data tuple prefix in a temporary file.

Returns
total size
Parameters
indexin: record descriptor
fieldsin: array of data fields
n_fieldsin: number of data fields
v_entryin: dtuple contains virtual column data
extraout: extra size

◆ rec_get_data_size_old()

UNIV_INLINE ulint rec_get_data_size_old ( const rec_t rec)

The following function returns the data size of an old-style physical record, that is the sum of field lengths.

SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes.

Returns
size
Parameters
recin: physical record

◆ rec_get_deleted_flag()

UNIV_INLINE ulint rec_get_deleted_flag ( const rec_t rec,
ulint  comp 
)

The following function tells if record is delete marked.

Returns
nonzero if delete marked
Parameters
recin: physical record
compin: nonzero=compact page format

◆ rec_get_end()

UNIV_INLINE byte* rec_get_end ( const rec_t rec,
const ulint *  offsets 
)

Returns a pointer to the end of the record.

Returns
pointer to end
Parameters
recin: pointer to record
offsetsin: array returned by rec_get_offsets()

◆ rec_get_heap_no_new()

UNIV_INLINE ulint rec_get_heap_no_new ( const rec_t rec)

The following function is used to get the order number of a new-style record in the heap of the index page.

Parameters
[in]recphysical record
Returns
heap order number

◆ rec_get_heap_no_old()

UNIV_INLINE ulint rec_get_heap_no_old ( const rec_t rec)

The following function is used to get the order number of an old-style record in the heap of the index page.

Parameters
[in]recphysical record
Returns
heap order number

◆ rec_get_info_and_status_bits()

UNIV_INLINE ulint rec_get_info_and_status_bits ( const rec_t rec,
ulint  comp 
)

The following function is used to retrieve the info and status bits of a record.

(Only compact records have status bits.)

Returns
info bits
Parameters
recin: physical record
compin: nonzero=compact page format

◆ rec_get_n_extern_new()

ulint rec_get_n_extern_new ( const rec_t rec,
const dict_index_t index,
ulint  n 
)

Determine how many of the first n columns in a compact physical record are stored externally.

Returns
number of externally stored columns
Parameters
recin: compact physical record
indexin: record descriptor
nin: number of columns to scan

◆ rec_get_n_fields_length()

UNIV_INLINE uint8_t rec_get_n_fields_length ( ulint  n_fields)

Get the length of the number of fields for any new style record.

Parameters
[in]n_fieldsnumber of fields in the record
Returns
length of specified number of fields

◆ rec_get_n_owned_new()

UNIV_INLINE ulint rec_get_n_owned_new ( const rec_t rec)

The following function is used to get the number of records owned by the previous directory record.

Returns
number of owned records
Parameters
recin: new-style physical record

◆ rec_get_n_owned_old()

UNIV_INLINE ulint rec_get_n_owned_old ( const rec_t rec)

The following function is used to get the number of records owned by the previous directory record.

Returns
number of owned records
Parameters
recin: old-style physical record

◆ rec_get_next_offs()

UNIV_INLINE ulint rec_get_next_offs ( const rec_t rec,
ulint  comp 
)

The following function is used to get the offset of the next chained record on the same page.

Returns
the page offset of the next chained record, or 0 if none
Parameters
recin: physical record
compin: nonzero=compact page format

◆ rec_get_next_ptr()

UNIV_INLINE rec_t* rec_get_next_ptr ( rec_t rec,
ulint  comp 
)

The following function is used to get the pointer of the next chained record on the same page.

Returns
pointer to the next chained record, or NULL if none
Parameters
recin: physical record
compin: nonzero=compact page format

◆ rec_get_next_ptr_const()

UNIV_INLINE const rec_t* rec_get_next_ptr_const ( const rec_t rec,
ulint  comp 
)

The following function is used to get the pointer of the next chained record on the same page.

Returns
pointer to the next chained record, or NULL if none
Parameters
recin: physical record
compin: nonzero=compact page format

◆ rec_get_node_ptr_flag()

UNIV_INLINE bool rec_get_node_ptr_flag ( const rec_t rec)

The following function tells if a new-style record is a node pointer.

Returns
true if node pointer
Parameters
recin: physical record

◆ rec_get_nth_field()

byte* rec_get_nth_field ( const rec_t rec,
const ulint *  offsets,
ulint  n,
ulint *  len 
)
inline

Gets the value of the specified field in the record.

This is used for normal cases, i.e. secondary index or clustered index which must have no instantly added columns. Also note, if it's non-leaf page records, it's OK to always use this functioni.

Parameters
[in]recphysical record
[in]offsetsarray returned by rec_get_offsets()
[in]nindex of the field
[out]lenlength of the field, UNIV_SQL_NULL if SQL null
Returns
value of the field

◆ rec_get_nth_field_instant()

UNIV_INLINE const byte* rec_get_nth_field_instant ( const rec_t rec,
const ulint *  offsets,
ulint  n,
const dict_index_t index,
ulint *  len 
)

Gets the value of the specified field in the record.

This is only used when there is possibility that the record comes from the clustered index, which has some instantly added columns.

Parameters
[in]recphysical record
[in]offsetsarray returned by rec_get_offsets()
[in]nindex of the field
[in]indexclustered index where the record resides, or nullptr if the record doesn't have instantly added columns for sure
[out]lenlength of the field, UNIV_SQL_NULL if SQL null
Returns
value of the field, could be either pointer to rec or default value

◆ rec_get_nth_field_offs()

UNIV_INLINE ulint rec_get_nth_field_offs ( const ulint *  offsets,
ulint  n,
ulint *  len 
)

The following function is used to get an offset to the nth data field in a record.

Parameters
[in]offsetsarray returned by rec_get_offsets()
[in]nindex of the field
[out]lenlength of the field; UNIV_SQL_NULL if SQL null; UNIV_SQL_ADD_COL_DEFAULT if it's default value and no value inlined
Returns
offset from the origin of rec

◆ rec_get_nth_field_offs_old()

ulint rec_get_nth_field_offs_old ( const rec_t rec,
ulint  n,
ulint *  len 
)

The following function is used to get the offset to the nth data field in an old-style record.

Returns
offset to the field out: length of the field; UNIV_SQL_NULL if SQL null
offset to the field
Parameters
recin: record
nin: index of the field
lenout: length of the field; UNIV_SQL_NULL if SQL null

◆ rec_get_nth_field_old_instant()

UNIV_INLINE const byte* rec_get_nth_field_old_instant ( const rec_t rec,
uint16_t  n,
const dict_index_t index,
ulint *  len 
)

Gets the value of the specified field in the record in old style.

This is only used for record from instant index, which is clustered index and has some instantly added columns.

Parameters
[in]recphysical record
[in]nindex of the field
[in]indexclustered index where the record resides
[out]lenlength of the field, UNIV_SQL if SQL null
Returns
value of the field, could be either pointer to rec or default value

◆ rec_get_nth_field_size()

UNIV_INLINE ulint rec_get_nth_field_size ( const rec_t rec,
ulint  n 
)

Gets the physical size of an old-style field.

Also an SQL null may have a field of size > 0, if the data type is of a fixed size.

Returns
field size in bytes
Parameters
recin: record
nin: index of the field

◆ rec_get_start()

UNIV_INLINE byte* rec_get_start ( const rec_t rec,
const ulint *  offsets 
)

Returns a pointer to the start of the record.

Returns
pointer to start
Parameters
recin: pointer to record
offsetsin: array returned by rec_get_offsets()

◆ rec_get_trx_id()

trx_id_t rec_get_trx_id ( const rec_t rec,
const dict_index_t index 
)

Reads the DB_TRX_ID of a clustered index record.

Returns
the value of DB_TRX_ID
Parameters
recin: record
indexin: clustered index

◆ rec_init_offsets_temp()

void rec_init_offsets_temp ( const rec_t rec,
const dict_index_t index,
ulint *  offsets 
)

Determine the offset to each field in temporary file.

See also
rec_convert_dtuple_to_temp() in/out: array of offsets; in: n=rec_offs_n_fields(offsets)
rec_convert_dtuple_to_temp()
Parameters
recin: temporary file record
indexin: record descriptor
offsetsin/out: array of offsets; in: n=rec_offs_n_fields(offsets)

◆ rec_offs_any_extern()

UNIV_INLINE ulint rec_offs_any_extern ( const ulint *  offsets)

Determine if the offsets are for a record containing externally stored columns.

Returns
nonzero if externally stored
Parameters
offsetsin: array returned by rec_get_offsets()

◆ rec_offs_any_null_extern()

UNIV_INLINE const byte* rec_offs_any_null_extern ( const rec_t rec,
const ulint *  offsets 
)

Determine if the offsets are for a record containing null BLOB pointers.

Returns
first field containing a null BLOB pointer, or NULL if none found
Parameters
recin: record
offsetsin: rec_get_offsets(rec)

◆ rec_offs_comp()

UNIV_INLINE ulint rec_offs_comp ( const ulint *  offsets)

Determine if the offsets are for a record in the new compact format.

Returns
nonzero if compact format
Parameters
offsetsin: array returned by rec_get_offsets()

◆ rec_offs_data_size()

UNIV_INLINE ulint rec_offs_data_size ( const ulint *  offsets)

The following function returns the data size of a physical record, that is the sum of field lengths.

SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes.

Returns
size
Parameters
offsetsin: array returned by rec_get_offsets()

◆ rec_offs_extra_size()

UNIV_INLINE ulint rec_offs_extra_size ( const ulint *  offsets)

Returns the total size of record minus data size of record.

The value returned by the function is the distance from record start to record origin in bytes.

Returns
size
Parameters
offsetsin: array returned by rec_get_offsets()

◆ rec_offs_make_nth_extern()

void rec_offs_make_nth_extern ( ulint *  offsets,
const ulint  n 
)

Mark the nth field as externally stored.

Parameters
[in]offsetsarray returned by rec_get_offsets()
[in]nnth field

◆ rec_offs_n_extern()

UNIV_INLINE ulint rec_offs_n_extern ( const ulint *  offsets)

Returns the number of extern bits set in a record.

Returns
number of externally stored fields
Parameters
offsetsin: array returned by rec_get_offsets()

◆ rec_offs_nth_default()

UNIV_INLINE ulint rec_offs_nth_default ( const ulint *  offsets,
ulint  n 
)

Returns nonzero if the default bit is set in nth field of rec.

Returns
nonzero if default bit is set

◆ rec_offs_nth_extern()

UNIV_INLINE ulint rec_offs_nth_extern ( const ulint *  offsets,
ulint  n 
)

Returns nonzero if the extern bit is set in nth field of rec.

Returns
nonzero if externally stored
Parameters
offsetsin: array returned by rec_get_offsets()
nin: nth field

◆ rec_offs_nth_size()

UNIV_INLINE ulint rec_offs_nth_size ( const ulint *  offsets,
ulint  n 
)

Gets the physical size of a field.

Returns
length of field
Parameters
offsetsin: array returned by rec_get_offsets()
nin: nth field

◆ rec_offs_nth_sql_null()

UNIV_INLINE ulint rec_offs_nth_sql_null ( const ulint *  offsets,
ulint  n 
)

Returns nonzero if the SQL NULL bit is set in nth field of rec.

Returns
nonzero if SQL NULL
Parameters
offsetsin: array returned by rec_get_offsets()
nin: nth field

◆ rec_offs_size()

UNIV_INLINE ulint rec_offs_size ( const ulint *  offsets)

Returns the total size of a physical record.

Returns
size
Parameters
offsetsin: array returned by rec_get_offsets()

◆ rec_print() [1/2]

void rec_print ( FILE *  file,
const rec_t rec,
const dict_index_t index 
)

Prints a physical record.

Parameters
[in]fileFile where to print
[in]recPhysical record
[in]indexRecord descriptor

◆ rec_print() [2/2]

void rec_print ( std::ostream &  o,
const rec_t rec,
ulint  info,
const ulint *  offsets 
)

Pretty-print a record.

Parameters
[in,out]ooutput stream
[in]recphysical record
[in]inforec_get_info_bits(rec)
[in]offsetsrec_get_offsets(rec)

◆ rec_print_mbr_rec()

void rec_print_mbr_rec ( FILE *  file,
const rec_t rec,
const ulint *  offsets 
)

Prints a spatial index record.

Parameters
[in]fileFile where to print
[in]recPhysical record
[in]offsetsArray returned by rec_get_offsets()

◆ rec_print_new()

void rec_print_new ( FILE *  file,
const rec_t rec,
const ulint *  offsets 
)

Prints a physical record.

in: array returned by rec_get_offsets()

Prints a physical record.

Parameters
filein: file where to print
recin: physical record
offsetsin: array returned by rec_get_offsets()

◆ rec_print_old()

void rec_print_old ( FILE *  file,
const rec_t rec 
)

Prints an old-style physical record.

Parameters
[in]fileFile where to print
[in]recPhysical record

◆ rec_set_1byte_offs_flag()

UNIV_INLINE void rec_set_1byte_offs_flag ( rec_t rec,
ibool  flag 
)

The following function is used to set the 1-byte offsets flag.

Parameters
[in]recphysical record
[in]flagTRUE if 1byte form

◆ rec_set_deleted_flag_new()

UNIV_INLINE void rec_set_deleted_flag_new ( rec_t rec,
page_zip_des_t page_zip,
ulint  flag 
)

The following function is used to set the deleted bit.

Parameters
[in,out]recnew-style physical record
[in,out]page_zipcompressed page, or NULL
[in]flagnonzero if delete marked

◆ rec_set_deleted_flag_old()

UNIV_INLINE void rec_set_deleted_flag_old ( rec_t rec,
ulint  flag 
)

The following function is used to set the deleted bit.

Parameters
[in]recold-style physical record
[in]flagnonzero if delete marked

◆ rec_set_heap_no_new()

UNIV_INLINE void rec_set_heap_no_new ( rec_t rec,
ulint  heap_no 
)

The following function is used to set the heap number field in a new-style record.

Parameters
[in,out]recphysical record
[in]heap_nothe heap number

◆ rec_set_heap_no_old()

UNIV_INLINE void rec_set_heap_no_old ( rec_t rec,
ulint  heap_no 
)

The following function is used to set the heap number field in an old-style record.

Parameters
[in]recphysical record
[in]heap_nothe heap number

◆ rec_set_info_and_status_bits()

UNIV_INLINE void rec_set_info_and_status_bits ( rec_t rec,
ulint  bits 
)

The following function is used to set the info and status bits of a record.

(Only compact records have status bits.)

Parameters
[in,out]reccompact physical record
[in]bitsinfo bits

◆ rec_set_info_bits_new()

UNIV_INLINE void rec_set_info_bits_new ( rec_t rec,
ulint  bits 
)

The following function is used to set the info bits of a record.

Parameters
[in,out]recnew-style physical record
[in]bitsinfo bits

◆ rec_set_info_bits_old()

UNIV_INLINE void rec_set_info_bits_old ( rec_t rec,
ulint  bits 
)

The following function is used to set the info bits of a record.

Parameters
[in]recold-style physical record
[in]bitsinfo bits

◆ rec_set_instant_flag_new()

UNIV_INLINE void rec_set_instant_flag_new ( rec_t rec,
bool  flag 
)

The following function is used to set the instant bit.

Parameters
[in,out]recnew-style physical record
[in]flagset the bit to this flag

◆ rec_set_n_fields()

UNIV_INLINE uint8_t rec_set_n_fields ( rec_t rec,
ulint  n_fields 
)

Set the number of fields for one new style leaf page record.

This is only needed for table after instant ADD COLUMN.

Parameters
[in,out]recleaf page record
[in]n_fieldsnumber of fields in the record
Returns
the length of the n_fields occupies

◆ rec_set_n_owned_new()

UNIV_INLINE void rec_set_n_owned_new ( rec_t rec,
page_zip_des_t page_zip,
ulint  n_owned 
)

The following function is used to set the number of owned records.

Parameters
[in,out]recnew-style physical record
[in,out]page_zipcompressed page, or NULL
[in]n_ownedthe number of owned

◆ rec_set_n_owned_old()

UNIV_INLINE void rec_set_n_owned_old ( rec_t rec,
ulint  n_owned 
)

The following function is used to set the number of owned records.

Parameters
[in]recold-style physical record
[in]n_ownedthe number of owned

◆ rec_set_next_offs_new()

UNIV_INLINE void rec_set_next_offs_new ( rec_t rec,
ulint  next 
)

The following function is used to set the next record offset field of a new-style record.

◆ rec_set_next_offs_old()

UNIV_INLINE void rec_set_next_offs_old ( rec_t rec,
ulint  next 
)

The following function is used to set the next record offset field of an old-style record.

Parameters
[in]recold-style physical record
[in]nextoffset of the next record

◆ rec_set_nth_field()

UNIV_INLINE void rec_set_nth_field ( rec_t rec,
const ulint *  offsets,
ulint  n,
const void *  data,
ulint  len 
)

This is used to modify the value of an already existing field in a record.

The previous value must have exactly the same size as the new value. If len is UNIV_SQL_NULL then the field is treated as an SQL null. For records in ROW_FORMAT=COMPACT (new-style records), len must not be UNIV_SQL_NULL unless the field already is SQL null.

Parameters
[in]recrecord
[in]offsetsarray returned by rec_get_offsets()
[in]nindex number of the field
[in]lenlength of the data or UNIV_SQL_NULL. If not SQL null, must have the same length as the previous value. If SQL null, previous value must be SQL null.
[in]datapointer to the data if not SQL null

◆ rec_set_status()

UNIV_INLINE void rec_set_status ( rec_t rec,
ulint  bits 
)

The following function is used to set the status bits of a new-style record.

Parameters
[in,out]recphysical record
[in]bitsinfo bits

◆ rec_validate()

ibool rec_validate ( const rec_t rec,
const ulint *  offsets 
)

Validates the consistency of a physical record.

Returns
true if ok in: array returned by rec_get_offsets()
true if ok
Parameters
recin: physical record
offsetsin: array returned by rec_get_offsets()

Variable Documentation

◆ REC_1BYTE_OFFS_LIMIT

constexpr ulint REC_1BYTE_OFFS_LIMIT = 0x7FUL

◆ REC_2BYTE_OFFS_LIMIT

constexpr ulint REC_2BYTE_OFFS_LIMIT = 0x7FFFUL

◆ REC_MAX_DATA_SIZE

constexpr ulint REC_MAX_DATA_SIZE = 16384