@@ -6737,26 +6737,20 @@ int handler::check_duplicate_long_entries_update(const uchar *new_rec)
6737
6737
int handler::ha_check_overlaps (const uchar *old_data, const uchar* new_data)
6738
6738
{
6739
6739
DBUG_ASSERT (new_data);
6740
+ if (this != table->file )
6741
+ return 0 ;
6740
6742
if (!table_share->period .unique_keys )
6741
6743
return 0 ;
6742
6744
if (table->versioned () && !table->vers_end_field ()->is_max ())
6743
6745
return 0 ;
6744
6746
6745
- bool is_update= old_data != NULL ;
6746
- alloc_lookup_buffer ();
6747
- auto *record_buffer= lookup_buffer + table_share->max_unique_length
6748
- + table_share->null_fields ;
6749
- auto *handler= this ;
6750
- // handler->inited can be NONE on INSERT
6751
- if (handler->inited != NONE)
6752
- {
6753
- create_lookup_handler ();
6754
- handler= lookup_handler;
6747
+ const bool is_update= old_data != NULL ;
6748
+ uchar *record_buffer= lookup_buffer + table_share->max_unique_length
6749
+ + table_share->null_fields ;
6755
6750
6756
- // Needs to compare record refs later is old_row_found()
6757
- if (is_update)
6758
- position (old_data);
6759
- }
6751
+ // Needs to compare record refs later is old_row_found()
6752
+ if (is_update)
6753
+ position (old_data);
6760
6754
6761
6755
DBUG_ASSERT (!keyread_enabled ());
6762
6756
@@ -6780,11 +6774,11 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
6780
6774
continue ;
6781
6775
}
6782
6776
6783
- error= handler ->ha_index_init (key_nr, 0 );
6777
+ error= lookup_handler ->ha_index_init (key_nr, 0 );
6784
6778
if (error)
6785
6779
return error;
6786
6780
6787
- error= handler ->ha_start_keyread (key_nr);
6781
+ error= lookup_handler ->ha_start_keyread (key_nr);
6788
6782
DBUG_ASSERT (!error);
6789
6783
6790
6784
const uint period_field_length= key_info.key_part [key_parts - 1 ].length ;
@@ -6801,7 +6795,7 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
6801
6795
period_field_length);
6802
6796
6803
6797
/* Find row with period_end > (period_start of new_data) */
6804
- error = handler ->ha_index_read_map (record_buffer, lookup_buffer,
6798
+ error = lookup_handler ->ha_index_read_map (record_buffer, lookup_buffer,
6805
6799
key_part_map ((1 << (key_parts - 1 )) - 1 ),
6806
6800
HA_READ_AFTER_KEY);
6807
6801
@@ -6814,13 +6808,13 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
6814
6808
An assumption is made that during update we always have the last
6815
6809
fetched row in old_data. Therefore, comparing ref's is enough
6816
6810
*/
6817
- DBUG_ASSERT (handler != this );
6811
+ DBUG_ASSERT (lookup_handler != this );
6818
6812
DBUG_ASSERT (inited != NONE);
6819
- DBUG_ASSERT (ref_length == handler ->ref_length );
6813
+ DBUG_ASSERT (ref_length == lookup_handler ->ref_length );
6820
6814
6821
- handler ->position (record_buffer);
6822
- if (memcmp (ref, handler ->ref , ref_length) == 0 )
6823
- error= handler ->ha_index_next (record_buffer);
6815
+ lookup_handler ->position (record_buffer);
6816
+ if (memcmp (ref, lookup_handler ->ref , ref_length) == 0 )
6817
+ error= lookup_handler ->ha_index_next (record_buffer);
6824
6818
}
6825
6819
6826
6820
if (!error && table->check_period_overlaps (key_info, new_data, record_buffer))
@@ -6832,10 +6826,10 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
6832
6826
if (error == HA_ERR_FOUND_DUPP_KEY)
6833
6827
lookup_errkey= key_nr;
6834
6828
6835
- int end_error= handler ->ha_end_keyread ();
6829
+ int end_error= lookup_handler ->ha_end_keyread ();
6836
6830
DBUG_ASSERT (!end_error);
6837
6831
6838
- end_error= handler ->ha_index_end ();
6832
+ end_error= lookup_handler ->ha_index_end ();
6839
6833
if (!error && end_error)
6840
6834
error= end_error;
6841
6835
}
@@ -6919,7 +6913,7 @@ bool handler::prepare_for_row_logging()
6919
6913
int handler::prepare_for_insert ()
6920
6914
{
6921
6915
/* Preparation for unique of blob's */
6922
- if (table->s ->long_unique_table )
6916
+ if (table->s ->long_unique_table || table-> s -> period . unique_keys )
6923
6917
{
6924
6918
/*
6925
6919
When doing a scan we can't use the same handler to check
@@ -6941,9 +6935,8 @@ int handler::ha_write_row(const uchar *buf)
6941
6935
DBUG_ENTER (" handler::ha_write_row" );
6942
6936
DEBUG_SYNC_C (" ha_write_row_start" );
6943
6937
6944
- error= ha_check_overlaps (NULL , buf);
6945
- if (unlikely (error))
6946
- goto end;
6938
+ if ((error= ha_check_overlaps (NULL , buf)))
6939
+ DBUG_RETURN (error);
6947
6940
6948
6941
MYSQL_INSERT_ROW_START (table_share->db .str , table_share->table_name .str );
6949
6942
mark_trx_read_write ();
@@ -6976,7 +6969,6 @@ int handler::ha_write_row(const uchar *buf)
6976
6969
#endif /* WITH_WSREP */
6977
6970
}
6978
6971
6979
- end:
6980
6972
DEBUG_SYNC_C (" ha_write_row_end" );
6981
6973
DBUG_RETURN (error);
6982
6974
}
0 commit comments