Skip to content

Commit

Permalink
fix Bug : Query results more data stoneatom#282
Browse files Browse the repository at this point in the history
  • Loading branch information
swoapri committed Aug 12, 2022
1 parent 2dffcab commit 643e8e3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
41 changes: 40 additions & 1 deletion storage/tianmu/core/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ CondID Query::ConditionNumberFromMultipleEquality(Item_equal *conds, const TabID
}
while ((ifield = li++) != nullptr) {
if (!Item2CQTerm(ifield, next_term, tmp_table, filter_type)) return CondID(-1);
//cq->And(filter, tmp_table, next_term, common::Operator::O_EQ, zero_term);
if (!and_me_filter) {
if (is_or_subtree)
cq->Or(filter, tmp_table, next_term, common::Operator::O_EQ, zero_term);
Expand All @@ -1147,6 +1148,42 @@ CondID Query::ConditionNumberFromMultipleEquality(Item_equal *conds, const TabID
return filter;
}

CondID Query::ConditionNewNumberFromMultipleEquality(Item_equal *conds, const TabID &tmp_table, CondType filter_type,
CondID *and_me_filter, bool is_or_subtree) {
Item_equal_iterator li(*conds);

CQTerm zero_term, first_term, next_term;
Item_field *ifield;
Item *const_item = conds->get_const();
if (const_item) {
if (!Item2CQTerm(const_item, zero_term, tmp_table, filter_type)) return CondID(-1);
} else {
ifield = li++;
if (!Item2CQTerm(ifield, zero_term, tmp_table, filter_type)) return CondID(-1);
}
ifield = li++;
if (!Item2CQTerm(ifield, first_term, tmp_table, filter_type)) return CondID(-1);
CondID filter;
cq->CreateConds(filter, tmp_table, first_term, common::Operator::O_EQ, zero_term, CQTerm(),
is_or_subtree || filter_type == CondType::HAVING_COND);

while ((ifield = li++) != nullptr) {
if (!Item2CQTerm(ifield, next_term, tmp_table, filter_type)) return CondID(-1);
cq->And(filter, tmp_table, next_term, common::Operator::O_EQ, zero_term);
}

if (and_me_filter) {
if (is_or_subtree) {
cq->Or(*and_me_filter, tmp_table, filter);
} else {
cq->And(*and_me_filter, tmp_table, filter);
}
}

if (and_me_filter) filter = *and_me_filter;
return filter;
}

Item *Query::FindOutAboutNot(Item *it, bool &is_there_not) {
is_there_not = false;

Expand Down Expand Up @@ -1184,7 +1221,9 @@ CondID Query::ConditionNumberFromComparison(Item *conds, const TabID &tmp_table,
ExtractOperatorType(conds, op, negative, like_esc);
Item_func *cond_func = (Item_func *)conds;
if (op == common::Operator::O_MULT_EQUAL_FUNC)
return ConditionNumberFromMultipleEquality((Item_equal *)conds, tmp_table, filter_type, and_me_filter,
//return ConditionNumberFromMultipleEquality((Item_equal *)conds, tmp_table, filter_type, and_me_filter,
// is_or_subtree);
return ConditionNewNumberFromMultipleEquality((Item_equal *)conds, tmp_table, filter_type, and_me_filter,
is_or_subtree);
else if (op == common::Operator::O_NOT_FUNC) {
if (cond_func->arg_count != 1 || dynamic_cast<Item_in_optimizer *>(cond_func->arguments()[0]) == NULL)
Expand Down
6 changes: 6 additions & 0 deletions storage/tianmu/core/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ class Query final {
bool is_or_subtree = false);
CondID ConditionNumberFromMultipleEquality(Item_equal *conds, const TabID &tmp_table, CondType filter_type,
CondID *and_me_filter = 0, bool is_or_subtree = false);

CondID ConditionNewNumberFromMultipleEquality(Item_equal *conds, const TabID &tmp_table, CondType filter_type,
CondID *and_me_filter = 0, bool is_or_subtree = false);
// add by lsh
CondID ConditionNumberAndFromMultipleEquality(Item_equal *conds, const TabID &tmp_table, CondType filter_type,
CondID *and_me_filter = 0, bool is_or_subtree = false);
CondID ConditionNumberFromComparison(Item *conds, const TabID &tmp_table, CondType filter_type,
CondID *and_me_filter = 0, bool is_or_subtree = false, bool negative = false);

Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/handler/tianmu_handler_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ static MYSQL_SYSVAR_INT(insert_buffer_size, tianmu_sysvar_insert_buffer_size, PL
static MYSQL_THDVAR_INT(session_debug_level, PLUGIN_VAR_INT, "session debug level", NULL, debug_update, 3, 0, 5, 0);
static MYSQL_THDVAR_INT(control_trace, PLUGIN_VAR_OPCMDARG, "ini controltrace", NULL, trace_update, 0, 0, 100, 0);
static MYSQL_SYSVAR_INT(global_debug_level, tianmu_sysvar_global_debug_level, PLUGIN_VAR_INT, "global debug level",
NULL, NULL, 4, 0, 5, 0);
NULL, NULL, 5, 0, 5, 0);

static MYSQL_SYSVAR_INT(distinct_cache_size, tianmu_sysvar_distcache_size, PLUGIN_VAR_INT,
"Upper byte limit for GroupDistinctCache buffer", NULL, NULL, 64, 64, 256, 0);
Expand Down

0 comments on commit 643e8e3

Please sign in to comment.