InnoDB Plugin
1.0
|
#include "univ.i"
#include "trx0types.h"
#include "mtr0mtr.h"
#include "trx0sys.h"
#include "page0types.h"
#include "trx0xa.h"
#include "trx0undo.ic"
Go to the source code of this file.
Data Structures | |
struct | trx_undo_t |
Macros | |
#define | trx_undo_free_last_page(trx, undo, mtr) trx_undo_free_last_page_func(trx,undo,mtr) |
#define | trx_undo_truncate_end(trx, undo, limit) trx_undo_truncate_end_func(trx,undo,limit) |
#define | TRX_UNDO_INSERT 1 /* contains undo entries for inserts */ |
#define | TRX_UNDO_UPDATE |
#define | TRX_UNDO_ACTIVE |
#define | TRX_UNDO_CACHED 2 /* cached for quick reuse */ |
#define | TRX_UNDO_TO_FREE 3 /* insert undo segment can be freed */ |
#define | TRX_UNDO_TO_PURGE |
#define | TRX_UNDO_PREPARED |
#define | TRX_UNDO_PAGE_HDR FSEG_PAGE_DATA |
#define | TRX_UNDO_PAGE_REUSE_LIMIT (3 * UNIV_PAGE_SIZE / 4) |
#define | TRX_UNDO_SEG_HDR (TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE) |
#define | TRX_UNDO_PAGE_TYPE 0 |
#define | TRX_UNDO_PAGE_START 2 |
#define | TRX_UNDO_PAGE_FREE 4 |
#define | TRX_UNDO_PAGE_NODE 6 |
#define | TRX_UNDO_PAGE_HDR_SIZE (6 + FLST_NODE_SIZE) |
#define | TRX_UNDO_STATE 0 |
#define | TRX_UNDO_LAST_LOG 2 |
#define | TRX_UNDO_FSEG_HEADER 4 |
#define | TRX_UNDO_PAGE_LIST (4 + FSEG_HEADER_SIZE) |
#define | TRX_UNDO_SEG_HDR_SIZE (4 + FSEG_HEADER_SIZE + FLST_BASE_NODE_SIZE) |
#define | TRX_UNDO_TRX_ID 0 |
#define | TRX_UNDO_TRX_NO 8 |
#define | TRX_UNDO_DEL_MARKS 16 |
#define | TRX_UNDO_LOG_START 18 |
#define | TRX_UNDO_XID_EXISTS 20 |
#define | TRX_UNDO_DICT_TRANS 21 |
#define | TRX_UNDO_TABLE_ID 22 |
#define | TRX_UNDO_NEXT_LOG 30 |
#define | TRX_UNDO_PREV_LOG 32 |
#define | TRX_UNDO_HISTORY_NODE 34 |
#define | TRX_UNDO_LOG_OLD_HDR_SIZE (34 + FLST_NODE_SIZE) |
#define | TRX_UNDO_XA_FORMAT (TRX_UNDO_LOG_OLD_HDR_SIZE) |
#define | TRX_UNDO_XA_TRID_LEN (TRX_UNDO_XA_FORMAT + 4) |
#define | TRX_UNDO_XA_BQUAL_LEN (TRX_UNDO_XA_TRID_LEN + 4) |
#define | TRX_UNDO_XA_XID (TRX_UNDO_XA_BQUAL_LEN + 4) |
#define | TRX_UNDO_LOG_XA_HDR_SIZE (TRX_UNDO_XA_XID + XIDDATASIZE) |
Functions | |
UNIV_INLINE roll_ptr_t | trx_undo_build_roll_ptr (ibool is_insert, ulint rseg_id, ulint page_no, ulint offset) |
UNIV_INLINE void | trx_undo_decode_roll_ptr (roll_ptr_t roll_ptr, ibool *is_insert, ulint *rseg_id, ulint *page_no, ulint *offset) |
UNIV_INLINE ibool | trx_undo_roll_ptr_is_insert (roll_ptr_t roll_ptr) |
UNIV_INLINE bool | trx_undo_trx_id_is_insert (const byte *trx_id)) |
UNIV_INLINE void | trx_write_roll_ptr (byte *ptr, roll_ptr_t roll_ptr) |
UNIV_INLINE roll_ptr_t | trx_read_roll_ptr (const byte *ptr) |
UNIV_INLINE page_t * | trx_undo_page_get (ulint space, ulint zip_size, ulint page_no, mtr_t *mtr) |
UNIV_INLINE page_t * | trx_undo_page_get_s_latched (ulint space, ulint zip_size, ulint page_no, mtr_t *mtr) |
UNIV_INLINE trx_undo_rec_t * | trx_undo_page_get_prev_rec (trx_undo_rec_t *rec, ulint page_no, ulint offset) |
UNIV_INLINE trx_undo_rec_t * | trx_undo_page_get_next_rec (trx_undo_rec_t *rec, ulint page_no, ulint offset) |
UNIV_INLINE trx_undo_rec_t * | trx_undo_page_get_last_rec (page_t *undo_page, ulint page_no, ulint offset) |
UNIV_INLINE trx_undo_rec_t * | trx_undo_page_get_first_rec (page_t *undo_page, ulint page_no, ulint offset) |
UNIV_INTERN trx_undo_rec_t * | trx_undo_get_prev_rec (trx_undo_rec_t *rec, ulint page_no, ulint offset, bool shared, mtr_t *mtr) |
UNIV_INTERN trx_undo_rec_t * | trx_undo_get_next_rec (trx_undo_rec_t *rec, ulint page_no, ulint offset, mtr_t *mtr) |
UNIV_INTERN trx_undo_rec_t * | trx_undo_get_first_rec (ulint space, ulint zip_size, ulint page_no, ulint offset, ulint mode, mtr_t *mtr) |
UNIV_INTERN buf_block_t * | trx_undo_add_page (trx_t *trx, trx_undo_t *undo, mtr_t *mtr)) |
UNIV_INTERN void | trx_undo_free_last_page_func (const trx_t *trx, trx_undo_t *undo, mtr_t *mtr)) |
UNIV_INTERN void | trx_undo_truncate_end_func (const trx_t *trx, trx_undo_t *undo, undo_no_t limit)) |
UNIV_INTERN void | trx_undo_truncate_start (trx_rseg_t *rseg, ulint space, ulint hdr_page_no, ulint hdr_offset, undo_no_t limit) |
UNIV_INTERN ulint | trx_undo_lists_init (trx_rseg_t *rseg) |
UNIV_INTERN dberr_t | trx_undo_assign_undo (trx_t *trx, ulint type)) |
UNIV_INTERN page_t * | trx_undo_set_state_at_finish (trx_undo_t *undo, mtr_t *mtr) |
UNIV_INTERN page_t * | trx_undo_set_state_at_prepare (trx_t *trx, trx_undo_t *undo, mtr_t *mtr) |
UNIV_INTERN void | trx_undo_update_cleanup (trx_t *trx, page_t *undo_page, mtr_t *mtr) |
UNIV_INTERN void | trx_undo_insert_cleanup (trx_t *trx) |
UNIV_INTERN void | trx_undo_free_prepared (trx_t *trx) UNIV_COLD) |
UNIV_INTERN byte * | trx_undo_parse_page_init (byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr) |
UNIV_INTERN byte * | trx_undo_parse_page_header (ulint type, byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr) |
UNIV_INTERN byte * | trx_undo_parse_discard_latest (byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr) |
UNIV_INTERN void | trx_undo_mem_free (trx_undo_t *undo) |
Transaction undo log
Created 3/26/1996 Heikki Tuuri
#define TRX_UNDO_ACTIVE |
#define TRX_UNDO_DEL_MARKS 16 |
Defined only in an update undo log: TRUE if the transaction may have done delete markings of records, and thus purge is necessary
#define TRX_UNDO_DICT_TRANS 21 |
TRUE if the transaction is a table create, index create, or drop transaction: in recovery the transaction cannot be rolled back in the usual way: a 'rollback' rather means dropping the created or dropped table, if it still exists
#define TRX_UNDO_FSEG_HEADER 4 |
Header for the file segment which the undo log segment occupies
#define TRX_UNDO_HISTORY_NODE 34 |
If the log is put to the history list, the file list node is here
#define TRX_UNDO_LAST_LOG 2 |
Offset of the last undo log header on the segment header page, 0 if none
#define TRX_UNDO_LOG_OLD_HDR_SIZE (34 + FLST_NODE_SIZE) |
Size of the undo log header without XID information
#define TRX_UNDO_LOG_START 18 |
Offset of the first undo log record of this log on the header page; purge may remove undo log record from the log start, and therefore this is not necessarily the same as this log header end offset
#define TRX_UNDO_LOG_XA_HDR_SIZE (TRX_UNDO_XA_XID + XIDDATASIZE) |
Total size of the undo log header with the XA XID
#define TRX_UNDO_NEXT_LOG 30 |
Offset of the next undo log header on this page, 0 if none
#define TRX_UNDO_PAGE_FREE 4 |
On each page of the undo log this field contains the byte offset of the first free byte on the page
#define TRX_UNDO_PAGE_HDR FSEG_PAGE_DATA |
The offset of the undo log page header on pages of the undo log
#define TRX_UNDO_PAGE_HDR_SIZE (6 + FLST_NODE_SIZE) |
Size of the transaction undo log page header, in bytes
#define TRX_UNDO_PAGE_LIST (4 + FSEG_HEADER_SIZE) |
Base node for the list of pages in the undo log segment; defined only on the undo log segment's first page
#define TRX_UNDO_PAGE_NODE 6 |
The file list node in the chain of undo log pages
#define TRX_UNDO_PAGE_REUSE_LIMIT (3 * UNIV_PAGE_SIZE / 4) |
An update undo segment with just one page can be reused if it has
at most this many bytes used; we must leave space at least for one new undo log header on the page
#define TRX_UNDO_PAGE_START 2 |
Byte offset where the undo log records for the LATEST transaction start on this page (remember that in an update undo log, the first page can contain several undo logs)
#define TRX_UNDO_PAGE_TYPE 0 |
Transaction undo log page header offsets TRX_UNDO_INSERT or TRX_UNDO_UPDATE
#define TRX_UNDO_PREPARED |
#define TRX_UNDO_PREV_LOG 32 |
Offset of the previous undo log header on this page, 0 if none
#define TRX_UNDO_SEG_HDR (TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE) |
The offset of the undo log segment header on the first page of the undo
log segment
#define TRX_UNDO_SEG_HDR_SIZE (4 + FSEG_HEADER_SIZE + FLST_BASE_NODE_SIZE) |
Size of the undo log segment header
#define TRX_UNDO_STATE 0 |
Undo log segment header TRX_UNDO_ACTIVE, ...
#define TRX_UNDO_TABLE_ID 22 |
Id of the table if the preceding field is TRUE
#define TRX_UNDO_TO_PURGE |
#define TRX_UNDO_TRX_ID 0 |
The undo log header. There can be several undo log headers on the first
page of an update undo log segment. Transaction id
#define TRX_UNDO_TRX_NO 8 |
Transaction number of the transaction; defined only if the log is in a history list
#define TRX_UNDO_UPDATE |
#define TRX_UNDO_XA_BQUAL_LEN (TRX_UNDO_XA_TRID_LEN + 4) |
#define TRX_UNDO_XA_FORMAT (TRX_UNDO_LOG_OLD_HDR_SIZE) |
X/Open XA Transaction Identification (XID) xid_t::formatID
#define TRX_UNDO_XA_TRID_LEN (TRX_UNDO_XA_FORMAT + 4) |
#define TRX_UNDO_XA_XID (TRX_UNDO_XA_BQUAL_LEN + 4) |
Distributed transaction identifier data
#define TRX_UNDO_XID_EXISTS 20 |
TRUE if undo log header includes X/Open XA transaction identification XID
UNIV_INLINE roll_ptr_t trx_read_roll_ptr | ( | const byte * | ptr | ) |
Reads a roll ptr from an index page. In case that the roll ptr size changes in some future version, this function should be used instead of mach_read_...
Reads a roll ptr from an index page. In case that the roll ptr size changes in some future version, this function should be used instead of mach_read_...
ptr | in: pointer to memory from where to read |
UNIV_INTERN buf_block_t* trx_undo_add_page | ( | trx_t * | trx, |
trx_undo_t * | undo, | ||
mtr_t * | mtr | ||
) |
Tries to add a page to the undo log segment where the undo log is placed.
trx | in: transaction |
undo | in: undo log memory object |
mtr | in: mtr which does not have a latch to any undo log page; the caller must have reserved the rollback segment mutex |
Assigns an undo log for a transaction. A new undo log is created or a cached undo log reused.
trx | in: transaction |
type | in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE |
UNIV_INLINE roll_ptr_t trx_undo_build_roll_ptr | ( | ibool | is_insert, |
ulint | rseg_id, | ||
ulint | page_no, | ||
ulint | offset | ||
) |
Builds a roll pointer.
Builds a roll pointer.
is_insert | in: TRUE if insert undo log |
rseg_id | in: rollback segment id |
page_no | in: page number |
offset | in: offset of the undo entry within page |
UNIV_INLINE void trx_undo_decode_roll_ptr | ( | roll_ptr_t | roll_ptr, |
ibool * | is_insert, | ||
ulint * | rseg_id, | ||
ulint * | page_no, | ||
ulint * | offset | ||
) |
Decodes a roll pointer. out: offset of the undo entry within page
Decodes a roll pointer.
roll_ptr | in: roll pointer |
is_insert | out: TRUE if insert undo log |
rseg_id | out: rollback segment id |
page_no | out: page number |
offset | out: offset of the undo entry within page |
UNIV_INTERN void trx_undo_free_last_page_func | ( | const trx_t * | trx, |
trx_undo_t * | undo, | ||
mtr_t * | mtr | ||
) |
Frees the last undo log page. The caller must hold the rollback segment mutex.
trx | in: transaction |
undo | in/out: undo log memory copy |
mtr | in/out: mini-transaction which does not have a latch to any undo log page or which has allocated the undo log page |
UNIV_INTERN void trx_undo_free_prepared | ( | trx_t * | trx | ) |
At shutdown, frees the undo logs of a PREPARED transaction.
trx | in/out: PREPARED transaction |
UNIV_INTERN trx_undo_rec_t* trx_undo_get_first_rec | ( | ulint | space, |
ulint | zip_size, | ||
ulint | page_no, | ||
ulint | offset, | ||
ulint | mode, | ||
mtr_t * | mtr | ||
) |
Gets the first record in an undo log.
space | in: undo log header space |
zip_size | in: compressed page size in bytes or 0 for uncompressed pages |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
mode | in: latching mode: RW_S_LATCH or RW_X_LATCH |
UNIV_INTERN trx_undo_rec_t* trx_undo_get_next_rec | ( | trx_undo_rec_t * | rec, |
ulint | page_no, | ||
ulint | offset, | ||
mtr_t * | mtr | ||
) |
Gets the next record in an undo log.
rec | in: undo record |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
UNIV_INTERN trx_undo_rec_t* trx_undo_get_prev_rec | ( | trx_undo_rec_t * | rec, |
ulint | page_no, | ||
ulint | offset, | ||
bool | shared, | ||
mtr_t * | mtr | ||
) |
Gets the previous record in an undo log.
rec | in: undo record |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
shared | in: true=S-latch, false=X-latch |
UNIV_INTERN void trx_undo_insert_cleanup | ( | trx_t * | trx | ) |
Frees or caches an insert undo log after a transaction commit or rollback. Knowledge of inserts is not needed after a commit or rollback, therefore the data can be discarded. in: transaction handle
UNIV_INTERN ulint trx_undo_lists_init | ( | trx_rseg_t * | rseg | ) |
Initializes the undo log lists for a rollback segment memory copy. This function is only called when the database is started or a new rollback segment created.
Gets an undo log page and x-latches it.
Gets an undo log page and x-latches it.
space | in: space where placed |
zip_size | in: compressed page size in bytes or 0 for uncompressed pages |
page_no | in: page number |
mtr | in: mtr |
UNIV_INLINE trx_undo_rec_t* trx_undo_page_get_first_rec | ( | page_t * | undo_page, |
ulint | page_no, | ||
ulint | offset | ||
) |
Returns the first undo record on the page in the specified undo log, or NULL if none exists.
Returns the first undo record on the page in the specified undo log, or NULL if none exists.
undo_page | in: undo log page |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
UNIV_INLINE trx_undo_rec_t* trx_undo_page_get_last_rec | ( | page_t * | undo_page, |
ulint | page_no, | ||
ulint | offset | ||
) |
Returns the last undo record on the page in the specified undo log, or NULL if none exists.
Returns the last undo record on the page in the specified undo log, or NULL if none exists.
undo_page | in: undo log page |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
UNIV_INLINE trx_undo_rec_t* trx_undo_page_get_next_rec | ( | trx_undo_rec_t * | rec, |
ulint | page_no, | ||
ulint | offset | ||
) |
Returns the next undo log record on the page in the specified log, or NULL if none exists.
Returns the next undo log record on the page in the specified log, or NULL if none exists.
rec | in: undo log record |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
UNIV_INLINE trx_undo_rec_t* trx_undo_page_get_prev_rec | ( | trx_undo_rec_t * | rec, |
ulint | page_no, | ||
ulint | offset | ||
) |
Returns the previous undo record on the page in the specified log, or NULL if none exists.
Returns the previous undo record on the page in the specified log, or NULL if none exists.
rec | in: undo log record |
page_no | in: undo log header page number |
offset | in: undo log header offset on page |
UNIV_INLINE page_t* trx_undo_page_get_s_latched | ( | ulint | space, |
ulint | zip_size, | ||
ulint | page_no, | ||
mtr_t * | mtr | ||
) |
Gets an undo log page and s-latches it.
Gets an undo log page and s-latches it.
space | in: space where placed |
zip_size | in: compressed page size in bytes or 0 for uncompressed pages |
page_no | in: page number |
mtr | in: mtr |
UNIV_INTERN byte* trx_undo_parse_discard_latest | ( | byte * | ptr, |
byte * | end_ptr, | ||
page_t * | page, | ||
mtr_t * | mtr | ||
) |
Parses the redo log entry of an undo log page header discard.
ptr | in: buffer |
end_ptr | in: buffer end |
page | in: page or NULL |
UNIV_INTERN byte* trx_undo_parse_page_header | ( | ulint | type, |
byte * | ptr, | ||
byte * | end_ptr, | ||
page_t * | page, | ||
mtr_t * | mtr | ||
) |
Parses the redo log entry of an undo log page header create or reuse.
type | in: MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE |
ptr | in: buffer |
end_ptr | in: buffer end |
page | in: page or NULL |
UNIV_INTERN byte* trx_undo_parse_page_init | ( | byte * | ptr, |
byte * | end_ptr, | ||
page_t * | page, | ||
mtr_t * | mtr | ||
) |
Parses the redo log entry of an undo log page initialization.
ptr | in: buffer |
end_ptr | in: buffer end |
page | in: page or NULL |
UNIV_INLINE ibool trx_undo_roll_ptr_is_insert | ( | roll_ptr_t | roll_ptr | ) |
Returns TRUE if the roll pointer is of the insert type.
Returns TRUE if the roll pointer is of the insert type.
roll_ptr | in: roll pointer |
UNIV_INTERN page_t* trx_undo_set_state_at_finish | ( | trx_undo_t * | undo, |
mtr_t * | mtr | ||
) |
Sets the state of the undo log segment at a transaction finish.
undo | in: undo log memory copy |
UNIV_INTERN page_t* trx_undo_set_state_at_prepare | ( | trx_t * | trx, |
trx_undo_t * | undo, | ||
mtr_t * | mtr | ||
) |
Sets the state of the undo log segment at a transaction prepare.
trx | in: transaction |
undo | in: undo log memory copy |
UNIV_INTERN void trx_undo_truncate_end_func | ( | const trx_t * | trx, |
trx_undo_t * | undo, | ||
undo_no_t | limit | ||
) |
Truncates an undo log from the end. This function is used during a rollback to free space from an undo log.
trx | in: transaction whose undo log it is |
undo | in/out: undo log |
limit | in: all undo records with undo number >= this value should be truncated |
UNIV_INTERN void trx_undo_truncate_start | ( | trx_rseg_t * | rseg, |
ulint | space, | ||
ulint | hdr_page_no, | ||
ulint | hdr_offset, | ||
undo_no_t | limit | ||
) |
Truncates an undo log from the start. This function is used during a purge operation. in: all undo pages with undo numbers < this value should be truncated; NOTE that the function only frees whole pages; the header page is not freed, but emptied, if all the records there are < limit
rseg | in: rollback segment |
space | in: space id of the log |
hdr_page_no | in: header page number |
hdr_offset | in: header offset on the page |
UNIV_INLINE bool trx_undo_trx_id_is_insert | ( | const byte * | trx_id | ) |
Returns true if the record is of the insert type.
trx_id | in: DB_TRX_ID, followed by DB_ROLL_PTR |
Adds the update undo log header as the first in the history list, and frees the memory object, or puts it to the list of cached update undo log segments. in: mtr
trx | in: trx owning the update undo log |
undo_page | in: update undo log header page, x-latched |
UNIV_INLINE void trx_write_roll_ptr | ( | byte * | ptr, |
roll_ptr_t | roll_ptr | ||
) |
Writes a roll ptr to an index page. In case that the size changes in some future version, this function should be used instead of mach_write_... in: roll ptr
Writes a roll ptr to an index page. In case that the size changes in some future version, this function should be used instead of mach_write_...
ptr | in: pointer to memory where written |
roll_ptr | in: roll ptr |