Skip to content

Commit

Permalink
[CBRD-25708] temporary implementation of partition pruning for compos…
Browse files Browse the repository at this point in the history
…ite IN conditions
  • Loading branch information
Hamkua committed Dec 23, 2024
1 parent ffc2c02 commit a006090
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/query/partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "xasl.h"
#include "xasl_predicate.hpp"
#include "xasl_unpack_info.hpp"
#include "set_object.h"
// XXX: SHOULD BE THE LAST INCLUDE HEADER
#include "memory_wrapper.hpp"

Expand Down Expand Up @@ -1975,12 +1976,50 @@ partition_match_pred_expr (PRUNING_CONTEXT * pinfo, const PRED_EXPR * pr, PRUNIN
/* see if part_expr matches right or left */
REGU_VARIABLE *left, *right;
PRUNING_OP op;
REGU_VARIABLE *seq_var;
REGU_VARIABLE_LIST seq_list;

left = pr->pe.m_eval_term.et.et_comp.lhs;
right = pr->pe.m_eval_term.et.et_comp.rhs;
op = partition_rel_op_to_pruning_op (pr->pe.m_eval_term.et.et_comp.rel_op);

status = MATCH_NOT_FOUND;
if (partition_do_regu_variables_match (pinfo, left, part_expr))

/* TODO: This is a temporary implementation for sequence handling. */
if ((left->type == TYPE_FUNC || right->type == TYPE_FUNC) && part_expr->type == TYPE_ATTR_ID)
{
if ((left->type == TYPE_FUNC && left->value.funcp->ftype == F_SEQUENCE) ||
(right->type == TYPE_FUNC && right->value.funcp->ftype == F_SEQUENCE))
{
seq_var = (left->type == TYPE_FUNC) ? left : right;
seq_list = seq_var->value.funcp->operand;
int i = 0;

while (seq_list != NULL)
{
// TODO: Need to verify if the value is constant
seq_var = &seq_list->value;
if (seq_var->value.attr_descr.id == part_expr->value.attr_descr.id)
{
break;
}
i++;
seq_list = seq_list->next;
}

if (seq_list == NULL)
{
/* Attribute not found in sequence */
// pinfo->error_code = ER_FAILED;
status = MATCH_NOT_FOUND;
break;
}

DB_VALUE *val = (left->type == TYPE_FUNC) ? &right->value.dbval : &left->value.dbval;
status = partition_prune_db_val (pinfo, val->data.set->set->array[i], op, pruned);
}
}
else if (partition_do_regu_variables_match (pinfo, left, part_expr))
{
status = partition_prune (pinfo, right, op, pruned);
}
Expand Down

0 comments on commit a006090

Please sign in to comment.