Skip to content

Commit

Permalink
[CBRD-25164] Fix error in covered index query results using function …
Browse files Browse the repository at this point in the history
…indexes (#4881) (#5092)

http://jira.cubrid.org/browse/CBRD-25164

* Fix error in covered index query results using function indexes
* This problem occurs because the value is not properly obtained during the key filtering process.
* backport [CBRD-25164] Fix error in covered index query results using function indexes #4881
  • Loading branch information
ctshim authored Apr 8, 2024
1 parent 8681ae7 commit 08700a5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/query/query_evaluator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2824,6 +2824,8 @@ eval_key_filter (THREAD_ENTRY * thread_p, DB_VALUE * value, FILTER_INFO * filter
{
if (DB_VALUE_TYPE (value) == DB_TYPE_MIDXKEY)
{
int func_idx_col_id = filterp->func_idx_col_id;

midxkey = db_get_midxkey (value);

if (filterp->btree_num_attrs <= 0 || !filterp->btree_attr_ids || !midxkey)
Expand All @@ -2834,6 +2836,11 @@ eval_key_filter (THREAD_ENTRY * thread_p, DB_VALUE * value, FILTER_INFO * filter
prev_j_index = 0;
prev_j_ptr = NULL;

if (func_idx_col_id == -1)
{
func_idx_col_id = filterp->btree_num_attrs + 1;
}

/* for all attributes specified in the filter */
for (i = 0; i < scan_attrsp->num_attrs; i++)
{
Expand All @@ -2859,13 +2866,9 @@ eval_key_filter (THREAD_ENTRY * thread_p, DB_VALUE * value, FILTER_INFO * filter
return V_ERROR;
}

if (filterp->func_idx_col_id != -1 && j > filterp->func_idx_col_id)
{
j = j + 1;
}

/* get j-th element value from the midxkey */
if (pr_midxkey_get_element_nocopy (midxkey, j, valp, &prev_j_index, &prev_j_ptr) != NO_ERROR)
if (pr_midxkey_get_element_nocopy (midxkey, ((j < func_idx_col_id) ? j : j + 1),
valp, &prev_j_index, &prev_j_ptr) != NO_ERROR)
{
return V_ERROR;
}
Expand Down

0 comments on commit 08700a5

Please sign in to comment.