summaryrefslogtreecommitdiff
path: root/storage/innobase/trx/trx0rec.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-11-10 12:34:23 +0100
committerSergei Golubchik <serg@mariadb.org>2020-11-10 14:09:05 +0100
commit7da6353b1558adce73320c803f0413c9bbd81185 (patch)
tree051de35a83e26d034293928ccfbb3e90274ce646 /storage/innobase/trx/trx0rec.cc
parent90f43d260e407c650aa8a7885d674c717618cc37 (diff)
parent5fbfdae130950d0a5a07d4b909f3bf1ff0498d34 (diff)
downloadmariadb-git-7da6353b1558adce73320c803f0413c9bbd81185.tar.gz
Merge branch '10.4' into 10.5mariadb-10.5.8
Diffstat (limited to 'storage/innobase/trx/trx0rec.cc')
-rw-r--r--storage/innobase/trx/trx0rec.cc41
1 files changed, 20 insertions, 21 deletions
diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc
index 52130b50eb1..1b1cabb6963 100644
--- a/storage/innobase/trx/trx0rec.cc
+++ b/storage/innobase/trx/trx0rec.cc
@@ -53,15 +53,18 @@ const dtuple_t trx_undo_metadata = {
/*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/
/** Calculate the free space left for extending an undo log record.
-@param[in] undo_block undo log page
-@param[in] ptr current end of the undo page
+@param undo_block undo log page
+@param ptr current end of the undo page
@return bytes left */
-static ulint trx_undo_left(const buf_block_t* undo_block, const byte* ptr)
+static ulint trx_undo_left(const buf_block_t *undo_block, const byte *ptr)
{
- /* The 10 is a safety margin, in case we have some small
- calculation error below */
- return srv_page_size - ulint(ptr - undo_block->frame)
- - (10 + FIL_PAGE_DATA_END);
+ ut_ad(ptr >= &undo_block->frame[TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE]);
+ ut_ad(ptr <= &undo_block->frame[srv_page_size - 10 - FIL_PAGE_DATA_END]);
+
+ /* The 10 is supposed to be an extra safety margin (and needed for
+ compatibility with older versions) */
+ return srv_page_size - ulint(ptr - undo_block->frame) -
+ (10 + FIL_PAGE_DATA_END);
}
/**********************************************************************//**
@@ -133,17 +136,15 @@ trx_undo_log_v_idx(
ut_ad(!vcol->v_indexes.empty());
- /* Size to reserve, max 5 bytes for each index id and position, plus
- 5 bytes for num of indexes, 2 bytes for write total length.
- 1 byte for undo log record format version marker */
- ulint size = 5 + 2 + (first_v_col ? 1 : 0);
+ ulint size = first_v_col ? 1 + 2 : 2;
const ulint avail = trx_undo_left(undo_block, ptr);
- if (avail < size) {
+ /* The mach_write_compressed(ptr, flen) in
+ trx_undo_page_report_modify() will consume additional 1 to 5 bytes. */
+ if (avail < size + 5) {
return(NULL);
}
- size = 0;
ulint n_idx = 0;
for (const auto& v_index : vcol->v_indexes) {
n_idx++;
@@ -151,12 +152,14 @@ trx_undo_log_v_idx(
size += mach_get_compressed_size(uint32_t(v_index.index->id));
size += mach_get_compressed_size(v_index.nth_field);
}
- size += 2 + mach_get_compressed_size(n_idx);
- if (avail < size) {
+ size += mach_get_compressed_size(n_idx);
+
+ if (avail < size + 5) {
return(NULL);
}
+ ut_d(const byte* orig_ptr = ptr);
if (first_v_col) {
/* write the version marker */
@@ -179,6 +182,8 @@ trx_undo_log_v_idx(
ptr += mach_write_compressed(ptr, v_index.nth_field);
}
+ ut_ad(orig_ptr + size == ptr);
+
mach_write_to_2(old_ptr, ulint(ptr - old_ptr));
return(ptr);
@@ -394,9 +399,6 @@ trx_undo_page_report_insert(
+ undo_block->frame));
byte* ptr = undo_block->frame + first_free;
- ut_ad(first_free >= TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE);
- ut_ad(first_free <= srv_page_size - FIL_PAGE_DATA_END);
-
if (trx_undo_left(undo_block, ptr) < 2 + 1 + 11 + 11) {
/* Not enough space for writing the general parameters */
return(0);
@@ -803,9 +805,6 @@ trx_undo_page_report_modify(
const uint16_t first_free = mach_read_from_2(ptr_to_first_free);
byte *ptr = undo_block->frame + first_free;
- ut_ad(first_free >= TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE);
- ut_ad(first_free <= srv_page_size - FIL_PAGE_DATA_END);
-
if (trx_undo_left(undo_block, ptr) < 50) {
/* NOTE: the value 50 must be big enough so that the general
fields written below fit on the undo log page */