| 8290 | |
| 8291 | |
| 8292 | int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data) |
| 8293 | { |
| 8294 | DBUG_ASSERT(new_data); |
| 8295 | DBUG_ASSERT(this == table->file); |
| 8296 | if (!table_share->period.unique_keys) |
| 8297 | return 0; |
| 8298 | if (table->versioned()) |
| 8299 | { |
| 8300 | Field *end= table->vers_end_field(); |
| 8301 | if (!end->is_max(end->ptr_in_record(new_data))) |
| 8302 | return 0; |
| 8303 | } |
| 8304 | |
| 8305 | const bool after_write= ha_table_flags() & HA_CHECK_UNIQUE_AFTER_WRITE; |
| 8306 | const bool is_update= !after_write && old_data; |
| 8307 | uchar *record_buffer= lookup_buffer + table_share->max_unique_length |
| 8308 | + table_share->null_fields; |
| 8309 | |
| 8310 | // Needed to compare record refs later |
| 8311 | if (is_update) |
| 8312 | position(old_data); |
| 8313 | |
| 8314 | DBUG_ASSERT(!keyread_enabled()); |
| 8315 | |
| 8316 | int error= 0; |
| 8317 | lookup_errkey= (uint)-1; |
| 8318 | |
| 8319 | for (uint key_nr= 0; key_nr < table_share->keys && !error; key_nr++) |
| 8320 | { |
| 8321 | const KEY &key_info= table->key_info[key_nr]; |
| 8322 | const uint key_parts= key_info.user_defined_key_parts; |
| 8323 | if (!key_info.without_overlaps) |
| 8324 | continue; |
| 8325 | |
| 8326 | if (is_update) |
| 8327 | { |
| 8328 | bool key_used= false; |
| 8329 | for (uint k= 0; k < key_parts && !key_used; k++) |
| 8330 | key_used= bitmap_is_set(table->write_set, |
| 8331 | key_info.key_part[k].fieldnr - 1); |
| 8332 | if (!key_used) |
| 8333 | continue; |
| 8334 | } |
| 8335 | |
| 8336 | error= lookup_handler->ha_index_init(key_nr, 0); |
| 8337 | if (error) |
| 8338 | return error; |
| 8339 | |
| 8340 | error= lookup_handler->ha_start_keyread(key_nr); |
| 8341 | DBUG_ASSERT(!error); |
| 8342 | |
| 8343 | const uint period_field_length= key_info.key_part[key_parts - 1].length; |
| 8344 | const uint key_base_length= key_info.key_length - 2 * period_field_length; |
| 8345 | |
| 8346 | key_copy(lookup_buffer, new_data, &key_info, 0); |
| 8347 | |
| 8348 | /* Copy period_start to period_end. |
| 8349 | the value in period_start field is not significant, but anyway let's leave |
nothing calls this directly
no test coverage detected