diff options
Diffstat (limited to 'storage/innobase/data/data0data.cc')
-rw-r--r-- | storage/innobase/data/data0data.cc | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc index 7fb0eae611c..6601edfec9d 100644 --- a/storage/innobase/data/data0data.cc +++ b/storage/innobase/data/data0data.cc @@ -42,6 +42,39 @@ to data_error. */ byte data_error; #endif /* UNIV_DEBUG */ +/** Trim the tail of an index tuple before insert or update. +After instant ADD COLUMN, if the last fields of a clustered index tuple +match the 'default row', there will be no need to store them. +NOTE: A page latch in the index must be held, so that the index +may not lose 'instantness' before the trimmed tuple has been +inserted or updated. +@param[in] index index possibly with instantly added columns */ +void dtuple_t::trim(const dict_index_t& index) +{ + ut_ad(n_fields >= index.n_core_fields); + ut_ad(n_fields <= index.n_fields); + ut_ad(index.is_instant()); + + ulint i = n_fields; + for (; i > index.n_core_fields; i--) { + const dfield_t* dfield = dtuple_get_nth_field(this, i - 1); + const dict_col_t* col = dict_index_get_nth_col(&index, i - 1); + ut_ad(col->is_instant()); + ulint len = dfield_get_len(dfield); + if (len != col->def_val.len) { + break; + } + + if (len != 0 && len != UNIV_SQL_NULL + && dfield->data != col->def_val.data + && memcmp(dfield->data, col->def_val.data, len)) { + break; + } + } + + n_fields = i; +} + /** Compare two data tuples. @param[in] tuple1 first data tuple @param[in] tuple2 second data tuple @@ -574,7 +607,7 @@ dtuple_convert_big_rec( return(NULL); } - if (dict_table_get_format(index->table) < UNIV_FORMAT_B) { + if (!dict_table_has_atomic_blobs(index->table)) { /* up to MySQL 5.1: store a 768-byte prefix locally */ local_len = BTR_EXTERN_FIELD_REF_SIZE + DICT_ANTELOPE_MAX_INDEX_COL_LEN; @@ -813,6 +846,7 @@ dfield_t::clone(mem_heap_t* heap) const dfield_t* obj = static_cast<dfield_t*>( mem_heap_alloc(heap, sizeof(dfield_t) + size)); + ut_ad(len != UNIV_SQL_DEFAULT); obj->ext = ext; obj->len = len; obj->type = type; |