void row_upd_index_entry_sys_field( /*==========================*/ dtuple_t* entry, /* in: index entry, where the memory buffers for sys fields are already allocated: the function just copies the new values to them */ dict_index_t* index, /* in: clustered index */ ulint type, /* in: DATA_TRX_ID or DATA_ROLL_PTR */ dulint val) /* in: value to write */ { dfield_t* dfield; byte* field; ulint pos; ut_ad(index->type & DICT_CLUSTERED); pos = dict_index_get_sys_col_pos(index, type); dfield = dtuple_get_nth_field(entry, pos); field = dfield_get_data(dfield); if (type == DATA_TRX_ID) { trx_write_trx_id(field, val); } else { ut_ad(type == DATA_ROLL_PTR); trx_write_roll_ptr(field, val); } }
void row_set_rec_sys_field( /*==================*/ /* out: value of the field */ ulint type, /* in: DATA_TRX_ID or DATA_ROLL_PTR */ rec_t* rec, /* in: record */ dict_index_t* index, /* in: clustered index */ dulint val) /* in: value to set */ { ulint pos; byte* field; ulint len; ut_ad(index->type & DICT_CLUSTERED); pos = dict_index_get_sys_col_pos(index, type); field = rec_get_nth_field(rec, pos, &len); if (type == DATA_TRX_ID) { trx_write_trx_id(field, val); } else { ut_ad(type == DATA_ROLL_PTR); trx_write_roll_ptr(field, val); } }
void row_upd_rec_sys_fields_in_recovery( /*===============================*/ rec_t* rec, /* in: record */ ulint pos, /* in: TRX_ID position in rec */ dulint trx_id, /* in: transaction id */ dulint roll_ptr)/* in: roll ptr of the undo log record */ { byte* field; ulint len; field = rec_get_nth_field(rec, pos, &len); ut_ad(len == DATA_TRX_ID_LEN); trx_write_trx_id(field, trx_id); field = rec_get_nth_field(rec, pos + 1, &len); ut_ad(len == DATA_ROLL_PTR_LEN); trx_write_roll_ptr(field, roll_ptr); }
byte* row_upd_write_sys_vals_to_log( /*==========================*/ /* out: new pointer to mlog */ dict_index_t* index, /* in: clustered index */ trx_t* trx, /* in: transaction */ dulint roll_ptr,/* in: roll ptr of the undo log record */ byte* log_ptr,/* pointer to a buffer of size > 20 opened in mlog */ mtr_t* mtr) /* in: mtr */ { ut_ad(index->type & DICT_CLUSTERED); ut_ad(mtr); log_ptr += mach_write_compressed(log_ptr, dict_index_get_sys_col_pos(index, DATA_TRX_ID)); trx_write_roll_ptr(log_ptr, roll_ptr); log_ptr += DATA_ROLL_PTR_LEN; log_ptr += mach_dulint_write_compressed(log_ptr, trx->id); return(log_ptr); }
/*******************************************************************//** Builds an update vector based on a remaining part of an undo log record. @return remaining part of the record, NULL if an error detected, which means that the record is corrupted */ UNIV_INTERN byte* trx_undo_update_rec_get_update( /*===========================*/ byte* ptr, /*!< in: 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! */ dict_index_t* index, /*!< in: clustered index */ ulint type, /*!< in: 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_id_t trx_id, /*!< in: transaction id from this undo record */ roll_ptr_t roll_ptr,/*!< in: roll pointer from this undo record */ ulint info_bits,/*!< in: info bits from this undo record */ trx_t* trx, /*!< in: transaction */ mem_heap_t* heap, /*!< in: memory heap from which the memory needed is allocated */ upd_t** upd) /*!< out, own: update vector */ { upd_field_t* upd_field; upd_t* update; ulint n_fields; byte* buf; ulint i; ut_a(dict_index_is_clust(index)); if (type != TRX_UNDO_DEL_MARK_REC) { ptr = trx_undo_update_rec_get_n_upd_fields(ptr, &n_fields); } else { n_fields = 0; } update = upd_create(n_fields + 2, heap); update->info_bits = info_bits; /* Store first trx id and roll ptr to update vector */ upd_field = upd_get_nth_field(update, n_fields); buf = mem_heap_alloc(heap, DATA_TRX_ID_LEN); trx_write_trx_id(buf, trx_id); upd_field_set_field_no(upd_field, dict_index_get_sys_col_pos(index, DATA_TRX_ID), index, trx); dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN); upd_field = upd_get_nth_field(update, n_fields + 1); buf = mem_heap_alloc(heap, DATA_ROLL_PTR_LEN); trx_write_roll_ptr(buf, roll_ptr); upd_field_set_field_no( upd_field, dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), index, trx); dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN); /* Store then the updated ordinary columns to the update vector */ for (i = 0; i < n_fields; i++) { byte* field; ulint len; ulint field_no; ulint orig_len; ptr = trx_undo_update_rec_get_field_no(ptr, &field_no); if (field_no >= dict_index_get_n_fields(index)) { fprintf(stderr, "InnoDB: Error: trying to access" " update undo rec field %lu in ", (ulong) field_no); dict_index_name_print(stderr, trx, index); fprintf(stderr, "\n" "InnoDB: but index has only %lu fields\n" "InnoDB: Submit a detailed bug report" " to http://bugs.mysql.com\n" "InnoDB: Run also CHECK TABLE ", (ulong) dict_index_get_n_fields(index)); ut_print_name(stderr, trx, TRUE, index->table_name); fprintf(stderr, "\n" "InnoDB: n_fields = %lu, i = %lu, ptr %p\n", (ulong) n_fields, (ulong) i, ptr); *upd = NULL; return(NULL); } upd_field = upd_get_nth_field(update, i); upd_field_set_field_no(upd_field, field_no, index, trx); ptr = trx_undo_rec_get_col_val(ptr, &field, &len, &orig_len); upd_field->orig_len = orig_len; if (len == UNIV_SQL_NULL) { dfield_set_null(&upd_field->new_val); } else if (len < UNIV_EXTERN_STORAGE_FIELD) { dfield_set_data(&upd_field->new_val, field, len); } else { len -= UNIV_EXTERN_STORAGE_FIELD; dfield_set_data(&upd_field->new_val, field, len); dfield_set_ext(&upd_field->new_val); } } *upd = update; return(ptr); }