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

MDEV-35793: Server crashes in Item_func_vec_distance_common::get_const_arg

The problem was caused by this scenario: The query had both SELECT DISTINCT
and ORDER BY. DISTINCT was converted into GROUP BY. Then, vector index was
used to resolve the GROUP BY.
When join_read_first() initialized vector index scan, it used the ORDER BY
clause instead of GROUP BY, which caused a crash.

Fixed by making test_if_skip_sort_order() remember which ordering the scan
produces in JOIN_TAB::full_index_scan_order, and join_read_first() using that.
This commit is contained in:
Oleksandr Byelkin
2025-01-17 08:42:17 +01:00
parent 9171ef3faf
commit 195dcfec6f
4 changed files with 38 additions and 3 deletions

View File

@@ -556,6 +556,13 @@ typedef struct st_join_table {
/** HAVING condition for checking prior saving a record into tmp table*/
Item *having;
/**
Ordering to be produced when doing full index scan.
Important for vector indexes, set by test_if_skip_sort_order() when it
decides to use full index to produce rows in order.
*/
ORDER *full_index_scan_order;
/** TRUE <=> remove duplicates on this table. */
bool distinct;