Skip to content

Commit 926b339

Browse files
committed
MDEV-35194 non-BNL join fails on assertion
with streaming implemened mhnsw no longer needs to know the LIMIT in advance. let's just cap it to avoid allocating too much memory for the one step result set
1 parent 597e34d commit 926b339

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

mysql-test/main/vector2.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,19 @@ v
254254
UUUU
255255
VVVV
256256
drop table t;
257+
#
258+
# MDEV-35194 non-BNL join fails on assertion
259+
#
260+
create table t1 (pk int primary key, a vector(2) not null, vector(a));
261+
insert into t1 select seq, vec_fromtext(json_array(seq, -seq)) from seq_1_to_1000;
262+
create table t2 (f int);
263+
insert into t2 select seq from seq_1_to_1000;
264+
set join_cache_level= 0;
265+
select t2.f from t1 left join t2 on (t1.pk=t2.f) order by vec_distance_euclidean(t1.a,0x00000040) limit 5;
266+
f
267+
1
268+
2
269+
3
270+
4
271+
5
272+
drop table t1, t2;

mysql-test/main/vector2.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,14 @@ create table t (v vector(1));
196196
insert into t values (0x55555555),(0x56565656);
197197
select distinct v from t;
198198
drop table t;
199+
200+
--echo #
201+
--echo # MDEV-35194 non-BNL join fails on assertion
202+
--echo #
203+
create table t1 (pk int primary key, a vector(2) not null, vector(a));
204+
insert into t1 select seq, vec_fromtext(json_array(seq, -seq)) from seq_1_to_1000;
205+
create table t2 (f int);
206+
insert into t2 select seq from seq_1_to_1000;
207+
set join_cache_level= 0;
208+
select t2.f from t1 left join t2 on (t1.pk=t2.f) order by vec_distance_euclidean(t1.a,0x00000040) limit 5;
209+
drop table t1, t2;

sql/sql_select.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25150,7 +25150,6 @@ join_read_first(JOIN_TAB *tab)
2515025150
DBUG_ASSERT(tab->sorted);
2515125151
DBUG_ASSERT(tab->join->order);
2515225152
DBUG_ASSERT(tab->join->order->next == NULL);
25153-
DBUG_ASSERT(tab->join->select_limit < HA_POS_ERROR);
2515425153
tab->read_record.read_record_func= join_hlindex_read_next;
2515525154
error= tab->table->hlindex_read_first(tab->index, *tab->join->order->item,
2515625155
tab->join->select_limit);

sql/vector_mhnsw.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,8 @@ int mhnsw_read_first(TABLE *table, KEY *keyinfo, Item *dist, ulonglong limit)
12421242
auto *fun= static_cast<Item_func_vec_distance_common*>(dist->real_item());
12431243
DBUG_ASSERT(fun);
12441244

1245+
limit= std::min<ulonglong>(limit, max_ef);
1246+
12451247
String buf, *res= fun->get_const_arg()->val_str(&buf);
12461248
MHNSW_Share *ctx;
12471249

0 commit comments

Comments
 (0)