Commit 5fa82b6a authored by Marko Mäkelä's avatar Marko Mäkelä

Simplify rec_get_n_add_field() (non-functional change)

parent 273557c1
...@@ -245,23 +245,18 @@ static inline unsigned rec_get_n_add_field_len(unsigned n_add_field) ...@@ -245,23 +245,18 @@ static inline unsigned rec_get_n_add_field_len(unsigned n_add_field)
} }
/** Get the added field count in a REC_STATUS_COLUMNS_ADDED record. /** Get the added field count in a REC_STATUS_COLUMNS_ADDED record.
@param[in] rec REC_STATUS_COLUMNS_ADDED record @param[in,out] header variable header of a REC_STATUS_COLUMNS_ADDED record
@param[out] len storage size of the field count, in bytes
@return number of added fields */ @return number of added fields */
static inline unsigned rec_get_n_add_field(const rec_t* rec, ulint* len) static inline unsigned rec_get_n_add_field(const byte*& header)
{ {
ut_ad(rec_get_status(rec) == REC_STATUS_COLUMNS_ADDED); unsigned n_fields_add = *--header;
rec -= REC_N_NEW_EXTRA_BYTES + 1;
unsigned n_fields_add = *rec;
if (n_fields_add < 0x80) { if (n_fields_add < 0x80) {
*len = 1;
ut_ad(rec_get_n_add_field_len(n_fields_add) == 1); ut_ad(rec_get_n_add_field_len(n_fields_add) == 1);
return n_fields_add; return n_fields_add;
} }
*len = 2;
n_fields_add &= 0x7f; n_fields_add &= 0x7f;
n_fields_add |= unsigned(rec[-1]) << 7; n_fields_add |= unsigned(*--header) << 7;
ut_ad(n_fields_add < REC_MAX_N_FIELDS); ut_ad(n_fields_add < REC_MAX_N_FIELDS);
ut_ad(rec_get_n_add_field_len(n_fields_add) == 2); ut_ad(rec_get_n_add_field_len(n_fields_add) == 2);
return n_fields_add; return n_fields_add;
...@@ -349,18 +344,17 @@ rec_init_offsets_comp_ordinary( ...@@ -349,18 +344,17 @@ rec_init_offsets_comp_ordinary(
if (rec_offs_n_fields(offsets) <= n_fields) { if (rec_offs_n_fields(offsets) <= n_fields) {
goto ordinary; goto ordinary;
} }
ulint len; nulls = &rec[-REC_N_NEW_EXTRA_BYTES];
n_fields = index->n_core_fields + 1 n_fields = index->n_core_fields + 1
+ rec_get_n_add_field(rec, &len); + rec_get_n_add_field(nulls);
ut_ad(n_fields <= index->n_fields); ut_ad(n_fields <= index->n_fields);
ut_ad(extra_bytes == REC_N_NEW_EXTRA_BYTES); ut_ad(extra_bytes == REC_N_NEW_EXTRA_BYTES);
nulls = rec - (1 + REC_N_NEW_EXTRA_BYTES) - len;
const ulint n_nullable = index->get_n_nullable(n_fields); const ulint n_nullable = index->get_n_nullable(n_fields);
const ulint n_null_bytes = UT_BITS_IN_BYTES(n_nullable); const ulint n_null_bytes = UT_BITS_IN_BYTES(n_nullable);
ut_d(n_null = n_nullable); ut_d(n_null = n_nullable);
ut_ad(n_null <= index->n_nullable); ut_ad(n_null <= index->n_nullable);
ut_ad(n_null_bytes >= index->n_core_null_bytes); ut_ad(n_null_bytes >= index->n_core_null_bytes);
lens = nulls - n_null_bytes; lens = --nulls - n_null_bytes;
} }
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -1949,12 +1943,11 @@ rec_copy_prefix_to_buf( ...@@ -1949,12 +1943,11 @@ rec_copy_prefix_to_buf(
ut_ad(index->is_instant()); ut_ad(index->is_instant());
if (n_fields >= index->n_core_fields) { if (n_fields >= index->n_core_fields) {
ut_ad(n_fields <= index->n_fields); ut_ad(n_fields <= index->n_fields);
ulint len; nulls = &rec[-REC_N_NEW_EXTRA_BYTES];
ulint n_rec = n_fields + 1 const ulint n_rec = n_fields + 1
+ rec_get_n_add_field(rec, &len); + rec_get_n_add_field(nulls);
const uint n_nullable = index->get_n_nullable(n_rec); const uint n_nullable = index->get_n_nullable(n_rec);
nulls = rec - (REC_N_NEW_EXTRA_BYTES + 1) - len; lens = --nulls - UT_BITS_IN_BYTES(n_nullable);
lens = nulls - UT_BITS_IN_BYTES(n_nullable);
break; break;
} }
/* fall through */ /* fall through */
......
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