Commit dc2e9160 authored by marko's avatar marko

branches/zip: Minor cleanup in rollback.

trx_undo_left(): Add const qualifiers.

trx_undo_page_report_insert(): Use exact trx_undo_left() limit.
Remove a duplicated trx_undo_left() check.

trx_undo_page_report_modify(): Eliminate the local variable len.
Document that no prefix for BLOBs needs to be stored in the undo log.
Lump two trx_undo_left() checks together.
parent a369b009
...@@ -120,9 +120,9 @@ UNIV_INLINE ...@@ -120,9 +120,9 @@ UNIV_INLINE
ulint ulint
trx_undo_left( trx_undo_left(
/*==========*/ /*==========*/
/* out: bytes left */ /* out: bytes left */
page_t* page, /* in: undo log page */ const page_t* page, /* in: undo log page */
byte* ptr) /* in: pointer to page */ const byte* ptr) /* in: pointer to page */
{ {
/* The '- 10' is a safety margin, in case we have some small /* The '- 10' is a safety margin, in case we have some small
calculation error below */ calculation error below */
...@@ -161,10 +161,9 @@ trx_undo_page_report_insert( ...@@ -161,10 +161,9 @@ trx_undo_page_report_insert(
ut_ad(first_free <= UNIV_PAGE_SIZE); ut_ad(first_free <= UNIV_PAGE_SIZE);
if (trx_undo_left(undo_page, ptr) < 30) { if (trx_undo_left(undo_page, ptr) < 2 + 1 + 11 + 11) {
/* NOTE: the value 30 must be big enough such that the general /* Not enough space for writing the general parameters */
fields written below fit on the undo log page */
return(0); return(0);
} }
...@@ -210,11 +209,6 @@ trx_undo_page_report_insert( ...@@ -210,11 +209,6 @@ trx_undo_page_report_insert(
} }
} }
if (trx_undo_left(undo_page, ptr) < 2) {
return(0);
}
/*----------------------------------------*/ /*----------------------------------------*/
/* Write pointers to the previous and the next undo log records */ /* Write pointers to the previous and the next undo log records */
...@@ -415,7 +409,6 @@ trx_undo_page_report_modify( ...@@ -415,7 +409,6 @@ trx_undo_page_report_modify(
dict_table_t* table; dict_table_t* table;
ulint first_free; ulint first_free;
byte* ptr; byte* ptr;
ulint len;
const byte* field; const byte* field;
ulint flen; ulint flen;
ulint col_no; ulint col_no;
...@@ -457,17 +450,12 @@ trx_undo_page_report_modify( ...@@ -457,17 +450,12 @@ trx_undo_page_report_modify(
} }
type_cmpl |= cmpl_info * TRX_UNDO_CMPL_INFO_MULT; type_cmpl |= cmpl_info * TRX_UNDO_CMPL_INFO_MULT;
mach_write_to_1(ptr, type_cmpl);
type_cmpl_ptr = ptr; type_cmpl_ptr = ptr;
ptr++; *ptr++ = type_cmpl;
len = mach_dulint_write_much_compressed(ptr, trx->undo_no); ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
ptr += len;
len = mach_dulint_write_much_compressed(ptr, table->id); ptr += mach_dulint_write_much_compressed(ptr, table->id);
ptr += len;
/*----------------------------------------*/ /*----------------------------------------*/
/* Store the state of the info bits */ /* Store the state of the info bits */
...@@ -477,19 +465,17 @@ trx_undo_page_report_modify( ...@@ -477,19 +465,17 @@ trx_undo_page_report_modify(
/* Store the values of the system columns */ /* Store the values of the system columns */
field = rec_get_nth_field(rec, offsets, field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos( dict_index_get_sys_col_pos(
index, DATA_TRX_ID), &len); index, DATA_TRX_ID), &flen);
ut_ad(len == DATA_TRX_ID_LEN); ut_ad(flen == DATA_TRX_ID_LEN);
len = mach_dulint_write_compressed(ptr, trx_read_trx_id(field)); ptr += mach_dulint_write_compressed(ptr, trx_read_trx_id(field));
ptr += len;
field = rec_get_nth_field(rec, offsets, field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos( dict_index_get_sys_col_pos(
index, DATA_ROLL_PTR), &len); index, DATA_ROLL_PTR), &flen);
ut_ad(len == DATA_ROLL_PTR_LEN); ut_ad(flen == DATA_ROLL_PTR_LEN);
len = mach_dulint_write_compressed(ptr, trx_read_roll_ptr(field)); ptr += mach_dulint_write_compressed(ptr, trx_read_roll_ptr(field));
ptr += len;
/*----------------------------------------*/ /*----------------------------------------*/
/* Store then the fields required to uniquely determine the /* Store then the fields required to uniquely determine the
...@@ -504,8 +490,7 @@ trx_undo_page_report_modify( ...@@ -504,8 +490,7 @@ trx_undo_page_report_modify(
return(0); return(0);
} }
len = mach_write_compressed(ptr, flen); ptr += mach_write_compressed(ptr, flen);
ptr += len;
if (flen != UNIV_SQL_NULL) { if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr) < flen) { if (trx_undo_left(undo_page, ptr) < flen) {
...@@ -527,8 +512,7 @@ trx_undo_page_report_modify( ...@@ -527,8 +512,7 @@ trx_undo_page_report_modify(
return(0); return(0);
} }
len = mach_write_compressed(ptr, upd_get_n_fields(update)); ptr += mach_write_compressed(ptr, upd_get_n_fields(update));
ptr += len;
for (i = 0; i < upd_get_n_fields(update); i++) { for (i = 0; i < upd_get_n_fields(update); i++) {
...@@ -540,8 +524,7 @@ trx_undo_page_report_modify( ...@@ -540,8 +524,7 @@ trx_undo_page_report_modify(
return(0); return(0);
} }
len = mach_write_compressed(ptr, pos); ptr += mach_write_compressed(ptr, pos);
ptr += len;
/* Save the old value of field */ /* Save the old value of field */
field = rec_get_nth_field(rec, offsets, pos, &flen); field = rec_get_nth_field(rec, offsets, pos, &flen);
...@@ -555,7 +538,7 @@ trx_undo_page_report_modify( ...@@ -555,7 +538,7 @@ trx_undo_page_report_modify(
/* If a field has external storage, we add /* If a field has external storage, we add
to flen the flag */ to flen the flag */
len = mach_write_compressed( ptr += mach_write_compressed(
ptr, ptr,
UNIV_EXTERN_STORAGE_FIELD + flen); UNIV_EXTERN_STORAGE_FIELD + flen);
...@@ -566,11 +549,9 @@ trx_undo_page_report_modify( ...@@ -566,11 +549,9 @@ trx_undo_page_report_modify(
*type_cmpl_ptr |= TRX_UNDO_UPD_EXTERN; *type_cmpl_ptr |= TRX_UNDO_UPD_EXTERN;
} else { } else {
len = mach_write_compressed(ptr, flen); ptr += mach_write_compressed(ptr, flen);
} }
ptr += len;
if (flen != UNIV_SQL_NULL) { if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr) < flen) { if (trx_undo_left(undo_page, ptr) < flen) {
...@@ -590,10 +571,12 @@ trx_undo_page_report_modify( ...@@ -590,10 +571,12 @@ trx_undo_page_report_modify(
in the purge of old versions where we use it to build and search the in the purge of old versions where we use it to build and search the
delete marked index records, to look if we can remove them from the delete marked index records, to look if we can remove them from the
index tree. Note that starting from 4.0.14 also externally stored index tree. Note that starting from 4.0.14 also externally stored
fields can be ordering in some index. But we always store at least fields can be ordering in some index. Starting from 5.2, we no longer
384 first bytes locally to the clustered index record, which means store REC_MAX_INDEX_COL_LEN first bytes to the undo log record,
we can construct the column prefix fields in the index from the but we can construct the column prefix fields in the index by
stored data. */ fetching the first page of the BLOB that is pointed to by the
clustered index. This works also in crash recovery, because all pages
(including BLOBs) are recovered before anything is rolled back. */
if (!update || !(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { if (!update || !(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
byte* old_ptr = ptr; byte* old_ptr = ptr;
...@@ -616,31 +599,24 @@ trx_undo_page_report_modify( ...@@ -616,31 +599,24 @@ trx_undo_page_report_modify(
const dict_col_t* col const dict_col_t* col
= dict_table_get_nth_col(table, col_no); = dict_table_get_nth_col(table, col_no);
if (col->ord_part > 0) { if (col->ord_part) {
ulint pos;
ulint pos = dict_index_get_nth_col_pos(
index, col_no);
/* Write field number to undo log */ /* Write field number to undo log */
if (trx_undo_left(undo_page, ptr) < 5) { if (trx_undo_left(undo_page, ptr) < 5 + 5) {
return(0); return(0);
} }
len = mach_write_compressed(ptr, pos); pos = dict_index_get_nth_col_pos(index,
ptr += len; col_no);
ptr += mach_write_compressed(ptr, pos);
/* Save the old value of field */ /* Save the old value of field */
field = rec_get_nth_field(rec, offsets, pos, field = rec_get_nth_field(rec, offsets, pos,
&flen); &flen);
if (trx_undo_left(undo_page, ptr) < 5) { ptr += mach_write_compressed(ptr, flen);
return(0);
}
len = mach_write_compressed(ptr, flen);
ptr += len;
if (flen != UNIV_SQL_NULL) { if (flen != UNIV_SQL_NULL) {
if (trx_undo_left(undo_page, ptr) if (trx_undo_left(undo_page, ptr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment