Skip to content

Commit 982535b

Browse files
committed
overflow/inf in vec_distance_euclidean
1 parent 9d3af2c commit 982535b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

mysql-test/main/vector2.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,13 @@ drop table t1;
489489
#
490490
create table t1(v vector (16384) not null,vector (v));
491491
ERROR 42000: Column length too big for column 'v' (max = 16383); use BLOB or TEXT instead
492+
#
493+
# overflow/inf in vec_distance_euclidean
494+
#
495+
select vec_totext(0x03CA397B);
496+
vec_totext(0x03CA397B)
497+
[9.64672e35]
498+
select vec_distance_euclidean(0x03CA397B, vec_fromtext('[0]'));
499+
vec_distance_euclidean(0x03CA397B, vec_fromtext('[0]'))
500+
9.64672e35
492501
# End of 11.8 tests

mysql-test/main/vector2.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,11 @@ drop table t1;
361361
--error ER_TOO_BIG_FIELDLENGTH
362362
create table t1(v vector (16384) not null,vector (v));
363363

364+
--echo #
365+
--echo # overflow/inf in vec_distance_euclidean
366+
--echo #
367+
select vec_totext(0x03CA397B);
368+
--replace_regex /(\.\d{5})\d+/\1/
369+
select vec_distance_euclidean(0x03CA397B, vec_fromtext('[0]'));
370+
364371
--echo # End of 11.8 tests

sql/item_vectorfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static double calc_distance_euclidean(float *v1, float *v2, size_t v_len)
2929
double d= 0;
3030
for (size_t i= 0; i < v_len; i++, v1++, v2++)
3131
{
32-
float dist= get_float(v1) - get_float(v2);
32+
double dist= get_float(v1) - get_float(v2);
3333
d+= dist * dist;
3434
}
3535
return sqrt(d);

0 commit comments

Comments
 (0)