revision-id: 8ab9f5e7d5df9b602950733e8416e6e2711f01f6 (mariadb-10.4.11-89-g8ab9f5e7d5d) parent(s): 92fa873fabfe28dc845b8384fe332a8e784d7f6f author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-03-11 14:04:12 +0300 message: Fix compile warning/error about ha_rows and double error: implicit conversion from 'ha_rows' (aka 'unsigned long long') to 'double' changes value from 18446744073709551615 to 18446744073709551616 Make _mi_record_pos follow calling convention of _mi_search_pos: return -1 for error --- storage/myisam/mi_range.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index 25c79b9789f..a0f1743840a 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -102,12 +102,13 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, end_pos= (max_key ? _mi_record_pos(info, max_key->key, max_key->keypart_map, max_key->flag) : (double) info->state->records); - res= (end_pos < start_pos ? (ha_rows) 0 : - (end_pos == start_pos ? (ha_rows) 1 : (ha_rows) (end_pos-start_pos))); - if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR) - res=HA_POS_ERROR; + if (start_pos < 0 || end_pos < 0) + res= HA_POS_ERROR; else { + res= (end_pos < start_pos ? (ha_rows) 0 : + (end_pos == start_pos ? (ha_rows) 1 : (ha_rows) (end_pos- + start_pos))); diff= end_pos - start_pos; if (diff >= 0) { @@ -142,7 +143,13 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, */ -/* Find relative position (in records) for key in index-tree */ +/* + Find relative position (in records) for key in index-tree + + @return + position + -1.0 for error +*/ static double _mi_record_pos(MI_INFO *info, const uchar *key, key_part_map keypart_map, @@ -208,7 +215,7 @@ static double _mi_record_pos(MI_INFO *info, const uchar *key, DBUG_PRINT("exit",("pos: %g",(pos*info->state->records))); DBUG_RETURN(pos*info->state->records); } - DBUG_RETURN((double) (HA_POS_ERROR)); + DBUG_RETURN(-1.0); }