void rec_set_nth_field_extern_bit( /*=========================*/ rec_t* rec, /* in: record */ ulint i, /* in: ith field */ ibool val, /* in: value to set */ mtr_t* mtr) /* in: mtr holding an X-latch to the page where rec is, or NULL; in the NULL case we do not write to log about the change */ { ulint info; ut_a(!rec_get_1byte_offs_flag(rec)); ut_a(i < rec_get_n_fields(rec)); info = rec_2_get_field_end_info(rec, i); if (val) { info = info | REC_2BYTE_EXTERN_MASK; } else { info = info & ~REC_2BYTE_EXTERN_MASK; } if (mtr) { mlog_write_ulint(rec - REC_N_EXTRA_BYTES - 2 * (i + 1), info, MLOG_2BYTES, mtr); } else { rec_2_set_field_end_info(rec, i, info); } }
void rec_set_nth_field_null_bit( /*=======================*/ rec_t* rec, /* in: record */ ulint i, /* in: ith field */ ibool val) /* in: value to set */ { ulint info; if (rec_get_1byte_offs_flag(rec)) { info = rec_1_get_field_end_info(rec, i); if (val) { info = info | REC_1BYTE_SQL_NULL_MASK; } else { info = info & ~REC_1BYTE_SQL_NULL_MASK; } rec_1_set_field_end_info(rec, i, info); return; } info = rec_2_get_field_end_info(rec, i); if (val) { info = info | REC_2BYTE_SQL_NULL_MASK; } else { info = info & ~REC_2BYTE_SQL_NULL_MASK; } rec_2_set_field_end_info(rec, i, info); }
static inline ibool ibrec_init_offsets_old(page_t *page, rec_t* rec, table_def_t* table, ulint* offsets) { ulint i = 0; ulint offs; // First field is 0 bytes from origin point rec_offs_base(offsets)[0] = 0; // Init first bytes rec_offs_set_n_fields(offsets, table->fields_count); /* Old-style record: determine extra size and end offsets */ offs = REC_N_OLD_EXTRA_BYTES; if (rec_get_1byte_offs_flag(rec)) { offs += rec_offs_n_fields(offsets); *rec_offs_base(offsets) = offs; /* Determine offsets to fields */ do { offs = rec_1_get_field_end_info(rec, i); if (offs & REC_1BYTE_SQL_NULL_MASK) { offs &= ~REC_1BYTE_SQL_NULL_MASK; offs |= REC_OFFS_SQL_NULL; } offs &= 0xffff; if (rec + offs - page > UNIV_PAGE_SIZE) { if (debug) printf("Invalid offset for field %lu: %lu\n", i, offs); return FALSE; } rec_offs_base(offsets)[1 + i] = offs; } while (++i < rec_offs_n_fields(offsets)); } else { offs += 2 * rec_offs_n_fields(offsets); *rec_offs_base(offsets) = offs; /* Determine offsets to fields */ do { offs = rec_2_get_field_end_info(rec, i); if (offs & REC_2BYTE_SQL_NULL_MASK) { offs &= ~REC_2BYTE_SQL_NULL_MASK; offs |= REC_OFFS_SQL_NULL; } if (offs & REC_2BYTE_EXTERN_MASK) { offs &= ~REC_2BYTE_EXTERN_MASK; offs |= REC_OFFS_EXTERNAL; } offs &= 0xffff; if (rec + offs - page > UNIV_PAGE_SIZE) { if (debug) printf("Invalid offset for field %lu: %lu\n", i, offs); return FALSE; } rec_offs_base(offsets)[1 + i] = offs; } while (++i < rec_offs_n_fields(offsets)); } return TRUE; }
byte* rec_get_nth_field( /*==============*/ /* out: pointer to the field */ rec_t* rec, /* in: record */ ulint n, /* in: index of the field */ ulint* len) /* out: length of the field; UNIV_SQL_NULL if SQL null */ { ulint os; ulint next_os; ut_ad(rec && len); ut_ad(n < rec_get_n_fields(rec)); if (n > 1024) { fprintf(stderr, "Error: trying to access field %lu in rec\n", n); ut_a(0); } if (rec == NULL) { fprintf(stderr, "Error: rec is NULL pointer\n"); ut_a(0); } if (rec_get_1byte_offs_flag(rec)) { os = rec_1_get_field_start_offs(rec, n); next_os = rec_1_get_field_end_info(rec, n); if (next_os & REC_1BYTE_SQL_NULL_MASK) { *len = UNIV_SQL_NULL; return(rec + os); } next_os = next_os & ~REC_1BYTE_SQL_NULL_MASK; } else { os = rec_2_get_field_start_offs(rec, n); next_os = rec_2_get_field_end_info(rec, n); if (next_os & REC_2BYTE_SQL_NULL_MASK) { *len = UNIV_SQL_NULL; return(rec + os); } next_os = next_os & ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK); } *len = next_os - os; ut_ad(*len < UNIV_PAGE_SIZE); return(rec + os); }