Drizzled Public API Documentation

trx0rec.h File Reference
#include "univ.i"
#include "trx0types.h"
#include "row0types.h"
#include "mtr0mtr.h"
#include "dict0types.h"
#include "data0data.h"
#include "rem0types.h"
#include "que0types.h"

Go to the source code of this file.

Defines

#define trx_undo_rec_get_ptr(undo_rec, undo_no)   ((undo_rec) + trx_undo_rec_get_offset(undo_no))
#define TRX_UNDO_INSERT_REC   11 /* fresh insert into clustered index */
#define TRX_UNDO_UPD_EXIST_REC
#define TRX_UNDO_UPD_DEL_REC
#define TRX_UNDO_DEL_MARK_REC
#define TRX_UNDO_CMPL_INFO_MULT
#define TRX_UNDO_UPD_EXTERN
#define TRX_UNDO_INSERT_OP   1
#define TRX_UNDO_MODIFY_OP   2

Functions

UNIV_INLINE trx_undo_rec_ttrx_undo_rec_copy (const trx_undo_rec_t *undo_rec, mem_heap_t *heap)
UNIV_INLINE ulint trx_undo_rec_get_type (const trx_undo_rec_t *undo_rec)
UNIV_INLINE ulint trx_undo_rec_get_cmpl_info (const trx_undo_rec_t *undo_rec)
UNIV_INLINE ibool trx_undo_rec_get_extern_storage (const trx_undo_rec_t *undo_rec)
UNIV_INLINE undo_no_t trx_undo_rec_get_undo_no (const trx_undo_rec_t *undo_rec)
UNIV_INLINE ulint trx_undo_rec_get_offset (undo_no_t undo_no) __attribute__((const ))
UNIV_INTERN byte * trx_undo_rec_get_pars (trx_undo_rec_t *undo_rec, ulint *type, ulint *cmpl_info, ibool *updated_extern, undo_no_t *undo_no, table_id_t *table_id)
UNIV_INTERN byte * trx_undo_rec_get_row_ref (byte *ptr, dict_index_t *index, dtuple_t **ref, mem_heap_t *heap)
UNIV_INTERN byte * trx_undo_rec_skip_row_ref (byte *ptr, dict_index_t *index)
UNIV_INTERN byte * trx_undo_update_rec_get_sys_cols (byte *ptr, trx_id_t *trx_id, roll_ptr_t *roll_ptr, ulint *info_bits)
UNIV_INTERN byte * trx_undo_update_rec_get_update (byte *ptr, dict_index_t *index, ulint type, trx_id_t trx_id, roll_ptr_t roll_ptr, ulint info_bits, trx_t *trx, mem_heap_t *heap, upd_t **upd)
UNIV_INTERN byte * trx_undo_rec_get_partial_row (byte *ptr, dict_index_t *index, dtuple_t **row, ibool ignore_prefix, mem_heap_t *heap)
UNIV_INTERN ulint trx_undo_report_row_operation (ulint flags, ulint op_type, que_thr_t *thr, dict_index_t *index, const dtuple_t *clust_entry, const upd_t *update, ulint cmpl_info, const rec_t *rec, roll_ptr_t *roll_ptr)
UNIV_INTERN trx_undo_rec_ttrx_undo_get_undo_rec_low (roll_ptr_t roll_ptr, mem_heap_t *heap)
UNIV_INTERN ulint trx_undo_get_undo_rec (roll_ptr_t roll_ptr, trx_id_t trx_id, trx_undo_rec_t **undo_rec, mem_heap_t *heap)
UNIV_INTERN ulint trx_undo_prev_version_build (const rec_t *index_rec, mtr_t *index_mtr, const rec_t *rec, dict_index_t *index, ulint *offsets, mem_heap_t *heap, rec_t **old_vers)
UNIV_INTERN byte * trx_undo_parse_add_undo_rec (byte *ptr, byte *end_ptr, page_t *page)
UNIV_INTERN byte * trx_undo_parse_erase_page_end (byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)

Detailed Description

Transaction undo log record

Created 3/26/1996 Heikki Tuuri

Definition in file trx0rec.h.


Define Documentation

#define TRX_UNDO_CMPL_INFO_MULT
Value:
16  /* compilation info is multiplied by
          this and ORed to the type above */

Definition at line 318 of file trx0rec.h.

#define TRX_UNDO_DEL_MARK_REC
Value:
14  /* delete marking of a record; fields
          do not change */

Definition at line 317 of file trx0rec.h.

#define trx_undo_rec_get_ptr (   undo_rec,
  undo_no 
)    ((undo_rec) + trx_undo_rec_get_offset(undo_no))

Returns the start of the undo record data area.

Definition at line 94 of file trx0rec.h.

#define TRX_UNDO_UPD_DEL_REC
Value:
13  /* update of a delete marked record to
          a not delete marked record; also the
          fields of the record can change */

Definition at line 316 of file trx0rec.h.

#define TRX_UNDO_UPD_EXIST_REC
Value:
12  /* update of a non-delete-marked
          record */

Definition at line 315 of file trx0rec.h.

#define TRX_UNDO_UPD_EXTERN
Value:
128 /* This bit can be ORed to type_cmpl
          to denote that we updated external
          storage fields: used by purge to
          free the external storage */

Definition at line 319 of file trx0rec.h.


Function Documentation

UNIV_INTERN ulint trx_undo_get_undo_rec ( roll_ptr_t  roll_ptr,
trx_id_t  trx_id,
trx_undo_rec_t **  undo_rec,
mem_heap_t heap 
)

Copies an undo record to heap.

NOTE: the caller must have latches on the clustered index page and purge_view.

Returns:
DB_SUCCESS, or DB_MISSING_HISTORY if the undo log has been truncated and we cannot fetch the old version in: memory heap where copied

Copies an undo record to heap.

NOTE: the caller must have latches on the clustered index page and purge_view.

Returns:
DB_SUCCESS, or DB_MISSING_HISTORY if the undo log has been truncated and we cannot fetch the old version
Parameters:
roll_ptrin: roll pointer to record
trx_idin: id of the trx that generated the roll pointer: it points to an undo log of this transaction
undo_recout, own: copy of the record
heapin: memory heap where copied

Definition at line 1377 of file trx0rec.cc.

References trx_purge_struct::latch, purge_sys, trx_purge_update_undo_must_exist(), trx_undo_get_undo_rec(), trx_undo_get_undo_rec_low(), and ut_ad.

Referenced by trx_undo_get_undo_rec(), and trx_undo_prev_version_build().

UNIV_INTERN trx_undo_rec_t* trx_undo_get_undo_rec_low ( roll_ptr_t  roll_ptr,
mem_heap_t heap 
)

Copies an undo record to heap. This function can be called if we know that the undo log record exists.

Returns:
own: copy of the record in: memory heap where copied

Copies an undo record to heap. This function can be called if we know that the undo log record exists.

Returns:
own: copy of the record
Parameters:
roll_ptrin: roll pointer to record
heapin: memory heap where copied

Definition at line 1337 of file trx0rec.cc.

References mtr_commit(), mtr_start(), trx_rseg_struct::space, trx_rseg_get_on_id(), trx_undo_decode_roll_ptr(), trx_undo_get_undo_rec_low(), trx_undo_page_get_s_latched(), and trx_undo_rec_copy().

Referenced by row_vers_build_for_consistent_read(), trx_undo_get_undo_rec(), and trx_undo_get_undo_rec_low().

UNIV_INTERN byte* trx_undo_parse_add_undo_rec ( byte *  ptr,
byte *  end_ptr,
page_t page 
)

Parses a redo log record of adding an undo log record.

Returns:
end of log record or NULL in: page or NULL

Parses a redo log record of adding an undo log record.

Returns:
end of log record or NULL
Parameters:
ptrin: buffer
end_ptrin: buffer end
pagein: page or NULL

Definition at line 94 of file trx0rec.cc.

References mach_read_from_2(), mach_write_to_2(), TRX_UNDO_PAGE_FREE, TRX_UNDO_PAGE_HDR, trx_undo_parse_add_undo_rec(), and ut_memcpy().

Referenced by trx_undo_parse_add_undo_rec().

UNIV_INTERN byte* trx_undo_parse_erase_page_end ( byte *  ptr,
byte *  ,
page_t page,
mtr_t mtr 
)

Parses a redo log record of erasing of an undo page end.

Returns:
end of log record or NULL in: mtr or NULL

Parses a redo log record of erasing of an undo page end.

Returns:
end of log record or NULL
Parameters:
ptrin: buffer
pagein: page or NULL
mtrin: mtr or NULL

Definition at line 1123 of file trx0rec.cc.

References trx_undo_parse_erase_page_end(), and ut_ad.

Referenced by trx_undo_parse_erase_page_end().

UNIV_INTERN ulint trx_undo_prev_version_build ( const rec_t *  index_rec,
mtr_t ,
const rec_t *  rec,
dict_index_t index,
ulint *  offsets,
mem_heap_t heap,
rec_t **  old_vers 
)

Build a previous version of a clustered index record. This function checks that the caller has a latch on the index page of the clustered index record and an s-latch on the purge_view. This guarantees that the stack of versions is locked.

Returns:
DB_SUCCESS, or DB_MISSING_HISTORY if the previous version is earlier than purge_view, which means that it may have been removed, DB_ERROR if corrupted record out, own: previous version, or NULL if rec is the first inserted version, or if history data has been deleted

Build a previous version of a clustered index record. This function checks that the caller has a latch on the index page of the clustered index record and an s-latch on the purge_view. This guarantees that the stack of versions is locked all the way down to the purge_view.

Returns:
DB_SUCCESS, or DB_MISSING_HISTORY if the previous version is earlier than purge_view, which means that it may have been removed, DB_ERROR if corrupted record
Parameters:
index_recin: clustered index record in the index tree
recin: version of a clustered index record
indexin: clustered index
offsetsin: rec_get_offsets(rec, index)
heapin: memory heap from which the memory needed is allocated
old_versout, own: previous version, or NULL if rec is the first inserted version, or if history data has been deleted (an error), or if the purge COULD have removed the version though it has not yet done so

Definition at line 1413 of file trx0rec.cc.

References dict_index_get_n_unique(), dict_index_is_clust(), dict_table_struct::id, trx_purge_struct::latch, mem_heap_alloc(), dict_index_struct::name, purge_sys, rec_convert_dtuple_to_rec(), rec_copy(), rec_get_converted_size(), rec_offs_size(), rec_offs_validate(), rec_print(), rec_print_new(), row_get_rec_roll_ptr(), row_get_rec_trx_id(), row_rec_to_index_entry(), row_upd_changes_field_size_or_external(), row_upd_index_replace_new_col_vals(), row_upd_rec_in_place(), dict_index_struct::table, dict_index_struct::table_name, TRX_ID_FMT, trx_purge_sys_print(), trx_undo_get_undo_rec(), trx_undo_prev_version_build(), trx_undo_rec_get_pars(), trx_undo_rec_skip_row_ref(), trx_undo_roll_ptr_is_insert(), trx_undo_update_rec_get_sys_cols(), trx_undo_update_rec_get_update(), ut_ad, and ut_print_buf().

Referenced by row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), row_vers_impl_x_locked_off_kernel(), row_vers_old_has_index_entry(), and trx_undo_prev_version_build().

UNIV_INLINE trx_undo_rec_t* trx_undo_rec_copy ( const trx_undo_rec_t undo_rec,
mem_heap_t heap 
)

Copies the undo record to the heap.

Returns:
own: copy of undo log record in: heap where copied
Parameters:
undo_recin: undo log record

Referenced by trx_roll_pop_top_rec_of_trx(), and trx_undo_get_undo_rec_low().

UNIV_INLINE ulint trx_undo_rec_get_cmpl_info ( const trx_undo_rec_t undo_rec)

Reads from an undo log record the record compiler info.

Returns:
compiler info in: undo log record
UNIV_INLINE ibool trx_undo_rec_get_extern_storage ( const trx_undo_rec_t undo_rec)

Returns TRUE if an undo log record contains an extern storage field.

Returns:
TRUE if extern in: undo log record
UNIV_INLINE ulint trx_undo_rec_get_offset ( undo_no_t  undo_no) const

Returns the start of the undo record data area.

Returns:
offset to the data area
Parameters:
undo_noin: undo no read from node
UNIV_INTERN byte* trx_undo_rec_get_pars ( trx_undo_rec_t undo_rec,
ulint *  type,
ulint *  cmpl_info,
ibool *  updated_extern,
undo_no_t undo_no,
table_id_t *  table_id 
)

Reads from an undo log record the general parameters.

Returns:
remaining part of undo log record after reading these values out: table id

Reads from an undo log record the general parameters.

Returns:
remaining part of undo log record after reading these values
Parameters:
undo_recin: undo log record
typeout: undo record type: TRX_UNDO_INSERT_REC, ...
cmpl_infoout: compiler info, relevant only for update type records
updated_externout: TRUE if we updated an externally stored fild
undo_noout: undo log record number
table_idout: table id

Definition at line 282 of file trx0rec.cc.

References mach_read_from_1(), mach_ull_get_much_compressed_size(), mach_ull_read_much_compressed(), and trx_undo_rec_get_pars().

Referenced by trx_undo_prev_version_build(), and trx_undo_rec_get_pars().

UNIV_INTERN byte* trx_undo_rec_get_partial_row ( byte *  ptr,
dict_index_t index,
dtuple_t **  row,
ibool  ignore_prefix,
mem_heap_t heap 
)

Builds a partial row from an update undo log record. It contains the columns which occur as ordering in any index of the table.

Returns:
pointer to remaining part of undo record in: memory heap from which the memory needed is allocated

Builds a partial row from an update undo log record. It contains the columns which occur as ordering in any index of the table.

Returns:
pointer to remaining part of undo record
Parameters:
ptrin: remaining part in update undo log record of a suitable type, at the start of the stored index columns; NOTE that this copy of the undo log record must be preserved as long as the partial row is used, as we do NOT copy the data in the record!
indexin: clustered index
rowout, own: partial row
ignore_prefixin: flag to indicate if we expect blob prefixes in undo. Used only in the assertion.
heapin: memory heap from which the memory needed is allocated

Definition at line 1020 of file trx0rec.cc.

References dfield_get_len(), dfield_set_data(), dfield_set_ext(), dfield_set_len(), dict_col_get_no(), dict_index_get_nth_col(), dict_index_is_clust(), dict_table_get_format(), dict_table_get_n_cols(), DICT_TF_FORMAT_ZIP, dtuple_create(), mach_read_from_2(), dict_col_struct::ord_part, dict_index_struct::table, trx_undo_rec_get_partial_row(), ut_a, and ut_ad.

Referenced by trx_undo_rec_get_partial_row().

UNIV_INTERN byte* trx_undo_rec_get_row_ref ( byte *  ptr,
dict_index_t index,
dtuple_t **  ref,
mem_heap_t heap 
)

Builds a row reference from an undo log record.

Returns:
pointer to remaining part of undo record in: memory heap from which the memory needed is allocated

Builds a row reference from an undo log record.

Returns:
pointer to remaining part of undo record
Parameters:
ptrin: remaining part of a copy of an undo log record, at the start of the row reference; NOTE that this copy of the undo log record must be preserved as long as the row reference is used, as we do NOT copy the data in the record!
indexin: clustered index
refout, own: row reference
heapin: memory heap from which the memory needed is allocated

Definition at line 380 of file trx0rec.cc.

References dfield_set_data(), dict_index_get_n_unique(), dict_index_is_clust(), dtuple_create(), trx_undo_rec_get_row_ref(), ut_a, and ut_ad.

Referenced by trx_undo_rec_get_row_ref().

UNIV_INLINE ulint trx_undo_rec_get_type ( const trx_undo_rec_t undo_rec)

Reads the undo log record type.

Returns:
record type in: undo log record
UNIV_INLINE undo_no_t trx_undo_rec_get_undo_no ( const trx_undo_rec_t undo_rec)

Reads the undo log record number.

Returns:
undo no in: undo log record

Referenced by row_vers_build_for_consistent_read(), trx_roll_pop_top_rec_of_trx(), trx_undo_truncate_end(), and trx_undo_truncate_start().

UNIV_INTERN byte* trx_undo_rec_skip_row_ref ( byte *  ptr,
dict_index_t index 
)

Skips a row reference from an undo log record.

Returns:
pointer to remaining part of undo record in: clustered index

Skips a row reference from an undo log record.

Returns:
pointer to remaining part of undo record
Parameters:
ptrin: remaining part in update undo log record, at the start of the row reference
indexin: clustered index

Definition at line 426 of file trx0rec.cc.

References dict_index_get_n_unique(), dict_index_is_clust(), trx_undo_rec_skip_row_ref(), ut_a, and ut_ad.

Referenced by trx_undo_prev_version_build(), and trx_undo_rec_skip_row_ref().

UNIV_INTERN ulint trx_undo_report_row_operation ( ulint  flags,
ulint  op_type,
que_thr_t thr,
dict_index_t index,
const dtuple_t clust_entry,
const upd_t update,
ulint  cmpl_info,
const rec_t *  rec,
roll_ptr_t roll_ptr 
)

Writes information to an undo log about an insert, update, or a delete marking of a clustered index record. This information is used in a rollback of the transaction and in consistent reads that must look to the history of this transaction.

Returns:
DB_SUCCESS or error code out: rollback pointer to the inserted undo log record, 0 if BTR_NO_UNDO_LOG flag was specified

Writes information to an undo log about an insert, update, or a delete marking of a clustered index record. This information is used in a rollback of the transaction and in consistent reads that must look to the history of this transaction.

Returns:
DB_SUCCESS or error code
Parameters:
flagsin: if BTR_NO_UNDO_LOG_FLAG bit is set, does nothing
op_typein: TRX_UNDO_INSERT_OP or TRX_UNDO_MODIFY_OP
thrin: query thread
indexin: clustered index
clust_entryin: in the case of an insert, index entry to insert into the clustered index, otherwise NULL
updatein: in the case of an update, the update vector, otherwise NULL
cmpl_infoin: compiler info on secondary index updates
recin: in case of an update or delete marking, the record in the clustered index, otherwise NULL
roll_ptrout: rollback pointer to the inserted undo log record, 0 if BTR_NO_UNDO_LOG flag was specified

Definition at line 1151 of file trx0rec.cc.

References BUF_GET, dict_index_is_clust(), trx_undo_struct::empty, FIL_NULL, trx_undo_struct::guess_block, trx_rseg_struct::id, trx_struct::insert_undo, trx_undo_struct::last_page_no, mem_heap_free, mtr_commit(), mtr_start(), trx_rseg_struct::mutex, trx_struct::rseg, trx_undo_struct::space, thr_get_trx(), trx_undo_struct::top_offset, trx_undo_struct::top_page_no, trx_undo_struct::top_undo_no, trx_undo_add_page(), trx_undo_assign_undo(), trx_undo_build_roll_ptr(), trx_undo_report_row_operation(), trx_struct::undo_mutex, trx_struct::undo_no, trx_struct::update_undo, ut_a, ut_ad, and trx_undo_struct::zip_size.

Referenced by btr_cur_del_mark_set_clust_rec(), and trx_undo_report_row_operation().

UNIV_INTERN byte* trx_undo_update_rec_get_sys_cols ( byte *  ptr,
trx_id_t trx_id,
roll_ptr_t roll_ptr,
ulint *  info_bits 
)

Reads from an undo log update record the system field values of the old version.

Returns:
remaining part of undo log record after reading these values out: info bits state

Reads from an undo log update record the system field values of the old version.

Returns:
remaining part of undo log record after reading these values
Parameters:
ptrin: remaining part of undo log record after reading general parameters
trx_idout: trx id
roll_ptrout: roll ptr
info_bitsout: info bits state

Definition at line 836 of file trx0rec.cc.

References mach_read_from_1(), mach_ull_get_compressed_size(), mach_ull_read_compressed(), and trx_undo_update_rec_get_sys_cols().

Referenced by trx_undo_prev_version_build(), and trx_undo_update_rec_get_sys_cols().

UNIV_INTERN byte* trx_undo_update_rec_get_update ( byte *  ptr,
dict_index_t index,
ulint  type,
trx_id_t  trx_id,
roll_ptr_t  roll_ptr,
ulint  info_bits,
trx_t trx,
mem_heap_t heap,
upd_t **  upd 
)

Builds an update vector based on a remaining part of an undo log record.

Returns:
remaining part of the record, NULL if an error detected, which means that the record is corrupted out, own: update vector

Builds an update vector based on a remaining part of an undo log record.

Returns:
remaining part of the record, NULL if an error detected, which means that the record is corrupted
Parameters:
ptrin: remaining part in update undo log record, after reading the row reference NOTE that this copy of the undo log record must be preserved as long as the update vector is used, as we do NOT copy the data in the record!
indexin: clustered index
typein: TRX_UNDO_UPD_EXIST_REC, TRX_UNDO_UPD_DEL_REC, or TRX_UNDO_DEL_MARK_REC; in the last case, only trx id and roll ptr fields are added to the update vector
trx_idin: transaction id from this undo record
roll_ptrin: roll pointer from this undo record
info_bitsin: info bits from this undo record
trxin: transaction
heapin: memory heap from which the memory needed is allocated
updout, own: update vector

Definition at line 898 of file trx0rec.cc.

References dfield_set_data(), dfield_set_ext(), dfield_set_null(), dict_index_get_n_fields(), dict_index_get_sys_col_pos(), dict_index_is_clust(), upd_struct::info_bits, mem_heap_alloc(), upd_field_struct::new_val, upd_field_struct::orig_len, dict_index_struct::table_name, trx_undo_update_rec_get_update(), trx_write_roll_ptr(), trx_write_trx_id(), upd_create(), upd_field_set_field_no(), ut_a, and ut_print_name().

Referenced by trx_undo_prev_version_build(), and trx_undo_update_rec_get_update().