From 643e8e3adf810e9343f530d7d578ccffea4ec7a8 Mon Sep 17 00:00:00 2001 From: lishaohui Date: Fri, 12 Aug 2022 07:17:13 +0000 Subject: [PATCH] fix Bug : Query results more data #282 --- storage/tianmu/core/query.cpp | 41 ++++++++++++++++++- storage/tianmu/core/query.h | 6 +++ storage/tianmu/handler/tianmu_handler_com.cpp | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/storage/tianmu/core/query.cpp b/storage/tianmu/core/query.cpp index 4810d3c727..eb04d6fb2b 100644 --- a/storage/tianmu/core/query.cpp +++ b/storage/tianmu/core/query.cpp @@ -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); @@ -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; @@ -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(cond_func->arguments()[0]) == NULL) diff --git a/storage/tianmu/core/query.h b/storage/tianmu/core/query.h index 8ef6db85bb..dc9146f3f5 100644 --- a/storage/tianmu/core/query.h +++ b/storage/tianmu/core/query.h @@ -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); diff --git a/storage/tianmu/handler/tianmu_handler_com.cpp b/storage/tianmu/handler/tianmu_handler_com.cpp index 70c0a1d982..dc8ebd5ca7 100644 --- a/storage/tianmu/handler/tianmu_handler_com.cpp +++ b/storage/tianmu/handler/tianmu_handler_com.cpp @@ -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);