Commit 4d683b90 authored by Marko Mäkelä's avatar Marko Mäkelä

Correctly update the metadata record to generic format

btr_cur_optimistic_insert(): Avoid unnecessary computation of rec_size.

btr_cur_pessimistic_update(): Correctly check for generic ALTER TABLE
metadata record when update an instant ADD COLUMN record.

instant_metadata(): Invoke dict_table_t::serialise_columns()
at the earliest possibility. Previously this was only invoked
during insert in dtuple_convert_big_rec().

rec_get_converted_size_comp_prefix_low(): Assume that the metadata
field will be stored externally. In dtuple_convert_big_rec() during
the rec_get_converted_size() call, it would not be there yet.
parent 67fc7b23
......@@ -521,7 +521,7 @@ HEX(c8)
ROLLBACK;
ALTER TABLE tab add COLUMN c9 POINT NOT NULL AFTER c5, ALGORITHM = INPLACE, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED
ALTER TABLE tab DROP COLUMN c9, ALGORITHM=INSTANT;
SHOW CREATE TABLE tab;
Table Create Table
tab CREATE TABLE `tab` (
......
......@@ -491,9 +491,8 @@ FROM tab LIMIT 1;
SELECT HEX(c8) FROM tab;
ROLLBACK;
# not instant, not supported
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE tab add COLUMN c9 POINT NOT NULL AFTER c5, ALGORITHM = INPLACE, LOCK=NONE;
ALTER TABLE tab DROP COLUMN c9, ALGORITHM=INSTANT;
SHOW CREATE TABLE tab;
......
......@@ -3345,13 +3345,17 @@ btr_cur_optimistic_insert(
leaf = page_is_leaf(page);
if (UNIV_UNLIKELY(entry->is_alter_metadata())) {
ut_ad(leaf);
goto convert_big_rec;
}
/* Calculate the record size when entry is converted to a record */
rec_size = rec_get_converted_size(index, entry, n_ext);
if (page_zip_rec_needs_ext(rec_size, page_is_comp(page),
dtuple_get_n_fields(entry), page_size)
|| UNIV_UNLIKELY(entry->is_alter_metadata())) {
dtuple_get_n_fields(entry), page_size)) {
convert_big_rec:
/* The record is so big that we have to store some fields
externally on separate database pages */
big_rec_vec = dtuple_convert_big_rec(index, 0, entry, &n_ext);
......@@ -4780,7 +4784,7 @@ btr_cur_pessimistic_update(
page_is_comp(page),
dict_index_get_n_fields(index),
block->page.size)
|| UNIV_UNLIKELY(rec_is_alter_metadata(rec, *index))) {
|| UNIV_UNLIKELY(update->is_alter_metadata())) {
big_rec_vec = dtuple_convert_big_rec(index, update, new_entry, &n_ext);
if (UNIV_UNLIKELY(big_rec_vec == NULL)) {
......
......@@ -640,7 +640,9 @@ dtuple_convert_big_rec(
if (entry->is_alter_metadata()) {
longest_i = index->n_uniq + DATA_ROLL_PTR;
dfield = dtuple_get_nth_field(entry, longest_i);
#if 1 // FIXME: remove this
index->table->serialise_columns(heap, dfield);
#endif
local_len = BTR_EXTERN_FIELD_REF_SIZE;
goto ext_write;
}
......
......@@ -4744,10 +4744,7 @@ static dtuple_t* instant_metadata(
dfield_t* dfield = dtuple_get_nth_field(entry, i);
if (i == index.first_user_field()) {
dfield_set_data(dfield,
mem_heap_zalloc(heap, FIELD_REF_SIZE),
FIELD_REF_SIZE);
dfield_set_ext(dfield);
index.table->serialise_columns(heap, dfield);
dfield->type.metadata_blob_init();
field--;
continue;
......@@ -5031,9 +5028,8 @@ static bool innobase_instant_try(
upd_field_t* uf = upd_get_nth_field(update, 0);
uf->field_no = index->first_user_field();
uf->new_val = entry->fields[uf->field_no];
DBUG_ASSERT(dfield_is_ext(&uf->new_val));
DBUG_ASSERT(dfield_get_len(&uf->new_val)
== BTR_EXTERN_FIELD_REF_SIZE);
DBUG_ASSERT(!dfield_is_ext(&uf->new_val));
DBUG_ASSERT(!dfield_is_null(&uf->new_val));
}
/* Add the default values for instantly added columns */
......
......@@ -1169,15 +1169,13 @@ rec_get_converted_size_comp_prefix_low(
const dfield_t* const end = dfield + n_fields;
/* read the lengths of fields 0..n */
for (ulint i = 0; dfield < end; i++, dfield++) {
ulint len = dfield_get_len(dfield);
if (mblob && i == index->first_user_field()) {
ut_ad(len == FIELD_REF_SIZE);
ut_ad(dfield_is_ext(dfield));
data_size += len;
len = dfield_get_len(++dfield);
data_size += FIELD_REF_SIZE;
++dfield;
}
ulint len = dfield_get_len(dfield);
const dict_field_t* field = dict_index_get_nth_field(index, i);
#ifdef UNIV_DEBUG
if (dict_index_is_spatial(index)) {
......
......@@ -1350,8 +1350,7 @@ row_upd_index_replace_metadata(
dfield_t* dfield = dtuple_get_nth_field(entry, f);
if (f-- == first) {
ut_ad(dfield_is_ext(&uf->new_val));
ut_ad(dfield_get_len(&uf->new_val) == FIELD_REF_SIZE);
ut_ad(!dfield_is_ext(&uf->new_val));
ut_ad(!dfield_is_null(&uf->new_val));
ut_ad(dfield_is_ext(dfield));
ut_ad(dfield_get_len(dfield) == FIELD_REF_SIZE);
......
......@@ -1046,8 +1046,8 @@ trx_undo_page_report_modify(
ut_ad(!upd_fld_is_virtual_col(&update->fields[0]));
ut_ad(update->fields[0].field_no
== index->first_user_field());
ut_ad(update->fields[0].new_val.ext);
ut_ad(update->fields[0].new_val.len == FIELD_REF_SIZE);
ut_ad(!dfield_is_ext(&update->fields[0].new_val));
ut_ad(!dfield_is_null(&update->fields[0].new_val));
/* The instant ADD COLUMN metadata record does not
contain the BLOB. Do not write anything for it. */
i = !rec_is_alter_metadata(rec, *index);
......
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