1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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
This commit is contained in:
Sergei Golubchik
2024-10-19 20:33:57 +02:00
parent 597e34d000
commit 926b339b93
4 changed files with 29 additions and 1 deletions

View File

@@ -254,3 +254,19 @@ v
UUUU UUUU
VVVV VVVV
drop table t; drop table t;
#
# MDEV-35194 non-BNL join fails on assertion
#
create table t1 (pk int primary key, a vector(2) not null, vector(a));
insert into t1 select seq, vec_fromtext(json_array(seq, -seq)) from seq_1_to_1000;
create table t2 (f int);
insert into t2 select seq from seq_1_to_1000;
set join_cache_level= 0;
select t2.f from t1 left join t2 on (t1.pk=t2.f) order by vec_distance_euclidean(t1.a,0x00000040) limit 5;
f
1
2
3
4
5
drop table t1, t2;

View File

@@ -196,3 +196,14 @@ create table t (v vector(1));
insert into t values (0x55555555),(0x56565656); insert into t values (0x55555555),(0x56565656);
select distinct v from t; select distinct v from t;
drop table t; drop table t;
--echo #
--echo # MDEV-35194 non-BNL join fails on assertion
--echo #
create table t1 (pk int primary key, a vector(2) not null, vector(a));
insert into t1 select seq, vec_fromtext(json_array(seq, -seq)) from seq_1_to_1000;
create table t2 (f int);
insert into t2 select seq from seq_1_to_1000;
set join_cache_level= 0;
select t2.f from t1 left join t2 on (t1.pk=t2.f) order by vec_distance_euclidean(t1.a,0x00000040) limit 5;
drop table t1, t2;

View File

@@ -25150,7 +25150,6 @@ join_read_first(JOIN_TAB *tab)
DBUG_ASSERT(tab->sorted); DBUG_ASSERT(tab->sorted);
DBUG_ASSERT(tab->join->order); DBUG_ASSERT(tab->join->order);
DBUG_ASSERT(tab->join->order->next == NULL); DBUG_ASSERT(tab->join->order->next == NULL);
DBUG_ASSERT(tab->join->select_limit < HA_POS_ERROR);
tab->read_record.read_record_func= join_hlindex_read_next; tab->read_record.read_record_func= join_hlindex_read_next;
error= tab->table->hlindex_read_first(tab->index, *tab->join->order->item, error= tab->table->hlindex_read_first(tab->index, *tab->join->order->item,
tab->join->select_limit); tab->join->select_limit);

View File

@@ -1242,6 +1242,8 @@ int mhnsw_read_first(TABLE *table, KEY *keyinfo, Item *dist, ulonglong limit)
auto *fun= static_cast<Item_func_vec_distance_common*>(dist->real_item()); auto *fun= static_cast<Item_func_vec_distance_common*>(dist->real_item());
DBUG_ASSERT(fun); DBUG_ASSERT(fun);
limit= std::min<ulonglong>(limit, max_ef);
String buf, *res= fun->get_const_arg()->val_str(&buf); String buf, *res= fun->get_const_arg()->val_str(&buf);
MHNSW_Share *ctx; MHNSW_Share *ctx;