summaryrefslogtreecommitdiff
path: root/storage/innobase/row
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-10-06 07:00:05 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-10-06 09:50:10 +0300
commita4948dafcd7eee65f16d848bdc6562fc49ef8916 (patch)
treef2f404bfab72b6b0f280dbc8cc468682ed7a7bd2 /storage/innobase/row
parent3a418242dffe93ee34db388727f67eb498ae48ee (diff)
downloadmariadb-git-a4948dafcd7eee65f16d848bdc6562fc49ef8916.tar.gz
MDEV-11369 Instant ADD COLUMN for InnoDB
For InnoDB tables, adding, dropping and reordering columns has required a rebuild of the table and all its indexes. Since MySQL 5.6 (and MariaDB 10.0) this has been supported online (LOCK=NONE), allowing concurrent modification of the tables. This work revises the InnoDB ROW_FORMAT=REDUNDANT, ROW_FORMAT=COMPACT and ROW_FORMAT=DYNAMIC so that columns can be appended instantaneously, with only minor changes performed to the table structure. The counter innodb_instant_alter_column in INFORMATION_SCHEMA.GLOBAL_STATUS is incremented whenever a table rebuild operation is converted into an instant ADD COLUMN operation. ROW_FORMAT=COMPRESSED tables will not support instant ADD COLUMN. Some usability limitations will be addressed in subsequent work: MDEV-13134 Introduce ALTER TABLE attributes ALGORITHM=NOCOPY and ALGORITHM=INSTANT MDEV-14016 Allow instant ADD COLUMN, ADD INDEX, LOCK=NONE The format of the clustered index (PRIMARY KEY) is changed as follows: (1) The FIL_PAGE_TYPE of the root page will be FIL_PAGE_TYPE_INSTANT, and a new field PAGE_INSTANT will contain the original number of fields in the clustered index ('core' fields). If instant ADD COLUMN has not been used or the table becomes empty, or the very first instant ADD COLUMN operation is rolled back, the fields PAGE_INSTANT and FIL_PAGE_TYPE will be reset to 0 and FIL_PAGE_INDEX. (2) A special 'default row' record is inserted into the leftmost leaf, between the page infimum and the first user record. This record is distinguished by the REC_INFO_MIN_REC_FLAG, and it is otherwise in the same format as records that contain values for the instantly added columns. This 'default row' always has the same number of fields as the clustered index according to the table definition. The values of 'core' fields are to be ignored. For other fields, the 'default row' will contain the default values as they were during the ALTER TABLE statement. (If the column default values are changed later, those values will only be stored in the .frm file. The 'default row' will contain the original evaluated values, which must be the same for every row.) The 'default row' must be completely hidden from higher-level access routines. Assertions have been added to ensure that no 'default row' is ever present in the adaptive hash index or in locked records. The 'default row' is never delete-marked. (3) In clustered index leaf page records, the number of fields must reside between the number of 'core' fields (dict_index_t::n_core_fields introduced in this work) and dict_index_t::n_fields. If the number of fields is less than dict_index_t::n_fields, the missing fields are replaced with the column value of the 'default row'. Note: The number of fields in the record may shrink if some of the last instantly added columns are updated to the value that is in the 'default row'. The function btr_cur_trim() implements this 'compression' on update and rollback; dtuple::trim() implements it on insert. (4) In ROW_FORMAT=COMPACT and ROW_FORMAT=DYNAMIC records, the new status value REC_STATUS_COLUMNS_ADDED will indicate the presence of a new record header that will encode n_fields-n_core_fields-1 in 1 or 2 bytes. (In ROW_FORMAT=REDUNDANT records, the record header always explicitly encodes the number of fields.) We introduce the undo log record type TRX_UNDO_INSERT_DEFAULT for covering the insert of the 'default row' record when instant ADD COLUMN is used for the first time. Subsequent instant ADD COLUMN can use TRX_UNDO_UPD_EXIST_REC. This is joint work with Vin Chen (陈福荣) from Tencent. The design that was discussed in April 2017 would not have allowed import or export of data files, because instead of the 'default row' it would have introduced a data dictionary table. The test rpl.rpl_alter_instant is exactly as contributed in pull request #408. The test innodb.instant_alter is based on a contributed test. The redo log record format changes for ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPACT are as contributed. (With this change present, crash recovery from MariaDB 10.3.1 will fail in spectacular ways!) Also the semantics of higher-level redo log records that modify the PAGE_INSTANT field is changed. The redo log format version identifier was already changed to LOG_HEADER_FORMAT_CURRENT=103 in MariaDB 10.3.1. Everything else has been rewritten by me. Thanks to Elena Stepanova, the code has been tested extensively. When rolling back an instant ADD COLUMN operation, we must empty the PAGE_FREE list after deleting or shortening the 'default row' record, by calling either btr_page_empty() or btr_page_reorganize(). We must know the size of each entry in the PAGE_FREE list. If rollback left a freed copy of the 'default row' in the PAGE_FREE list, we would be unable to determine its size (if it is in ROW_FORMAT=COMPACT or ROW_FORMAT=DYNAMIC) because it would contain more fields than the rolled-back definition of the clustered index. UNIV_SQL_DEFAULT: A new special constant that designates an instantly added column that is not present in the clustered index record. len_is_stored(): Check if a length is an actual length. There are two magic length values: UNIV_SQL_DEFAULT, UNIV_SQL_NULL. dict_col_t::def_val: The 'default row' value of the column. If the column is not added instantly, def_val.len will be UNIV_SQL_DEFAULT. dict_col_t: Add the accessors is_virtual(), is_nullable(), is_instant(), instant_value(). dict_col_t::remove_instant(): Remove the 'instant ADD' status of a column. dict_col_t::name(const dict_table_t& table): Replaces dict_table_get_col_name(). dict_index_t::n_core_fields: The original number of fields. For secondary indexes and if instant ADD COLUMN has not been used, this will be equal to dict_index_t::n_fields. dict_index_t::n_core_null_bytes: Number of bytes needed to represent the null flags; usually equal to UT_BITS_IN_BYTES(n_nullable). dict_index_t::NO_CORE_NULL_BYTES: Magic value signalling that n_core_null_bytes was not initialized yet from the clustered index root page. dict_index_t: Add the accessors is_instant(), is_clust(), get_n_nullable(), instant_field_value(). dict_index_t::instant_add_field(): Adjust clustered index metadata for instant ADD COLUMN. dict_index_t::remove_instant(): Remove the 'instant ADD' status of a clustered index when the table becomes empty, or the very first instant ADD COLUMN operation is rolled back. dict_table_t: Add the accessors is_instant(), is_temporary(), supports_instant(). dict_table_t::instant_add_column(): Adjust metadata for instant ADD COLUMN. dict_table_t::rollback_instant(): Adjust metadata on the rollback of instant ADD COLUMN. prepare_inplace_alter_table_dict(): First create the ctx->new_table, and only then decide if the table really needs to be rebuilt. We must split the creation of table or index metadata from the creation of the dictionary table records and the creation of the data. In this way, we can transform a table-rebuilding operation into an instant ADD COLUMN operation. Dictionary objects will only be added to cache when table rebuilding or index creation is needed. The ctx->instant_table will never be added to cache. dict_table_t::add_to_cache(): Modified and renamed from dict_table_add_to_cache(). Do not modify the table metadata. Let the callers invoke dict_table_add_system_columns() and if needed, set can_be_evicted. dict_create_sys_tables_tuple(), dict_create_table_step(): Omit the system columns (which will now exist in the dict_table_t object already at this point). dict_create_table_step(): Expect the callers to invoke dict_table_add_system_columns(). pars_create_table(): Before creating the table creation execution graph, invoke dict_table_add_system_columns(). row_create_table_for_mysql(): Expect all callers to invoke dict_table_add_system_columns(). create_index_dict(): Replaces row_merge_create_index_graph(). innodb_update_n_cols(): Renamed from innobase_update_n_virtual(). Call my_error() if an error occurs. btr_cur_instant_init(), btr_cur_instant_init_low(), btr_cur_instant_root_init(): Load additional metadata from the clustered index and set dict_index_t::n_core_null_bytes. This is invoked when table metadata is first loaded into the data dictionary. dict_boot(): Initialize n_core_null_bytes for the four hard-coded dictionary tables. dict_create_index_step(): Initialize n_core_null_bytes. This is executed as part of CREATE TABLE. dict_index_build_internal_clust(): Initialize n_core_null_bytes to NO_CORE_NULL_BYTES if table->supports_instant(). row_create_index_for_mysql(): Initialize n_core_null_bytes for CREATE TEMPORARY TABLE. commit_cache_norebuild(): Call the code to rename or enlarge columns in the cache only if instant ADD COLUMN is not being used. (Instant ADD COLUMN would copy all column metadata from instant_table to old_table, including the names and lengths.) PAGE_INSTANT: A new 13-bit field for storing dict_index_t::n_core_fields. This is repurposing the 16-bit field PAGE_DIRECTION, of which only the least significant 3 bits were used. The original byte containing PAGE_DIRECTION will be accessible via the new constant PAGE_DIRECTION_B. page_get_instant(), page_set_instant(): Accessors for the PAGE_INSTANT. page_ptr_get_direction(), page_get_direction(), page_ptr_set_direction(): Accessors for PAGE_DIRECTION. page_direction_reset(): Reset PAGE_DIRECTION, PAGE_N_DIRECTION. page_direction_increment(): Increment PAGE_N_DIRECTION and set PAGE_DIRECTION. rec_get_offsets(): Use the 'leaf' parameter for non-debug purposes, and assume that heap_no is always set. Initialize all dict_index_t::n_fields for ROW_FORMAT=REDUNDANT records, even if the record contains fewer fields. rec_offs_make_valid(): Add the parameter 'leaf'. rec_copy_prefix_to_dtuple(): Assert that the tuple is only built on the core fields. Instant ADD COLUMN only applies to the clustered index, and we should never build a search key that has more than the PRIMARY KEY and possibly DB_TRX_ID,DB_ROLL_PTR. All these columns are always present. dict_index_build_data_tuple(): Remove assertions that would be duplicated in rec_copy_prefix_to_dtuple(). rec_init_offsets(): Support ROW_FORMAT=REDUNDANT records whose number of fields is between n_core_fields and n_fields. cmp_rec_rec_with_match(): Implement the comparison between two MIN_REC_FLAG records. trx_t::in_rollback: Make the field available in non-debug builds. trx_start_for_ddl_low(): Remove dangerous error-tolerance. A dictionary transaction must be flagged as such before it has generated any undo log records. This is because trx_undo_assign_undo() will mark the transaction as a dictionary transaction in the undo log header right before the very first undo log record is being written. btr_index_rec_validate(): Account for instant ADD COLUMN row_undo_ins_remove_clust_rec(): On the rollback of an insert into SYS_COLUMNS, revert instant ADD COLUMN in the cache by removing the last column from the table and the clustered index. row_search_on_row_ref(), row_undo_mod_parse_undo_rec(), row_undo_mod(), trx_undo_update_rec_get_update(): Handle the 'default row' as a special case. dtuple_t::trim(index): Omit a redundant suffix of an index tuple right before insert or update. After instant ADD COLUMN, if the last fields of a clustered index tuple match the 'default row', there is no need to store them. While trimming the entry, we must hold a page latch, so that the table cannot be emptied and the 'default row' be deleted. btr_cur_optimistic_update(), btr_cur_pessimistic_update(), row_upd_clust_rec_by_insert(), row_ins_clust_index_entry_low(): Invoke dtuple_t::trim() if needed. row_ins_clust_index_entry(): Restore dtuple_t::n_fields after calling row_ins_clust_index_entry_low(). rec_get_converted_size(), rec_get_converted_size_comp(): Allow the number of fields to be between n_core_fields and n_fields. Do not support infimum,supremum. They are never supposed to be stored in dtuple_t, because page creation nowadays uses a lower-level method for initializing them. rec_convert_dtuple_to_rec_comp(): Assign the status bits based on the number of fields. btr_cur_trim(): In an update, trim the index entry as needed. For the 'default row', handle rollback specially. For user records, omit fields that match the 'default row'. btr_cur_optimistic_delete_func(), btr_cur_pessimistic_delete(): Skip locking and adaptive hash index for the 'default row'. row_log_table_apply_convert_mrec(): Replace 'default row' values if needed. In the temporary file that is applied by row_log_table_apply(), we must identify whether the records contain the extra header for instantly added columns. For now, we will allocate an additional byte for this for ROW_T_INSERT and ROW_T_UPDATE records when the source table has been subject to instant ADD COLUMN. The ROW_T_DELETE records are fine, as they will be converted and will only contain 'core' columns (PRIMARY KEY and some system columns) that are converted from dtuple_t. rec_get_converted_size_temp(), rec_init_offsets_temp(), rec_convert_dtuple_to_temp(): Add the parameter 'status'. REC_INFO_DEFAULT_ROW = REC_INFO_MIN_REC_FLAG | REC_STATUS_COLUMNS_ADDED: An info_bits constant for distinguishing the 'default row' record. rec_comp_status_t: An enum of the status bit values. rec_leaf_format: An enum that replaces the bool parameter of rec_init_offsets_comp_ordinary().
Diffstat (limited to 'storage/innobase/row')
-rw-r--r--storage/innobase/row/row0ftsort.cc5
-rw-r--r--storage/innobase/row/row0import.cc28
-rw-r--r--storage/innobase/row/row0ins.cc52
-rw-r--r--storage/innobase/row/row0log.cc139
-rw-r--r--storage/innobase/row/row0merge.cc82
-rw-r--r--storage/innobase/row/row0mysql.cc7
-rw-r--r--storage/innobase/row/row0purge.cc19
-rw-r--r--storage/innobase/row/row0row.cc100
-rw-r--r--storage/innobase/row/row0sel.cc84
-rw-r--r--storage/innobase/row/row0trunc.cc18
-rw-r--r--storage/innobase/row/row0uins.cc107
-rw-r--r--storage/innobase/row/row0umod.cc22
-rw-r--r--storage/innobase/row/row0undo.cc5
-rw-r--r--storage/innobase/row/row0upd.cc74
-rw-r--r--storage/innobase/row/row0vers.cc4
15 files changed, 531 insertions, 215 deletions
diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc
index dad00c58827..5d4824f0aae 100644
--- a/storage/innobase/row/row0ftsort.cc
+++ b/storage/innobase/row/row0ftsort.cc
@@ -1679,6 +1679,11 @@ row_fts_merge_insert(
dict_table_close(aux_table, FALSE, FALSE);
aux_index = dict_table_get_first_index(aux_table);
+ ut_ad(!aux_index->is_instant());
+ /* row_merge_write_fts_node() depends on the correct value */
+ ut_ad(aux_index->n_core_null_bytes
+ == UT_BITS_IN_BYTES(aux_index->n_nullable));
+
FlushObserver* observer;
observer = psort_info[0].psort_common->trx->flush_observer;
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index c8a9370208f..757fbd28a88 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -1439,6 +1439,13 @@ IndexPurge::open() UNIV_NOTHROW
btr_pcur_open_at_index_side(
true, m_index, BTR_MODIFY_LEAF, &m_pcur, true, 0, &m_mtr);
+ btr_pcur_move_to_next_user_rec(&m_pcur, &m_mtr);
+ if (rec_is_default_row(btr_pcur_get_rec(&m_pcur), m_index)) {
+ ut_ad(btr_pcur_is_on_user_rec(&m_pcur));
+ /* Skip the 'default row' pseudo-record. */
+ } else {
+ btr_pcur_move_to_prev_on_page(&m_pcur);
+ }
}
/**
@@ -1815,6 +1822,13 @@ PageConverter::update_index_page(
if (dict_index_is_clust(m_index->m_srv_index)) {
if (page_is_root(page)) {
/* Preserve the PAGE_ROOT_AUTO_INC. */
+ if (m_index->m_srv_index->table->supports_instant()
+ && btr_cur_instant_root_init(
+ const_cast<dict_index_t*>(
+ m_index->m_srv_index),
+ page)) {
+ return(DB_CORRUPTION);
+ }
} else {
/* Clear PAGE_MAX_TRX_ID so that it can be
used for other purposes in the future. IMPORT
@@ -1907,6 +1921,8 @@ PageConverter::update_page(
return(DB_CORRUPTION);
}
+ /* fall through */
+ case FIL_PAGE_TYPE_INSTANT:
/* This is on every page in the tablespace. */
mach_write_to_4(
get_frame(block)
@@ -2309,7 +2325,14 @@ row_import_set_sys_max_row_id(
rec = btr_pcur_get_rec(&pcur);
/* Check for empty table. */
- if (!page_rec_is_infimum(rec)) {
+ if (page_rec_is_infimum(rec)) {
+ /* The table is empty. */
+ err = DB_SUCCESS;
+ } else if (rec_is_default_row(rec, index)) {
+ /* The clustered index contains the 'default row',
+ that is, the table is empty. */
+ err = DB_SUCCESS;
+ } else {
ulint len;
const byte* field;
mem_heap_t* heap = NULL;
@@ -2336,9 +2359,6 @@ row_import_set_sys_max_row_id(
if (heap != NULL) {
mem_heap_free(heap);
}
- } else {
- /* The table is empty. */
- err = DB_SUCCESS;
}
btr_pcur_close(&pcur);
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 9b9d19ae960..88508cd8ce3 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -2250,6 +2250,8 @@ row_ins_duplicate_error_in_clust_online(
dberr_t err = DB_SUCCESS;
const rec_t* rec = btr_cur_get_rec(cursor);
+ ut_ad(!cursor->index->is_instant());
+
if (cursor->low_match >= n_uniq && !page_rec_is_infimum(rec)) {
*offsets = rec_get_offsets(rec, cursor->index, *offsets, true,
ULINT_UNDEFINED, heap);
@@ -2583,6 +2585,7 @@ row_ins_clust_index_entry_low(
ut_ad(flags & BTR_NO_LOCKING_FLAG);
ut_ad(!dict_index_is_online_ddl(index));
ut_ad(!index->table->persistent_autoinc);
+ ut_ad(!index->is_instant());
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
@@ -2634,6 +2637,41 @@ row_ins_clust_index_entry_low(
}
#endif /* UNIV_DEBUG */
+ if (UNIV_UNLIKELY(entry->info_bits)) {
+ ut_ad(entry->info_bits == REC_INFO_DEFAULT_ROW);
+ ut_ad(flags == BTR_NO_LOCKING_FLAG);
+ ut_ad(index->is_instant());
+ ut_ad(!dict_index_is_online_ddl(index));
+ ut_ad(!dup_chk_only);
+
+ const rec_t* rec = btr_cur_get_rec(cursor);
+
+ switch (rec_get_info_bits(rec, page_rec_is_comp(rec))
+ & (REC_INFO_MIN_REC_FLAG | REC_INFO_DELETED_FLAG)) {
+ case REC_INFO_MIN_REC_FLAG:
+ thr_get_trx(thr)->error_info = index;
+ err = DB_DUPLICATE_KEY;
+ goto err_exit;
+ case REC_INFO_MIN_REC_FLAG | REC_INFO_DELETED_FLAG:
+ /* The 'default row' is never delete-marked.
+ If a table loses its 'instantness', it happens
+ by the rollback of this first-time insert, or
+ by a call to btr_page_empty() on the root page
+ when the table becomes empty. */
+ err = DB_CORRUPTION;
+ goto err_exit;
+ default:
+ ut_ad(!row_ins_must_modify_rec(cursor));
+ goto do_insert;
+ }
+ }
+
+ if (index->is_instant()) entry->trim(*index);
+
+ if (rec_is_default_row(btr_cur_get_rec(cursor), index)) {
+ goto do_insert;
+ }
+
if (n_uniq
&& (cursor->up_match >= n_uniq || cursor->low_match >= n_uniq)) {
@@ -2696,6 +2734,7 @@ err_exit:
mtr_commit(&mtr);
mem_heap_free(entry_heap);
} else {
+do_insert:
rec_t* insert_rec;
if (mode != BTR_MODIFY_TREE) {
@@ -3192,16 +3231,19 @@ row_ins_clust_index_entry(
n_uniq = dict_index_is_unique(index) ? index->n_uniq : 0;
- /* Try first optimistic descent to the B-tree */
- log_free_check();
- const ulint flags = dict_table_is_temporary(index->table)
+ const ulint flags = index->table->is_temporary()
? BTR_NO_LOCKING_FLAG
: index->table->no_rollback() ? BTR_NO_ROLLBACK : 0;
+ const ulint orig_n_fields = entry->n_fields;
+
+ /* Try first optimistic descent to the B-tree */
+ log_free_check();
err = row_ins_clust_index_entry_low(
flags, BTR_MODIFY_LEAF, index, n_uniq, entry,
n_ext, thr, dup_chk_only);
+ entry->n_fields = orig_n_fields;
DEBUG_SYNC_C_IF_THD(thr_get_trx(thr)->mysql_thd,
"after_row_ins_clust_index_entry_leaf");
@@ -3218,6 +3260,8 @@ row_ins_clust_index_entry(
flags, BTR_MODIFY_TREE, index, n_uniq, entry,
n_ext, thr, dup_chk_only);
+ entry->n_fields = orig_n_fields;
+
DBUG_RETURN(err);
}
@@ -3311,7 +3355,7 @@ row_ins_index_entry(
DBUG_SET("-d,row_ins_index_entry_timeout");
return(DB_LOCK_WAIT);});
- if (dict_index_is_clust(index)) {
+ if (index->is_clust()) {
return(row_ins_clust_index_entry(index, entry, thr, 0, false));
} else {
return(row_ins_sec_index_entry(index, entry, thr, false));
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index a5dff03c16f..edb55534ada 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -832,16 +832,18 @@ row_log_table_low_redundant(
mem_heap_t* heap = NULL;
dtuple_t* tuple;
ulint num_v = ventry ? dtuple_get_n_v_fields(ventry) : 0;
+ const ulint n_fields = rec_get_n_fields_old(rec);
ut_ad(!page_is_comp(page_align(rec)));
- ut_ad(dict_index_get_n_fields(index) == rec_get_n_fields_old(rec));
+ ut_ad(index->n_fields >= n_fields);
+ ut_ad(index->n_fields == n_fields || index->is_instant());
ut_ad(dict_tf2_is_valid(index->table->flags, index->table->flags2));
ut_ad(!dict_table_is_comp(index->table)); /* redundant row format */
ut_ad(dict_index_is_clust(new_index));
- heap = mem_heap_create(DTUPLE_EST_ALLOC(index->n_fields));
- tuple = dtuple_create_with_vcol(heap, index->n_fields, num_v);
- dict_index_copy_types(tuple, index, index->n_fields);
+ heap = mem_heap_create(DTUPLE_EST_ALLOC(n_fields));
+ tuple = dtuple_create_with_vcol(heap, n_fields, num_v);
+ dict_index_copy_types(tuple, index, n_fields);
if (num_v) {
dict_table_copy_v_types(tuple, index->table);
@@ -850,7 +852,7 @@ row_log_table_low_redundant(
dtuple_set_n_fields_cmp(tuple, dict_index_get_n_unique(index));
if (rec_get_1byte_offs_flag(rec)) {
- for (ulint i = 0; i < index->n_fields; i++) {
+ for (ulint i = 0; i < n_fields; i++) {
dfield_t* dfield;
ulint len;
const void* field;
@@ -861,7 +863,7 @@ row_log_table_low_redundant(
dfield_set_data(dfield, field, len);
}
} else {
- for (ulint i = 0; i < index->n_fields; i++) {
+ for (ulint i = 0; i < n_fields; i++) {
dfield_t* dfield;
ulint len;
const void* field;
@@ -877,8 +879,15 @@ row_log_table_low_redundant(
}
}
+ rec_comp_status_t status = index->is_instant()
+ ? REC_STATUS_COLUMNS_ADDED : REC_STATUS_ORDINARY;
+
size = rec_get_converted_size_temp(
- index, tuple->fields, tuple->n_fields, &extra_size);
+ index, tuple->fields, tuple->n_fields, &extra_size, status);
+ if (index->is_instant()) {
+ size++;
+ extra_size++;
+ }
ulint v_size = num_v
? rec_get_converted_size_temp_v(index, ventry) : 0;
@@ -913,15 +922,19 @@ row_log_table_low_redundant(
if (byte* b = row_log_table_open(index->online_log,
mrec_size, &avail_size)) {
- *b++ = insert ? ROW_T_INSERT : ROW_T_UPDATE;
+ if (insert) {
+ *b++ = ROW_T_INSERT;
+ } else {
+ *b++ = ROW_T_UPDATE;
- if (old_pk_size) {
- *b++ = static_cast<byte>(old_pk_extra_size);
+ if (old_pk_size) {
+ *b++ = static_cast<byte>(old_pk_extra_size);
- rec_convert_dtuple_to_temp(
- b + old_pk_extra_size, new_index,
- old_pk->fields, old_pk->n_fields);
- b += old_pk_size;
+ rec_convert_dtuple_to_temp(
+ b + old_pk_extra_size, new_index,
+ old_pk->fields, old_pk->n_fields);
+ b += old_pk_size;
+ }
}
if (extra_size < 0x80) {
@@ -932,8 +945,17 @@ row_log_table_low_redundant(
*b++ = static_cast<byte>(extra_size);
}
+ if (status == REC_STATUS_COLUMNS_ADDED) {
+ ut_ad(index->is_instant());
+ if (n_fields <= index->n_core_fields) {
+ status = REC_STATUS_ORDINARY;
+ }
+ *b = status;
+ }
+
rec_convert_dtuple_to_temp(
- b + extra_size, index, tuple->fields, tuple->n_fields);
+ b + extra_size, index, tuple->fields, tuple->n_fields,
+ status);
b += size;
ut_ad(!num_v == !v_size);
if (num_v) {
@@ -976,7 +998,6 @@ row_log_table_low(
const dtuple_t* old_pk) /*!< in: old PRIMARY KEY value (if !insert
and a PRIMARY KEY is being created) */
{
- ulint omit_size;
ulint old_pk_size;
ulint old_pk_extra_size;
ulint extra_size;
@@ -995,7 +1016,19 @@ row_log_table_low(
ut_ad(rw_lock_own_flagged(
&index->lock,
RW_LOCK_FLAG_S | RW_LOCK_FLAG_X | RW_LOCK_FLAG_SX));
- ut_ad(fil_page_get_type(page_align(rec)) == FIL_PAGE_INDEX);
+#ifdef UNIV_DEBUG
+ switch (fil_page_get_type(page_align(rec))) {
+ case FIL_PAGE_INDEX:
+ break;
+ case FIL_PAGE_TYPE_INSTANT:
+ ut_ad(index->is_instant());
+ ut_ad(page_is_root(page_align(rec)));
+ break;
+ default:
+ ut_ad(!"wrong page type");
+ }
+#endif /* UNIV_DEBUG */
+ ut_ad(!rec_is_default_row(rec, index));
ut_ad(page_rec_is_leaf(rec));
ut_ad(!page_is_comp(page_align(rec)) == !rec_offs_comp(offsets));
/* old_pk=row_log_table_get_pk() [not needed in INSERT] is a prefix
@@ -1020,14 +1053,17 @@ row_log_table_low(
}
ut_ad(page_is_comp(page_align(rec)));
- ut_ad(rec_get_status(rec) == REC_STATUS_ORDINARY);
+ ut_ad(rec_get_status(rec) == REC_STATUS_ORDINARY
+ || rec_get_status(rec) == REC_STATUS_COLUMNS_ADDED);
- omit_size = REC_N_NEW_EXTRA_BYTES;
+ const ulint omit_size = REC_N_NEW_EXTRA_BYTES;
- extra_size = rec_offs_extra_size(offsets) - omit_size;
+ const ulint rec_extra_size = rec_offs_extra_size(offsets) - omit_size;
+ extra_size = rec_extra_size + index->is_instant();
mrec_size = ROW_LOG_HEADER_SIZE
- + (extra_size >= 0x80) + rec_offs_size(offsets) - omit_size;
+ + (extra_size >= 0x80) + rec_offs_size(offsets) - omit_size
+ + index->is_instant();
if (ventry && ventry->n_v_fields > 0) {
mrec_size += rec_get_converted_size_temp_v(new_index, ventry);
@@ -1063,15 +1099,19 @@ row_log_table_low(
if (byte* b = row_log_table_open(index->online_log,
mrec_size, &avail_size)) {
- *b++ = insert ? ROW_T_INSERT : ROW_T_UPDATE;
+ if (insert) {
+ *b++ = ROW_T_INSERT;
+ } else {
+ *b++ = ROW_T_UPDATE;
- if (old_pk_size) {
- *b++ = static_cast<byte>(old_pk_extra_size);
+ if (old_pk_size) {
+ *b++ = static_cast<byte>(old_pk_extra_size);
- rec_convert_dtuple_to_temp(
- b + old_pk_extra_size, new_index,
- old_pk->fields, old_pk->n_fields);
- b += old_pk_size;
+ rec_convert_dtuple_to_temp(
+ b + old_pk_extra_size, new_index,
+ old_pk->fields, old_pk->n_fields);
+ b += old_pk_size;
+ }
}
if (extra_size < 0x80) {
@@ -1082,8 +1122,14 @@ row_log_table_low(
*b++ = static_cast<byte>(extra_size);
}
- memcpy(b, rec - rec_offs_extra_size(offsets), extra_size);
- b += extra_size;
+ if (index->is_instant()) {
+ *b++ = rec_get_status(rec);
+ } else {
+ ut_ad(rec_get_status(rec) == REC_STATUS_ORDINARY);
+ }
+
+ memcpy(b, rec - rec_extra_size - omit_size, rec_extra_size);
+ b += rec_extra_size;
memcpy(b, rec, rec_offs_data_size(offsets));
b += rec_offs_data_size(offsets);
@@ -1618,6 +1664,9 @@ blob_done:
rw_lock_x_unlock(dict_index_get_lock(index));
} else {
data = rec_get_nth_field(mrec, offsets, i, &len);
+ if (len == UNIV_SQL_DEFAULT) {
+ data = index->instant_field_value(i, &len);
+ }
dfield_set_data(dfield, data, len);
}
@@ -2479,12 +2528,18 @@ row_log_table_apply_op(
mrec += extra_size;
+ ut_ad(extra_size || !dup->index->is_instant());
+
if (mrec > mrec_end) {
return(NULL);
}
rec_offs_set_n_fields(offsets, dup->index->n_fields);
- rec_init_offsets_temp(mrec, dup->index, offsets);
+ rec_init_offsets_temp(mrec, dup->index, offsets,
+ dup->index->is_instant()
+ ? static_cast<rec_comp_status_t>(
+ *(mrec - extra_size))
+ : REC_STATUS_ORDINARY);
next_mrec = mrec + rec_offs_data_size(offsets);
@@ -2520,6 +2575,9 @@ row_log_table_apply_op(
For fixed-length PRIMARY key columns, it is 0. */
mrec += extra_size;
+ /* The ROW_T_DELETE record was converted by
+ rec_convert_dtuple_to_temp() using new_index. */
+ ut_ad(!new_index->is_instant());
rec_offs_set_n_fields(offsets, new_index->n_uniq + 2);
rec_init_offsets_temp(mrec, new_index, offsets);
next_mrec = mrec + rec_offs_data_size(offsets) + ext_size;
@@ -2590,12 +2648,18 @@ row_log_table_apply_op(
mrec += extra_size;
+ ut_ad(extra_size || !dup->index->is_instant());
+
if (mrec > mrec_end) {
return(NULL);
}
rec_offs_set_n_fields(offsets, dup->index->n_fields);
- rec_init_offsets_temp(mrec, dup->index, offsets);
+ rec_init_offsets_temp(mrec, dup->index, offsets,
+ dup->index->is_instant()
+ ? static_cast<rec_comp_status_t>(
+ *(mrec - extra_size))
+ : REC_STATUS_ORDINARY);
next_mrec = mrec + rec_offs_data_size(offsets);
@@ -2638,6 +2702,9 @@ row_log_table_apply_op(
/* Get offsets for PRIMARY KEY,
DB_TRX_ID, DB_ROLL_PTR. */
+ /* The old_pk prefix was converted by
+ rec_convert_dtuple_to_temp() using new_index. */
+ ut_ad(!new_index->is_instant());
rec_offs_set_n_fields(offsets, new_index->n_uniq + 2);
rec_init_offsets_temp(mrec, new_index, offsets);
@@ -2690,12 +2757,18 @@ row_log_table_apply_op(
mrec += extra_size;
+ ut_ad(extra_size || !dup->index->is_instant());
+
if (mrec > mrec_end) {
return(NULL);
}
rec_offs_set_n_fields(offsets, dup->index->n_fields);
- rec_init_offsets_temp(mrec, dup->index, offsets);
+ rec_init_offsets_temp(mrec, dup->index, offsets,
+ dup->index->is_instant()
+ ? static_cast<rec_comp_status_t>(
+ *(mrec - extra_size))
+ : REC_STATUS_ORDINARY);
next_mrec = mrec + rec_offs_data_size(offsets);
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index fa466d09d30..a2442222d6d 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -1856,6 +1856,14 @@ row_merge_read_clustered_index(
btr_pcur_open_at_index_side(
true, clust_index, BTR_SEARCH_LEAF, &pcur, true, 0, &mtr);
+ btr_pcur_move_to_next_user_rec(&pcur, &mtr);
+ if (rec_is_default_row(btr_pcur_get_rec(&pcur), clust_index)) {
+ ut_ad(btr_pcur_is_on_user_rec(&pcur));
+ /* Skip the 'default row' pseudo-record. */
+ } else {
+ ut_ad(!clust_index->is_instant());
+ btr_pcur_move_to_prev_on_page(&pcur);
+ }
if (old_table != new_table) {
/* The table is being rebuilt. Identify the columns
@@ -4388,52 +4396,7 @@ row_merge_rename_tables_dict(
return(err);
}
-/** Create and execute a query graph for creating an index.
-@param[in,out] trx trx
-@param[in,out] table table
-@param[in,out] index index
-@param[in] add_v new virtual columns added along with add index call
-@return DB_SUCCESS or error code */
-MY_ATTRIBUTE((nonnull(1,2,3), warn_unused_result))
-static
-dberr_t
-row_merge_create_index_graph(
- trx_t* trx,
- dict_table_t* table,
- dict_index_t* index,
- const dict_add_v_col_t* add_v)
-{
- ind_node_t* node; /*!< Index creation node */
- mem_heap_t* heap; /*!< Memory heap */
- que_thr_t* thr; /*!< Query thread */
- dberr_t err;
-
- DBUG_ENTER("row_merge_create_index_graph");
-
- ut_ad(trx);
- ut_ad(table);
- ut_ad(index);
-
- heap = mem_heap_create(512);
-
- index->table = table;
- node = ind_create_graph_create(index, heap, add_v);
- thr = pars_complete_graph_for_exec(node, trx, heap, NULL);
-
- ut_a(thr == que_fork_start_command(
- static_cast<que_fork_t*>(que_node_get_parent(thr))));
-
- que_run_threads(thr);
-
- err = trx->error_state;
-
- que_graph_free((que_t*) que_node_get_parent(thr));
-
- DBUG_RETURN(err);
-}
-
/** Create the index and load in to the dictionary.
-@param[in,out] trx trx (sets error_state)
@param[in,out] table the index is on this table
@param[in] index_def the index definition
@param[in] add_v new virtual columns added along with add
@@ -4443,17 +4406,14 @@ row_merge_create_index_graph(
@return index, or NULL on error */
dict_index_t*
row_merge_create_index(
- trx_t* trx,
dict_table_t* table,
const index_def_t* index_def,
const dict_add_v_col_t* add_v,
const char** col_names)
{
dict_index_t* index;
- dberr_t err;
ulint n_fields = index_def->n_fields;
ulint i;
- bool has_new_v_col = false;
DBUG_ENTER("row_merge_create_index");
@@ -4466,8 +4426,7 @@ row_merge_create_index(
index = dict_mem_index_create(table->name.m_name, index_def->name,
0, index_def->ind_type, n_fields);
- ut_a(index);
-
+ index->table = table;
index->set_committed(index_def->rebuild);
for (i = 0; i < n_fields; i++) {
@@ -4481,7 +4440,7 @@ row_merge_create_index(
ut_ad(ifield->col_no >= table->n_v_def);
name = add_v->v_col_name[
ifield->col_no - table->n_v_def];
- has_new_v_col = true;
+ index->has_new_v_col = true;
} else {
name = dict_table_get_v_col_name(
table, ifield->col_no);
@@ -4506,27 +4465,6 @@ row_merge_create_index(
dict_mem_index_add_field(index, name, ifield->prefix_len);
}
- /* Add the index to SYS_INDEXES, using the index prototype. */
- err = row_merge_create_index_graph(trx, table, index, add_v);
-
- if (err == DB_SUCCESS) {
-
- index = dict_table_get_index_on_name(table, index_def->name,
- index_def->rebuild);
-
- ut_a(index);
-
- index->parser = index_def->parser;
- index->has_new_v_col = has_new_v_col;
-
- /* Note the id of the transaction that created this
- index, we use it to restrict readers from accessing
- this index, to ensure read consistency. */
- ut_ad(index->trx_id == trx->id);
- } else {
- index = NULL;
- }
-
DBUG_RETURN(index);
}
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index eb1c253be1c..f16155ef152 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -2622,6 +2622,8 @@ row_create_index_for_mysql(
index = dict_index_get_if_in_cache_low(index_id);
ut_a(index != NULL);
index->table = table;
+ ut_ad(!index->is_instant());
+ index->n_core_null_bytes = UT_BITS_IN_BYTES(index->n_nullable);
err = dict_create_index_tree_in_mem(index, trx);
@@ -3965,9 +3967,8 @@ row_drop_table_for_mysql(
}
sql += "DELETE FROM SYS_VIRTUAL\n"
- "WHERE TABLE_ID = table_id;\n";
-
- sql += "END;\n";
+ "WHERE TABLE_ID = table_id;\n"
+ "END;\n";
err = que_eval_sql(info, sql.c_str(), FALSE, trx);
} else {
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index b041917d398..f4f6d4cff9f 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -905,6 +905,7 @@ row_purge_parse_undo_rec(
node->rec_type = type;
switch (type) {
+ case TRX_UNDO_INSERT_DEFAULT:
case TRX_UNDO_INSERT_REC:
break;
default:
@@ -942,9 +943,15 @@ try_again:
goto err_exit;
}
- if (type != TRX_UNDO_INSERT_REC
- && node->table->n_v_cols && !node->table->vc_templ
- && dict_table_has_indexed_v_cols(node->table)) {
+ switch (type) {
+ case TRX_UNDO_INSERT_DEFAULT:
+ case TRX_UNDO_INSERT_REC:
+ break;
+ default:
+ if (!node->table->n_v_cols || node->table->vc_templ
+ || !dict_table_has_indexed_v_cols(node->table)) {
+ break;
+ }
/* Need server fully up for virtual column computation */
if (!mysqld_server_started) {
@@ -974,6 +981,11 @@ err_exit:
return(false);
}
+ if (type == TRX_UNDO_INSERT_DEFAULT) {
+ node->ref = &trx_undo_default_rec;
+ return(true);
+ }
+
ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref),
node->heap);
@@ -1034,6 +1046,7 @@ row_purge_record_func(
MONITOR_INC(MONITOR_N_DEL_ROW_PURGE);
}
break;
+ case TRX_UNDO_INSERT_DEFAULT:
case TRX_UNDO_INSERT_REC:
node->roll_ptr |= 1ULL << ROLL_PTR_INSERT_FLAG_POS;
/* fall through */
diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc
index a61adb7cd15..c9bd4533fd8 100644
--- a/storage/innobase/row/row0row.cc
+++ b/storage/innobase/row/row0row.cc
@@ -436,7 +436,7 @@ row_build_low(
}
/* Avoid a debug assertion in rec_offs_validate(). */
- rec_offs_make_valid(copy, index, const_cast<ulint*>(offsets));
+ rec_offs_make_valid(copy, index, true, const_cast<ulint*>(offsets));
if (!col_table) {
ut_ad(!col_map);
@@ -506,10 +506,14 @@ row_build_low(
}
dfield_t* dfield = dtuple_get_nth_field(row, col_no);
-
- const byte* field = rec_get_nth_field(
+ const void* field = rec_get_nth_field(
copy, offsets, i, &len);
-
+ if (len == UNIV_SQL_DEFAULT) {
+ field = index->instant_field_value(i, &len);
+ if (field && type != ROW_COPY_POINTERS) {
+ field = mem_heap_dup(heap, field, len);
+ }
+ }
dfield_set_data(dfield, field, len);
if (rec_offs_nth_extern(offsets, i)) {
@@ -526,7 +530,7 @@ row_build_low(
}
}
- rec_offs_make_valid(rec, index, const_cast<ulint*>(offsets));
+ rec_offs_make_valid(rec, index, true, const_cast<ulint*>(offsets));
ut_ad(dtuple_check_typed(row));
@@ -644,20 +648,24 @@ row_build_w_add_vcol(
add_cols, add_v, col_map, ext, heap));
}
-/*******************************************************************//**
-Converts an index record to a typed data tuple.
+/** Convert an index record to a data tuple.
+@tparam def whether the index->instant_field_value() needs to be accessed
+@param[in] rec index record
+@param[in] index index
+@param[in] offsets rec_get_offsets(rec, index)
+@param[out] n_ext number of externally stored columns
+@param[in,out] heap memory heap for allocations
@return index entry built; does not set info_bits, and the data fields
in the entry will point directly to rec */
+template<bool def>
+static inline
dtuple_t*
-row_rec_to_index_entry_low(
-/*=======================*/
- const rec_t* rec, /*!< in: record in the index */
- const dict_index_t* index, /*!< in: index */
- const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
- ulint* n_ext, /*!< out: number of externally
- stored columns */
- mem_heap_t* heap) /*!< in: memory heap from which
- the memory needed is allocated */
+row_rec_to_index_entry_impl(
+ const rec_t* rec,
+ const dict_index_t* index,
+ const ulint* offsets,
+ ulint* n_ext,
+ mem_heap_t* heap)
{
dtuple_t* entry;
dfield_t* dfield;
@@ -669,6 +677,7 @@ row_rec_to_index_entry_low(
ut_ad(rec != NULL);
ut_ad(heap != NULL);
ut_ad(index != NULL);
+ ut_ad(def || !rec_offs_any_default(offsets));
/* Because this function may be invoked by row0merge.cc
on a record whose header is in different format, the check
@@ -693,7 +702,9 @@ row_rec_to_index_entry_low(
for (i = 0; i < rec_len; i++) {
dfield = dtuple_get_nth_field(entry, i);
- field = rec_get_nth_field(rec, offsets, i, &len);
+ field = def
+ ? rec_get_nth_cfield(rec, index, offsets, i, &len)
+ : rec_get_nth_field(rec, offsets, i, &len);
dfield_set_data(dfield, field, len);
@@ -704,10 +715,27 @@ row_rec_to_index_entry_low(
}
ut_ad(dtuple_check_typed(entry));
-
return(entry);
}
+/** Convert an index record to a data tuple.
+@param[in] rec index record
+@param[in] index index
+@param[in] offsets rec_get_offsets(rec, index)
+@param[out] n_ext number of externally stored columns
+@param[in,out] heap memory heap for allocations */
+dtuple_t*
+row_rec_to_index_entry_low(
+ const rec_t* rec,
+ const dict_index_t* index,
+ const ulint* offsets,
+ ulint* n_ext,
+ mem_heap_t* heap)
+{
+ return row_rec_to_index_entry_impl<false>(
+ rec, index, offsets, n_ext, heap);
+}
+
/*******************************************************************//**
Converts an index record to a typed data tuple. NOTE that externally
stored (often big) fields are NOT copied to heap.
@@ -738,10 +766,12 @@ row_rec_to_index_entry(
copy_rec = rec_copy(buf, rec, offsets);
- rec_offs_make_valid(copy_rec, index, const_cast<ulint*>(offsets));
- entry = row_rec_to_index_entry_low(
+ rec_offs_make_valid(copy_rec, index, true,
+ const_cast<ulint*>(offsets));
+ entry = row_rec_to_index_entry_impl<true>(
copy_rec, index, offsets, n_ext, heap);
- rec_offs_make_valid(rec, index, const_cast<ulint*>(offsets));
+ rec_offs_make_valid(rec, index, true,
+ const_cast<ulint*>(offsets));
dtuple_set_info_bits(entry,
rec_get_info_bits(rec, rec_offs_comp(offsets)));
@@ -804,8 +834,7 @@ row_build_row_ref(
mem_heap_alloc(heap, rec_offs_size(offsets)));
rec = rec_copy(buf, rec, offsets);
- /* Avoid a debug assertion in rec_offs_validate(). */
- rec_offs_make_valid(rec, index, offsets);
+ rec_offs_make_valid(rec, index, true, offsets);
}
table = index->table;
@@ -825,6 +854,7 @@ row_build_row_ref(
ut_a(pos != ULINT_UNDEFINED);
+ ut_ad(!rec_offs_nth_default(offsets, pos));
field = rec_get_nth_field(rec, offsets, pos, &len);
dfield_set_data(dfield, field, len);
@@ -925,6 +955,7 @@ row_build_row_ref_in_tuple(
ut_a(pos != ULINT_UNDEFINED);
+ ut_ad(!rec_offs_nth_default(offsets, pos));
field = rec_get_nth_field(rec, offsets, pos, &len);
dfield_set_data(dfield, field, len);
@@ -980,9 +1011,24 @@ row_search_on_row_ref(
index = dict_table_get_first_index(table);
- ut_a(dtuple_get_n_fields(ref) == dict_index_get_n_unique(index));
-
- btr_pcur_open(index, ref, PAGE_CUR_LE, mode, pcur, mtr);
+ if (UNIV_UNLIKELY(ref->info_bits)) {
+ ut_ad(ref->info_bits == REC_INFO_DEFAULT_ROW);
+ ut_ad(ref->n_fields <= index->n_uniq);
+ btr_pcur_open_at_index_side(true, index, mode, pcur, true, 0,
+ mtr);
+ btr_pcur_move_to_next_user_rec(pcur, mtr);
+ /* We do not necessarily have index->is_instant() here,
+ because we could be executing a rollback of an
+ instant ADD COLUMN operation. The function
+ rec_is_default_row() asserts index->is_instant();
+ we do not want to call it here. */
+ return rec_get_info_bits(btr_pcur_get_rec(pcur),
+ dict_table_is_comp(index->table))
+ & REC_INFO_MIN_REC_FLAG;
+ } else {
+ ut_a(ref->n_fields == index->n_uniq);
+ btr_pcur_open(index, ref, PAGE_CUR_LE, mode, pcur, mtr);
+ }
low_match = btr_pcur_get_low_match(pcur);
@@ -1227,6 +1273,8 @@ row_raw_format(
ulint ret;
ibool format_in_hex;
+ ut_ad(data_len != UNIV_SQL_DEFAULT);
+
if (buf_size == 0) {
return(0);
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 08cce51a503..ad583393d23 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -242,7 +242,7 @@ row_sel_sec_rec_is_for_clust_rec(
clust_field = static_cast<byte*>(vfield->data);
} else {
clust_pos = dict_col_get_clust_pos(col, clust_index);
-
+ ut_ad(!rec_offs_nth_default(clust_offs, clust_pos));
clust_field = rec_get_nth_field(
clust_rec, clust_offs, clust_pos, &clust_len);
}
@@ -517,7 +517,6 @@ row_sel_fetch_columns(
rec, offsets,
dict_table_page_size(index->table),
field_no, &len, heap);
- //field_no, &len, heap, NULL);
/* data == NULL means that the
externally stored field was not
@@ -534,9 +533,8 @@ row_sel_fetch_columns(
needs_copy = TRUE;
} else {
- data = rec_get_nth_field(rec, offsets,
- field_no, &len);
-
+ data = rec_get_nth_cfield(rec, index, offsets,
+ field_no, &len);
needs_copy = column->copy_val;
}
@@ -1494,6 +1492,15 @@ row_sel_try_search_shortcut(
return(SEL_RETRY);
}
+ if (rec_is_default_row(rec, index)) {
+ /* Skip the 'default row' pseudo-record. */
+ if (!btr_pcur_move_to_next_user_rec(&plan->pcur, mtr)) {
+ return(SEL_RETRY);
+ }
+
+ rec = btr_pcur_get_rec(&plan->pcur);
+ }
+
ut_ad(plan->mode == PAGE_CUR_GE);
/* As the cursor is now placed on a user record after a search with
@@ -1820,6 +1827,12 @@ skip_lock:
goto next_rec;
}
+ if (rec_is_default_row(rec, index)) {
+ /* Skip the 'default row' pseudo-record. */
+ cost_counter++;
+ goto next_rec;
+ }
+
if (!consistent_read) {
/* Try to place a lock on the index record */
ulint lock_type;
@@ -3023,7 +3036,6 @@ row_sel_store_mysql_field_func(
rec, offsets,
dict_table_page_size(prebuilt->table),
field_no, &len, heap);
- //field_no, &len, heap, NULL);
if (UNIV_UNLIKELY(!data)) {
/* The externally stored field was not written
@@ -3050,9 +3062,19 @@ row_sel_store_mysql_field_func(
mem_heap_free(heap);
}
} else {
- /* Field is stored in the row. */
-
- data = rec_get_nth_field(rec, offsets, field_no, &len);
+ /* The field is stored in the index record, or
+ in the 'default row' for instant ADD COLUMN. */
+
+ if (rec_offs_nth_default(offsets, field_no)) {
+ ut_ad(dict_index_is_clust(index));
+ ut_ad(index->is_instant());
+ const dict_index_t* clust_index
+ = dict_table_get_first_index(prebuilt->table);
+ ut_ad(index == clust_index);
+ data = clust_index->instant_field_value(field_no,&len);
+ } else {
+ data = rec_get_nth_field(rec, offsets, field_no, &len);
+ }
if (len == UNIV_SQL_NULL) {
/* MySQL assumes that the field for an SQL
@@ -3586,7 +3608,12 @@ sel_restore_position_for_mysql(
case BTR_PCUR_ON:
if (!success && moves_up) {
next:
- btr_pcur_move_to_next(pcur, mtr);
+ if (btr_pcur_move_to_next(pcur, mtr)
+ && rec_is_default_row(btr_pcur_get_rec(pcur),
+ pcur->btr_cur.index)) {
+ btr_pcur_move_to_next(pcur, mtr);
+ }
+
return(TRUE);
}
return(!success);
@@ -3597,7 +3624,9 @@ next:
/* positioned to record after pcur->old_rec. */
pcur->pos_state = BTR_PCUR_IS_POSITIONED;
prev:
- if (btr_pcur_is_on_user_rec(pcur) && !moves_up) {
+ if (btr_pcur_is_on_user_rec(pcur) && !moves_up
+ && !rec_is_default_row(btr_pcur_get_rec(pcur),
+ pcur->btr_cur.index)) {
btr_pcur_move_to_prev(pcur, mtr);
}
return(TRUE);
@@ -3877,6 +3906,15 @@ row_sel_try_search_shortcut_for_mysql(
return(SEL_RETRY);
}
+ if (rec_is_default_row(rec, index)) {
+ /* Skip the 'default row' pseudo-record. */
+ if (!btr_pcur_move_to_next_user_rec(pcur, mtr)) {
+ return(SEL_RETRY);
+ }
+
+ rec = btr_pcur_get_rec(pcur);
+ }
+
/* As the cursor is now placed on a user record after a search with
the mode PAGE_CUR_GE, the up_match field in the cursor tells how many
fields in the user record matched to the search tuple */
@@ -4019,6 +4057,9 @@ row_sel_fill_vrow(
rec_offs_init(offsets_);
ut_ad(!(*vrow));
+ ut_ad(heap);
+ ut_ad(!dict_index_is_clust(index));
+ ut_ad(!index->is_instant());
ut_ad(page_rec_is_leaf(rec));
offsets = rec_get_offsets(rec, index, offsets, true,
@@ -4032,18 +4073,18 @@ row_sel_fill_vrow(
for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
const dict_field_t* field;
- const dict_col_t* col;
+ const dict_col_t* col;
field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(field);
if (dict_col_is_virtual(col)) {
const byte* data;
- ulint len;
+ ulint len;
data = rec_get_nth_field(rec, offsets, i, &len);
- const dict_v_col_t* vcol = reinterpret_cast<
+ const dict_v_col_t* vcol = reinterpret_cast<
const dict_v_col_t*>(col);
dfield_t* dfield = dtuple_get_nth_v_field(
@@ -4702,12 +4743,24 @@ rec_loop:
corruption */
if (comp) {
+ if (rec_get_info_bits(rec, true) & REC_INFO_MIN_REC_FLAG) {
+ /* Skip the 'default row' pseudo-record. */
+ ut_ad(index->is_instant());
+ goto next_rec;
+ }
+
next_offs = rec_get_next_offs(rec, TRUE);
if (UNIV_UNLIKELY(next_offs < PAGE_NEW_SUPREMUM)) {
goto wrong_offs;
}
} else {
+ if (rec_get_info_bits(rec, false) & REC_INFO_MIN_REC_FLAG) {
+ /* Skip the 'default row' pseudo-record. */
+ ut_ad(index->is_instant());
+ goto next_rec;
+ }
+
next_offs = rec_get_next_offs(rec, FALSE);
if (UNIV_UNLIKELY(next_offs < PAGE_OLD_SUPREMUM)) {
@@ -5979,6 +6032,9 @@ row_search_get_max_rec(
btr_pcur_close(&pcur);
+ ut_ad(!rec
+ || !(rec_get_info_bits(rec, dict_table_is_comp(index->table))
+ & (REC_INFO_MIN_REC_FLAG | REC_INFO_DELETED_FLAG)));
return(rec);
}
diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc
index 90e7aa08965..8d371f67e72 100644
--- a/storage/innobase/row/row0trunc.cc
+++ b/storage/innobase/row/row0trunc.cc
@@ -1950,16 +1950,11 @@ row_truncate_table_for_mysql(
return(row_truncate_complete(
table, trx, fsp_flags, logger, DB_ERROR));
}
- }
- DBUG_EXECUTE_IF("ib_trunc_crash_after_redo_log_write_complete",
- log_buffer_flush_to_disk();
- os_thread_sleep(3000000);
- DBUG_SUICIDE(););
-
- /* Step-9: Drop all indexes (free index pages associated with these
- indexes) */
- if (!dict_table_is_temporary(table)) {
+ DBUG_EXECUTE_IF("ib_trunc_crash_after_redo_log_write_complete",
+ log_buffer_flush_to_disk();
+ os_thread_sleep(3000000);
+ DBUG_SUICIDE(););
DropIndex dropIndex(table, no_redo);
@@ -1974,7 +1969,10 @@ row_truncate_table_for_mysql(
return(row_truncate_complete(
table, trx, fsp_flags, logger, err));
}
+
+ dict_table_get_first_index(table)->remove_instant();
} else {
+ ut_ad(!table->is_instant());
/* For temporary tables we don't have entries in SYSTEM TABLES*/
ut_ad(fsp_is_system_temporary(table->space));
for (dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
@@ -2108,6 +2106,8 @@ row_truncate_table_for_mysql(
trx_commit_for_mysql(trx);
}
+ ut_ad(!table->is_instant());
+
return(row_truncate_complete(table, trx, fsp_flags, logger, err));
}
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc
index b50b4e94cfb..6628007909e 100644
--- a/storage/innobase/row/row0uins.cc
+++ b/storage/innobase/row/row0uins.cc
@@ -78,6 +78,7 @@ row_undo_ins_remove_clust_rec(
mtr.start();
if (index->table->is_temporary()) {
+ ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
@@ -120,10 +121,11 @@ row_undo_ins_remove_clust_rec(
mem_heap_free(heap);
}
- if (node->table->id == DICT_INDEXES_ID) {
-
+ switch (node->table->id) {
+ case DICT_INDEXES_ID:
ut_ad(!online);
ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH);
+ ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
dict_drop_index_tree(
btr_pcur_get_rec(&node->pcur), &(node->pcur), &mtr);
@@ -135,6 +137,54 @@ row_undo_ins_remove_clust_rec(
success = btr_pcur_restore_position(
BTR_MODIFY_LEAF, &node->pcur, &mtr);
ut_a(success);
+ break;
+ case DICT_COLUMNS_ID:
+ /* This is rolling back an INSERT into SYS_COLUMNS.
+ If it was part of an instant ADD COLUMN operation, we
+ must modify the table definition. At this point, any
+ corresponding operation to the 'default row' will have
+ been rolled back. */
+ ut_ad(!online);
+ ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH);
+ ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
+ const rec_t* rec = btr_pcur_get_rec(&node->pcur);
+ if (rec_get_n_fields_old(rec)
+ != DICT_NUM_FIELDS__SYS_COLUMNS) {
+ break;
+ }
+ ulint len;
+ const byte* data = rec_get_nth_field_old(
+ rec, DICT_FLD__SYS_COLUMNS__TABLE_ID, &len);
+ if (len != 8) {
+ break;
+ }
+ const table_id_t table_id = mach_read_from_8(data);
+ data = rec_get_nth_field_old(rec, DICT_FLD__SYS_COLUMNS__POS,
+ &len);
+ if (len != 4) {
+ break;
+ }
+ const unsigned pos = mach_read_from_4(data);
+ if (pos == 0 || pos >= (1U << 16)) {
+ break;
+ }
+ dict_table_t* table = dict_table_open_on_id(
+ table_id, true, DICT_TABLE_OP_OPEN_ONLY_IF_CACHED);
+ if (!table) {
+ break;
+ }
+
+ dict_index_t* index = dict_table_get_first_index(table);
+
+ if (index && index->is_instant()
+ && DATA_N_SYS_COLS + 1 + pos == table->n_cols) {
+ /* This is the rollback of an instant ADD COLUMN.
+ Remove the column from the dictionary cache,
+ but keep the system columns. */
+ table->rollback_instant(pos);
+ }
+
+ dict_table_close(table, true, false);
}
if (btr_cur_optimistic_delete(btr_cur, 0, &mtr)) {
@@ -177,6 +227,27 @@ retry:
func_exit:
btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
+ if (err == DB_SUCCESS && node->rec_type == TRX_UNDO_INSERT_DEFAULT) {
+ /* When rolling back the very first instant ADD COLUMN
+ operation, reset the root page to the basic state. */
+ ut_ad(!index->table->is_temporary());
+ mtr.start();
+ if (page_t* root = btr_root_get(index, &mtr)) {
+ byte* page_type = root + FIL_PAGE_TYPE;
+ ut_ad(mach_read_from_2(page_type)
+ == FIL_PAGE_TYPE_INSTANT
+ || mach_read_from_2(page_type)
+ == FIL_PAGE_INDEX);
+ mtr.set_named_space(index->space);
+ mlog_write_ulint(page_type, FIL_PAGE_INDEX,
+ MLOG_2BYTES, &mtr);
+ byte* instant = PAGE_INSTANT + PAGE_HEADER + root;
+ mlog_write_ulint(instant,
+ page_ptr_get_direction(instant + 1),
+ MLOG_2BYTES, &mtr);
+ }
+ mtr.commit();
+ }
return(err);
}
@@ -340,7 +411,7 @@ row_undo_ins_parse_undo_rec(
ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &dummy,
&dummy_extern, &undo_no, &table_id);
- ut_ad(type == TRX_UNDO_INSERT_REC);
+ ut_ad(type == TRX_UNDO_INSERT_REC || type == TRX_UNDO_INSERT_DEFAULT);
node->rec_type = type;
node->update = NULL;
@@ -369,8 +440,14 @@ close_table:
clust_index = dict_table_get_first_index(node->table);
if (clust_index != NULL) {
- ptr = trx_undo_rec_get_row_ref(
- ptr, clust_index, &node->ref, node->heap);
+ if (type == TRX_UNDO_INSERT_REC) {
+ ptr = trx_undo_rec_get_row_ref(
+ ptr, clust_index, &node->ref,
+ node->heap);
+ } else {
+ ut_ad(type == TRX_UNDO_INSERT_DEFAULT);
+ node->ref = &trx_undo_default_rec;
+ }
if (!row_undo_search_clust_to_pcur(node)) {
/* An error probably occurred during
@@ -484,18 +561,28 @@ row_undo_ins(
node->index = dict_table_get_first_index(node->table);
ut_ad(dict_index_is_clust(node->index));
- /* Skip the clustered index (the first index) */
- node->index = dict_table_get_next_index(node->index);
- dict_table_skip_corrupt_index(node->index);
+ switch (node->rec_type) {
+ default:
+ ut_ad(!"wrong undo record type");
+ case TRX_UNDO_INSERT_REC:
+ /* Skip the clustered index (the first index) */
+ node->index = dict_table_get_next_index(node->index);
- err = row_undo_ins_remove_sec_rec(node, thr);
+ dict_table_skip_corrupt_index(node->index);
- if (err == DB_SUCCESS) {
+ err = row_undo_ins_remove_sec_rec(node, thr);
+
+ if (err != DB_SUCCESS) {
+ break;
+ }
+ /* fall through */
+ case TRX_UNDO_INSERT_DEFAULT:
log_free_check();
if (node->table->id == DICT_INDEXES_ID) {
+ ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
if (!dict_locked) {
mutex_enter(&dict_sys->mutex);
diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc
index 049b1048724..ecf6b76a593 100644
--- a/storage/innobase/row/row0umod.cc
+++ b/storage/innobase/row/row0umod.cc
@@ -1175,6 +1175,21 @@ close_table:
node->heap, &(node->update));
node->new_trx_id = trx_id;
node->cmpl_info = cmpl_info;
+ ut_ad(!node->ref->info_bits);
+
+ if (node->update->info_bits & REC_INFO_MIN_REC_FLAG) {
+ /* This must be an undo log record for a subsequent
+ instant ADD COLUMN on a table, extending the
+ 'default value' record. */
+ ut_ad(clust_index->is_instant());
+ if (node->update->info_bits != REC_INFO_MIN_REC_FLAG) {
+ ut_ad(!"wrong info_bits in undo log record");
+ goto close_table;
+ }
+ node->update->info_bits = REC_INFO_DEFAULT_ROW;
+ const_cast<dtuple_t*>(node->ref)->info_bits
+ = REC_INFO_DEFAULT_ROW;
+ }
if (!row_undo_search_clust_to_pcur(node)) {
/* As long as this rolling-back transaction exists,
@@ -1236,6 +1251,12 @@ row_undo_mod(
node->index = dict_table_get_first_index(node->table);
ut_ad(dict_index_is_clust(node->index));
+
+ if (node->ref->info_bits) {
+ ut_ad(node->ref->info_bits == REC_INFO_DEFAULT_ROW);
+ goto rollback_clust;
+ }
+
/* Skip the clustered index (the first index) */
node->index = dict_table_get_next_index(node->index);
@@ -1258,6 +1279,7 @@ row_undo_mod(
}
if (err == DB_SUCCESS) {
+rollback_clust:
err = row_undo_mod_clust(node, thr);
bool update_statistics
diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc
index 8826ebdd0cb..a1bb4cb7dbd 100644
--- a/storage/innobase/row/row0undo.cc
+++ b/storage/innobase/row/row0undo.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -225,10 +226,14 @@ row_undo_search_clust_to_pcur(
}
if (node->rec_type == TRX_UNDO_UPD_EXIST_REC) {
+ ut_ad(node->row->info_bits == REC_INFO_MIN_REC_FLAG
+ || node->row->info_bits == 0);
node->undo_row = dtuple_copy(node->row, node->heap);
row_upd_replace(node->undo_row, &node->undo_ext,
clust_index, node->update, node->heap);
} else {
+ ut_ad((node->row->info_bits == REC_INFO_MIN_REC_FLAG)
+ == (node->rec_type == TRX_UNDO_INSERT_DEFAULT));
node->undo_row = NULL;
node->undo_ext = NULL;
}
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 2eceef14025..2499aff2e2e 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -595,6 +595,7 @@ row_upd_changes_field_size_or_external(
new_val = &(upd_field->new_val);
new_len = dfield_get_len(new_val);
+ ut_ad(new_len != UNIV_SQL_DEFAULT);
if (dfield_is_null(new_val) && !rec_offs_comp(offsets)) {
/* A bug fixed on Dec 31st, 2004: we looked at the
@@ -697,6 +698,20 @@ row_upd_rec_in_place(
ut_ad(rec_offs_validate(rec, index, offsets));
if (rec_offs_comp(offsets)) {
+#ifdef UNIV_DEBUG
+ switch (rec_get_status(rec)) {
+ case REC_STATUS_ORDINARY:
+ break;
+ case REC_STATUS_COLUMNS_ADDED:
+ ut_ad(index->is_instant());
+ break;
+ case REC_STATUS_INFIMUM:
+ case REC_STATUS_SUPREMUM:
+ case REC_STATUS_NODE_PTR:
+ ut_ad(!"wrong record status in update");
+ }
+#endif /* UNIV_DEBUG */
+
rec_set_info_bits_new(rec, update->info_bits);
} else {
rec_set_info_bits_old(rec, update->info_bits);
@@ -978,6 +993,7 @@ row_upd_build_sec_rec_difference_binary(
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_n_fields(offsets) == dtuple_get_n_fields(entry));
ut_ad(!rec_offs_any_extern(offsets));
+ ut_ad(!rec_offs_any_default(offsets));
update = upd_create(dtuple_get_n_fields(entry), heap);
@@ -1076,8 +1092,7 @@ row_upd_build_difference_binary(
}
for (i = 0; i < n_fld; i++) {
-
- data = rec_get_nth_field(rec, offsets, i, &len);
+ data = rec_get_nth_cfield(rec, index, offsets, i, &len);
dfield = dtuple_get_nth_field(entry, i);
@@ -1308,41 +1323,25 @@ row_upd_index_replace_new_col_val(
}
}
-/***********************************************************//**
-Replaces the new column values stored in the update vector to the index entry
-given. */
+/** Apply an update vector to an index entry.
+@param[in,out] entry index entry to be updated; the clustered index record
+ must be covered by a lock or a page latch to prevent
+ deletion (rollback or purge)
+@param[in] index index of the entry
+@param[in] update update vector built for the entry
+@param[in,out] heap memory heap for copying off-page columns */
void
row_upd_index_replace_new_col_vals_index_pos(
-/*=========================================*/
- dtuple_t* entry, /*!< in/out: index entry where replaced;
- the clustered index record must be
- covered by a lock or a page latch to
- prevent deletion (rollback or purge) */
- dict_index_t* index, /*!< in: index; NOTE that this may also be a
- non-clustered index */
- const upd_t* update, /*!< in: an update vector built for the index so
- that the field number in an upd_field is the
- index position */
- ibool order_only,
- /*!< in: if TRUE, limit the replacement to
- ordering fields of index; note that this
- does not work for non-clustered indexes. */
- mem_heap_t* heap) /*!< in: memory heap for allocating and
- copying the new values */
+ dtuple_t* entry,
+ const dict_index_t* index,
+ const upd_t* update,
+ mem_heap_t* heap)
{
- ulint i;
- ulint n_fields;
const page_size_t& page_size = dict_table_page_size(index->table);
dtuple_set_info_bits(entry, update->info_bits);
- if (order_only) {
- n_fields = dict_index_get_n_unique(index);
- } else {
- n_fields = dict_index_get_n_fields(index);
- }
-
- for (i = 0; i < n_fields; i++) {
+ for (unsigned i = index->n_fields; i--; ) {
const dict_field_t* field;
const dict_col_t* col;
const upd_field_t* uf;
@@ -2045,16 +2044,19 @@ row_upd_copy_columns(
/*=================*/
rec_t* rec, /*!< in: record in a clustered index */
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ const dict_index_t* index, /*!< in: index of rec */
sym_node_t* column) /*!< in: first column in a column list, or
NULL */
{
- byte* data;
+ ut_ad(dict_index_is_clust(index));
+
+ const byte* data;
ulint len;
while (column) {
- data = rec_get_nth_field(rec, offsets,
- column->field_nos[SYM_CLUST_FIELD_NO],
- &len);
+ data = rec_get_nth_cfield(
+ rec, index, offsets,
+ column->field_nos[SYM_CLUST_FIELD_NO], &len);
eval_node_copy_and_alloc_val(column, data, len);
column = UT_LIST_GET_NEXT(col_var_list, column);
@@ -2588,6 +2590,7 @@ row_upd_clust_rec_by_insert_inherit_func(
#ifdef UNIV_DEBUG
if (UNIV_LIKELY(rec != NULL)) {
+ ut_ad(!rec_offs_nth_default(offsets, i));
const byte* rec_data
= rec_get_nth_field(rec, offsets, i, &len);
ut_ad(len == dfield_get_len(dfield));
@@ -2672,6 +2675,7 @@ row_upd_clust_rec_by_insert(
entry = row_build_index_entry_low(node->upd_row, node->upd_ext,
index, heap, ROW_BUILD_FOR_INSERT);
+ if (index->is_instant()) entry->trim(*index);
ut_ad(dtuple_get_info_bits(entry) == 0);
row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id);
@@ -3170,7 +3174,7 @@ row_upd_clust_step(
if (UNIV_UNLIKELY(!node->in_mysql_interface)) {
/* Copy the necessary columns from clust_rec and calculate the
new values to set */
- row_upd_copy_columns(rec, offsets,
+ row_upd_copy_columns(rec, offsets, index,
UT_LIST_GET_FIRST(node->columns));
row_upd_eval_new_vals(node->update);
}
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc
index a659042bb2f..8c9919511ad 100644
--- a/storage/innobase/row/row0vers.cc
+++ b/storage/innobase/row/row0vers.cc
@@ -1210,7 +1210,7 @@ row_vers_build_for_consistent_read(
in_heap, rec_offs_size(*offsets)));
*old_vers = rec_copy(buf, prev_version, *offsets);
- rec_offs_make_valid(*old_vers, index, *offsets);
+ rec_offs_make_valid(*old_vers, index, true, *offsets);
if (vrow && *vrow) {
*vrow = dtuple_copy(*vrow, in_heap);
@@ -1337,7 +1337,7 @@ committed_version_trx:
in_heap, rec_offs_size(*offsets)));
*old_vers = rec_copy(buf, version, *offsets);
- rec_offs_make_valid(*old_vers, index, *offsets);
+ rec_offs_make_valid(*old_vers, index, true, *offsets);
if (vrow && *vrow) {
*vrow = dtuple_copy(*vrow, in_heap);
dtuple_dup_v_fld(*vrow, in_heap);