File tree Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -369,3 +369,21 @@ vec_totext(v)
369
369
[7]
370
370
[6]
371
371
drop table t;
372
+ #
373
+ # MDEV-35768 Vector key is not used upon selecting from views / subqueries
374
+ #
375
+ create table t (b vector(1) not null, vector(b));
376
+ insert into t values (0x31313131),(0x32323232);
377
+ create view v as select * from t;
378
+ explain select * from t order by vec_distance_euclidean(b,0x30303030) limit 1;
379
+ id select_type table type possible_keys key key_len ref rows Extra
380
+ 1 SIMPLE t index NULL b 6 NULL 1
381
+ explain select * from v order by vec_distance_euclidean(b,0x30303030) limit 1;
382
+ id select_type table type possible_keys key key_len ref rows Extra
383
+ 1 SIMPLE t index NULL b 6 NULL 1
384
+ explain select * from (select * from t) sq order by vec_distance_euclidean(b,0x30303030) limit 1;
385
+ id select_type table type possible_keys key key_len ref rows Extra
386
+ 1 SIMPLE t index NULL b 6 NULL 1
387
+ drop view v;
388
+ drop table t;
389
+ # End of 11.7 tests
Original file line number Diff line number Diff line change @@ -265,3 +265,18 @@ create table t (v vector(1) not null, vector(v));
265
265
insert into t select vec_fromtext(concat('[',seq,']')) FROM seq_1_to_10;
266
266
select vec_totext(v) from t order by vec_distance_euclidean(v,vec_fromtext('[0]')) desc limit 5;
267
267
drop table t;
268
+
269
+ --echo #
270
+ --echo # MDEV-35768 Vector key is not used upon selecting from views / subqueries
271
+ --echo #
272
+
273
+ create table t (b vector(1) not null, vector(b));
274
+ insert into t values (0x31313131),(0x32323232);
275
+ create view v as select * from t;
276
+ explain select * from t order by vec_distance_euclidean(b,0x30303030) limit 1;
277
+ explain select * from v order by vec_distance_euclidean(b,0x30303030) limit 1;
278
+ explain select * from (select * from t) sq order by vec_distance_euclidean(b,0x30303030) limit 1;
279
+ drop view v;
280
+ drop table t;
281
+
282
+ --echo # End of 11.7 tests
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ class Item_func_vec_distance_common: public Item_real_func
26
26
{
27
27
Item_field *get_field_arg () const
28
28
{
29
- if (args[0 ]->type () == Item::FIELD_ITEM && args[1 ]->const_item ())
30
- return (Item_field*)(args[0 ]);
31
- if (args[1 ]->type () == Item::FIELD_ITEM && args[0 ]->const_item ())
32
- return (Item_field*)(args[1 ]);
29
+ if (args[0 ]->real_item ()-> type () == Item::FIELD_ITEM && args[1 ]->const_item ())
30
+ return (Item_field*)(args[0 ]-> real_item () );
31
+ if (args[1 ]->real_item ()-> type () == Item::FIELD_ITEM && args[0 ]->const_item ())
32
+ return (Item_field*)(args[1 ])-> real_item () ;
33
33
return NULL ;
34
34
}
35
35
bool check_arguments () const override
You can’t perform that action at this time.
0 commit comments