[FEAT MERGE]4_1_sql_feature

Co-authored-by: leslieyuchen <leslieyuchen@gmail.com>
Co-authored-by: Charles0429 <xiezhenjiang@gmail.com>
Co-authored-by: raywill <hustos@gmail.com>
This commit is contained in:
obdev
2023-01-28 16:01:26 +08:00
committed by ob-robot
parent 3080f2b66f
commit 2d19a9d8f5
846 changed files with 161957 additions and 116661 deletions

View File

@ -15,6 +15,7 @@
#include "lib/utility/ob_unify_serialize.h"
#include "sql/optimizer/ob_log_plan.h"
#include "common/ob_smart_call.h"
#include "sql/monitor/ob_sql_plan.h"
namespace oceanbase
{
@ -328,12 +329,12 @@ int ObGlobalHint::assign(const ObGlobalHint &other)
// hints below not print
// MAX_CONCURRENT
// ObDDLSchemaVersionHint
int ObGlobalHint::print_global_hint(planText &plan_text) const
int ObGlobalHint::print_global_hint(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
const char* outline_indent = ObQueryHint::get_outline_indent(plan_text.is_oneline_);
#define PRINT_GLOBAL_HINT_STR(hint_str) \
@ -436,7 +437,7 @@ int ObGlobalHint::print_global_hint(planText &plan_text) const
}
}
// OPTIMIZER_FEATURES_ENABLE
if (OB_SUCC(ret) && (has_valid_opt_features_version() || OUTLINE_DATA == plan_text.outline_type_)) {
if (OB_SUCC(ret) && (has_valid_opt_features_version() || plan_text.is_outline_data_)) {
int64_t cur_pos = 0;
const uint64_t version = has_valid_opt_features_version()
? opt_features_version_ : CURRENT_OUTLINE_ENABLE_VERSION;
@ -470,13 +471,13 @@ void ObGlobalHint::merge_osg_hint(int8_t flag) {
osg_hint_.flags_ |= flag;
}
int ObOptimizerStatisticsGatheringHint::print_osg_hint(planText &plan_text) const
int ObOptimizerStatisticsGatheringHint::print_osg_hint(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
const char* outline_indent = ObQueryHint::get_outline_indent(plan_text.is_oneline_);
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if ((flags_ & OB_NO_OPT_STATS_GATHER)) {
PRINT_GLOBAL_HINT_STR("NO_GATHER_OPTIMIZER_STATISTICS");
}
@ -489,13 +490,13 @@ int ObOptimizerStatisticsGatheringHint::print_osg_hint(planText &plan_text) cons
return ret;
}
int ObGlobalHint::print_monitoring_hints(planText &plan_text) const
int ObGlobalHint::print_monitoring_hints(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!monitoring_ids_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
const char* outline_indent = ObQueryHint::get_outline_indent(plan_text.is_oneline_);
ObSEArray<uint64_t, 4> tracing_ids;
ObSEArray<uint64_t, 4> stat_ids;
@ -540,7 +541,7 @@ int ObGlobalHint::print_monitoring_hints(planText &plan_text) const
DEFINE_ENUM_FUNC(ObOptParamHint::OptParamType, opt_param, OPT_PARAM_TYPE_DEF, ObOptParamHint::);
int ObOptParamHint::print_opt_param_hint(planText &plan_text) const
int ObOptParamHint::print_opt_param_hint(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(param_types_.count() != param_vals_.count())) {
@ -549,9 +550,9 @@ int ObOptParamHint::print_opt_param_hint(planText &plan_text) const
} else if (param_types_.empty()) {
/* do nothing*/
} else {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
const char* outline_indent = ObQueryHint::get_outline_indent(plan_text.is_oneline_);
const char* param_name = NULL;
for (int64_t i = 0; OB_SUCC(ret) && i < param_types_.count(); ++i) {
@ -636,6 +637,16 @@ bool ObOptParamHint::is_param_val_valid(const OptParamType param_type, const ObO
is_valid = val.is_int() && (0 < val.get_int());
break;
}
case ENABLE_NEWSORT: {
is_valid = val.is_varchar() && (0 == val.get_varchar().case_compare("true")
|| 0 == val.get_varchar().case_compare("false"));
break;
}
case USE_PART_SORT_MGB: {
is_valid = val.is_varchar() && (0 == val.get_varchar().case_compare("true")
|| 0 == val.get_varchar().case_compare("false"));
break;
}
default:
LOG_TRACE("invalid opt param val", K(param_type), K(val));
break;
@ -678,9 +689,10 @@ int ObOptParamHint::has_enable_opt_param(const OptParamType param_type, bool &en
return ret;
}
int ObOptParamHint::get_bool_opt_param(const OptParamType param_type, bool &val) const
int ObOptParamHint::get_bool_opt_param(const OptParamType param_type, bool &val, bool &is_exists) const
{
int ret = OB_SUCCESS;
is_exists = false;
ObObj obj;
if (OB_FAIL(get_opt_param(param_type, obj))) {
LOG_WARN("fail to get rowsets_enabled opt_param", K(ret));
@ -691,10 +703,17 @@ int ObOptParamHint::get_bool_opt_param(const OptParamType param_type, bool &val)
LOG_WARN("param obj is invalid", K(ret), K(obj));
} else {
val = (0 == obj.get_varchar().case_compare("true"));
is_exists = true;
}
return ret;
}
int ObOptParamHint::get_bool_opt_param(const OptParamType param_type, bool &val) const
{
bool is_exists = false;
return get_bool_opt_param(param_type, val, is_exists);
}
int ObOptParamHint::get_integer_opt_param(const OptParamType param_type, int64_t &val) const
{
int ret = OB_SUCCESS;
@ -712,6 +731,19 @@ int ObOptParamHint::get_integer_opt_param(const OptParamType param_type, int64_t
return ret;
}
int ObOptParamHint::has_opt_param(const OptParamType param_type, bool &has_hint) const
{
int ret = OB_SUCCESS;
has_hint = false;
ObObj obj;
if (OB_FAIL(get_opt_param(param_type, obj))) {
LOG_WARN("fail to get rowsets_enabled opt_param", K(ret));
} else {
has_hint = !obj.is_nop_value();
}
return ret;
}
void ObOptParamHint::reset()
{
param_types_.reuse();
@ -837,13 +869,13 @@ const char* ObHint::get_hint_name(ObItemType type, bool is_enable_hint /* defaul
}
}
int ObHint::print_hint(planText &plan_text) const
int ObHint::print_hint(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
const ObHint *hint = USED_HINT == plan_text.outline_type_ ? get_orig_hint() : this;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
const ObHint *hint = plan_text.is_used_hint_ ? get_orig_hint() : this;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
int64_t old_pos1 = -1;
int64_t old_pos2 = -1;
if (OB_FAIL(BUF_PRINTF("%s%s(", ObQueryHint::get_outline_indent(plan_text.is_oneline_),
@ -864,7 +896,7 @@ int ObHint::print_hint(planText &plan_text) const
return ret;
}
int ObHint::print_hint_desc(planText &plan_text) const
int ObHint::print_hint_desc(PlanText &plan_text) const
{
UNUSED(plan_text);
return OB_SUCCESS;
@ -1068,12 +1100,12 @@ int ObViewMergeHint::assign(const ObViewMergeHint &other)
return ret;
}
int ObViewMergeHint::print_hint_desc(planText &plan_text) const
int ObViewMergeHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (!parent_qb_name_.empty() && !is_query_push_down_ &&
OB_FAIL(BUF_PRINTF("> \"%.*s\"", parent_qb_name_.length(), parent_qb_name_.ptr()))) {
LOG_WARN("fail to print parent qb name", K(ret));
@ -1094,13 +1126,13 @@ int ObOrExpandHint::assign(const ObOrExpandHint &other)
return ret;
}
int ObOrExpandHint::print_hint_desc(planText &plan_text) const
int ObOrExpandHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!expand_cond_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_FAIL(BUF_PRINTF("\'%.*s\'", expand_cond_.length(), expand_cond_.ptr()))) {
LOG_WARN("fail to print expand condition", K(ret));
}
@ -1193,13 +1225,13 @@ int ObCountToExistsHint::assign(const ObCountToExistsHint &other)
return ret;
}
int ObCountToExistsHint::print_hint_desc(planText &plan_text) const
int ObCountToExistsHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!qb_name_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int64_t i = 0; OB_SUCC(ret) && i < qb_name_list_.count(); ++i) {
ObString qb_name = qb_name_list_.at(i);
if (OB_FAIL(BUF_PRINTF("\"%.*s\"", qb_name.length(), qb_name.ptr()))) {
@ -1238,13 +1270,13 @@ int ObLeftToAntiHint::assign(const ObLeftToAntiHint &other)
return ret;
}
int ObLeftToAntiHint::print_hint_desc(planText &plan_text) const
int ObLeftToAntiHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!table_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int64_t i = 0; OB_SUCC(ret) && i < table_list_.count(); ++i) {
single_or_joined_table cur_table = table_list_.at(i);
if (cur_table.count() > 1 && OB_FAIL(BUF_PRINTF("("))) {
@ -1296,13 +1328,13 @@ int ObEliminateJoinHint::assign(const ObEliminateJoinHint &other)
return ret;
}
int ObEliminateJoinHint::print_hint_desc(planText &plan_text) const
int ObEliminateJoinHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!table_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int64_t i = 0; OB_SUCC(ret) && i < table_list_.count(); ++i) {
single_or_joined_table cur_table = table_list_.at(i);
if (cur_table.count() > 1 && OB_FAIL(BUF_PRINTF("("))) {
@ -1355,13 +1387,13 @@ int ObGroupByPlacementHint::assign(const ObGroupByPlacementHint &other)
return ret;
}
int ObGroupByPlacementHint::print_hint_desc(planText &plan_text) const
int ObGroupByPlacementHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!table_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int64_t i = 0; OB_SUCC(ret) && i < table_list_.count(); ++i) {
single_or_joined_table cur_table = table_list_.at(i);
if (cur_table.count() > 1 && OB_FAIL(BUF_PRINTF("("))) {
@ -1442,13 +1474,13 @@ int ObWinMagicHint::get_all_table_in_hint(ObIArray<ObTableInHint*> &all_tables)
return ret;
}
int ObWinMagicHint::print_hint_desc(planText &plan_text) const
int ObWinMagicHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!table_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_UNLIKELY(table_list_.count() < 2)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("table in hint count < 2", K(ret));
@ -1493,13 +1525,13 @@ int ObMaterializeHint::assign(const ObMaterializeHint &other)
return ret;
}
int ObMaterializeHint::print_hint_desc(planText &plan_text) const
int ObMaterializeHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!qb_name_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int i = 0; OB_SUCC(ret) && i < qb_name_list_.count(); ++i) {
if (OB_FAIL(BUF_PRINTF("("))) {
LOG_WARN("fail to print materialize hint", K(ret));
@ -1574,12 +1606,12 @@ int ObSemiToInnerHint::assign(const ObSemiToInnerHint &other)
return ret;
}
int ObSemiToInnerHint::print_hint_desc(planText &plan_text) const
int ObSemiToInnerHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (tables_.empty()) {
//do nothing
} else if (tables_.count() > 1 && OB_FAIL(BUF_PRINTF("("))) {
@ -1614,14 +1646,14 @@ int ObCoalesceSqHint::assign(const ObCoalesceSqHint &other)
return ret;
}
int ObCoalesceSqHint::print_hint_desc(planText &plan_text) const
int ObCoalesceSqHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (!qb_name_list_.empty()) {
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
for (int i = 0; OB_SUCC(ret) && i < qb_name_list_.count(); ++i) {
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int i = 0; i < qb_name_list_.count(); ++i) {
if (OB_FAIL(BUF_PRINTF("("))) {
LOG_WARN("fail to print coalesce sq hint", K(ret));
}
@ -1696,12 +1728,12 @@ int ObTableParallelHint::assign(const ObTableParallelHint &other)
return ret;
}
int ObTableParallelHint::print_hint_desc(planText &plan_text) const
int ObTableParallelHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_FAIL(table_.print_table_in_hint(plan_text))) {
LOG_WARN("fail to print table in hint", K(ret));
} else if (OB_FAIL(BUF_PRINTF(" %ld", parallel_))) {
@ -1724,12 +1756,12 @@ int ObIndexHint::assign(const ObIndexHint &other)
return ret;
}
int ObIndexHint::print_hint_desc(planText &plan_text) const
int ObIndexHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_FAIL(table_.print_table_in_hint(plan_text))) {
LOG_WARN("fail to print table in hint", K(ret));
} else if (T_FULL_HINT == hint_type_ || T_USE_DAS_HINT == hint_type_) {
@ -1752,13 +1784,13 @@ int ObJoinHint::assign(const ObJoinHint &other)
return ret;
}
int ObJoinHint::print_hint_desc(planText &plan_text) const
int ObJoinHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
const char* algo_str = get_dist_algo_str();
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_UNLIKELY(tables_.empty())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected join hint", K(ret));
@ -1794,16 +1826,19 @@ bool ObJoinHint::is_match_local_algo(JoinAlgo join_algo) const
const char *ObJoinHint::get_dist_algo_str(DistAlgo dist_algo)
{
switch (dist_algo) {
case DistAlgo::DIST_PARTITION_NONE: return "PARTITION NONE";
case DistAlgo::DIST_NONE_PARTITION: return "NONE PARTITION";
case DistAlgo::DIST_BC2HOST_NONE: return "BC2HOST NONE";
case DistAlgo::DIST_BROADCAST_NONE: return "BROADCAST NONE";
case DistAlgo::DIST_NONE_BROADCAST: return "NONE BROADCAST";
case DistAlgo::DIST_HASH_HASH: return "HASH HASH";
case DistAlgo::DIST_PULL_TO_LOCAL: return "LOCAL LOCAL";
case DistAlgo::DIST_PARTITION_WISE: return "NONE NONE";
case DistAlgo::DIST_NONE_ALL: return "NONE ALL";
case DistAlgo::DIST_ALL_NONE: return "ALL NONE";
case DistAlgo::DIST_PARTITION_NONE: return "PARTITION NONE";
case DistAlgo::DIST_NONE_PARTITION: return "NONE PARTITION";
case DistAlgo::DIST_BC2HOST_NONE: return "BC2HOST NONE";
case DistAlgo::DIST_BROADCAST_NONE: return "BROADCAST NONE";
case DistAlgo::DIST_NONE_BROADCAST: return "NONE BROADCAST";
case DistAlgo::DIST_HASH_HASH: return "HASH HASH";
case DistAlgo::DIST_HASH_NONE: return "HASH NONE";
case DistAlgo::DIST_NONE_HASH: return "NONE HASH";
case DistAlgo::DIST_PULL_TO_LOCAL: return "LOCAL LOCAL";
case DistAlgo::DIST_PARTITION_WISE: return "NONE NONE";
case DistAlgo::DIST_EXT_PARTITION_WISE: return "NONE NONE";
case DistAlgo::DIST_NONE_ALL: return "NONE ALL";
case DistAlgo::DIST_ALL_NONE: return "ALL NONE";
default: return NULL;
}
return NULL;
@ -1813,6 +1848,7 @@ int ObJoinFilterHint::assign(const ObJoinFilterHint &other)
{
int ret = OB_SUCCESS;
filter_table_ = other.filter_table_;
pushdown_filter_table_ = other.pushdown_filter_table_;
if (OB_FAIL(left_tables_.assign(other.left_tables_))) {
LOG_WARN("fail to assign left tables", K(ret));
} else if (OB_FAIL(ObOptHint::assign(other))) {
@ -1832,12 +1868,12 @@ int ObJoinFilterHint::get_all_table_in_hint(ObIArray<ObTableInHint*> &all_tables
return ret;
}
int ObJoinFilterHint::print_hint_desc(planText &plan_text) const
int ObJoinFilterHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_FAIL(filter_table_.print_table_in_hint(plan_text))) {
LOG_WARN("fail to print table in hint", K(ret));
} else if (!left_tables_.empty() && OB_FAIL(BUF_PRINTF(" "))) {
@ -1847,6 +1883,11 @@ int ObJoinFilterHint::print_hint_desc(planText &plan_text) const
LOG_WARN("failed to print join tables", K(ret));
} else if (left_tables_.count() > 1 && OB_FAIL(BUF_PRINTF(")"))) {
LOG_WARN("failed to print hint", K(ret));
} else if (has_pushdown_filter_table() && OB_FAIL(BUF_PRINTF(" "))) {
LOG_WARN("fail to print table in hint", K(ret));
} else if (has_pushdown_filter_table() &&
OB_FAIL(pushdown_filter_table_.print_table_in_hint(plan_text))) {
LOG_WARN("fail to print table in hint", K(ret));
}
return ret;
}
@ -1888,7 +1929,17 @@ int ObPQSetHint::set_pq_set_hint(const DistAlgo dist_algo,
dist_methods_.at(0) = T_DISTRIBUTE_NONE;
dist_methods_.at(1) = T_DISTRIBUTE_NONE;
break;
}
}
case DistAlgo::DIST_EXT_PARTITION_WISE: {
dist_methods_.at(0) = T_DISTRIBUTE_NONE;
dist_methods_.at(1) = T_DISTRIBUTE_NONE;
break;
}
case DistAlgo::DIST_SET_PARTITION_WISE: {
dist_methods_.at(0) = T_DISTRIBUTE_NONE;
dist_methods_.at(1) = T_DISTRIBUTE_NONE;
break;
}
case DistAlgo::DIST_NONE_ALL: {
dist_methods_.at(0) = T_DISTRIBUTE_NONE;
dist_methods_.at(1) = T_DISTRIBUTE_ALL;
@ -1908,18 +1959,28 @@ int ObPQSetHint::set_pq_set_hint(const DistAlgo dist_algo,
dist_methods_.at(0) = T_DISTRIBUTE_PARTITION;
dist_methods_.at(1) = T_DISTRIBUTE_NONE;
break;
}
case DistAlgo::DIST_HASH_NONE: {
dist_methods_.at(0) = T_DISTRIBUTE_HASH;
dist_methods_.at(1) = T_DISTRIBUTE_NONE;
break;
}
case DistAlgo::DIST_NONE_PARTITION: {
dist_methods_.at(0) = T_DISTRIBUTE_NONE;
dist_methods_.at(1) = T_DISTRIBUTE_PARTITION;
break;
}
}
case DistAlgo::DIST_NONE_HASH: {
dist_methods_.at(0) = T_DISTRIBUTE_NONE;
dist_methods_.at(1) = T_DISTRIBUTE_HASH;
break;
}
case DistAlgo::DIST_SET_RANDOM: {
dist_methods_.at(0) = T_DISTRIBUTE_RANDOM;
dist_methods_.at(1) = T_DISTRIBUTE_RANDOM;
dist_methods_.at(random_none_idx) = T_DISTRIBUTE_NONE;
break;
}
}
default : {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected dist algo", K(ret), K(dist_algo));
@ -1931,6 +1992,10 @@ int ObPQSetHint::set_pq_set_hint(const DistAlgo dist_algo,
method = T_DISTRIBUTE_NONE;
} else if (DistAlgo::DIST_PULL_TO_LOCAL == dist_algo) {
method = T_DISTRIBUTE_LOCAL;
} else if (DistAlgo::DIST_SET_PARTITION_WISE == dist_algo) {
method = T_DISTRIBUTE_NONE;
} else if (DistAlgo::DIST_EXT_PARTITION_WISE == dist_algo) {
method = T_DISTRIBUTE_NONE;
} else if (DistAlgo::DIST_SET_RANDOM == dist_algo) {
method = T_DISTRIBUTE_RANDOM;
} else {
@ -1949,12 +2014,12 @@ int ObPQSetHint::set_pq_set_hint(const DistAlgo dist_algo,
return ret;
}
int ObPQSetHint::print_hint_desc(planText &plan_text) const
int ObPQSetHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_UNLIKELY(false == is_valid_dist_methods(dist_methods_))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected pq set hint", K(ret));
@ -2003,6 +2068,10 @@ DistAlgo ObPQSetHint::get_dist_algo(const ObIArray<ObItemType> &dist_methods,
dist_algo = DistAlgo::DIST_PARTITION_NONE;
} else if (T_DISTRIBUTE_NONE == method1 && T_DISTRIBUTE_PARTITION == method2) {
dist_algo = DistAlgo::DIST_NONE_PARTITION;
} else if (T_DISTRIBUTE_HASH == method1 && T_DISTRIBUTE_NONE == method2) {
dist_algo = DistAlgo::DIST_HASH_NONE;
} else if (T_DISTRIBUTE_NONE == method1 && T_DISTRIBUTE_HASH == method2) {
dist_algo = DistAlgo::DIST_NONE_HASH;
} else if (T_DISTRIBUTE_NONE == method1 && T_DISTRIBUTE_RANDOM == method2) {
dist_algo = DistAlgo::DIST_SET_RANDOM;
random_none_idx = 0;
@ -2055,7 +2124,7 @@ const char *ObPQSetHint::get_dist_method_str(const ObItemType dist_method)
return NULL;
};
int ObJoinOrderHint::print_hint_desc(planText &plan_text) const
int ObJoinOrderHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
if (is_ordered_hint()) {
@ -2173,12 +2242,12 @@ int ObLeadingTable::get_all_table_in_leading_table(ObIArray<ObTableInHint*> &all
return ret;
}
int ObLeadingTable::print_leading_table(planText &plan_text) const
int ObLeadingTable::print_leading_table(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_UNLIKELY(!is_valid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected leading table", K(ret), K(table_), K(left_table_), K(right_table_));
@ -2229,6 +2298,13 @@ int ObTableInHint::assign(const ObTableInHint &other)
return ret;
}
bool ObTableInHint::equal(const ObTableInHint& other) const
{
return qb_name_.case_compare(other.qb_name_) == 0 &&
db_name_.case_compare(other.db_name_) == 0 &&
table_name_.case_compare(other.table_name_) == 0;
}
DEF_TO_STRING(ObTableInHint)
{
int64_t pos = 0;
@ -2245,14 +2321,14 @@ DEF_TO_STRING(ObTableInHint)
return pos;
}
int ObTableInHint::print_join_tables_in_hint(planText &plan_text,
int ObTableInHint::print_join_tables_in_hint(PlanText &plan_text,
const ObIArray<ObTableInHint> &tables,
bool ignore_qb_name /* default false */)
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
for (int64_t i = 0; OB_SUCC(ret) && i < tables.count(); ++i) {
if (OB_FAIL(tables.at(i).print_table_in_hint(plan_text, ignore_qb_name))) {
LOG_WARN("fail to print table in hint", K(ret));
@ -2262,13 +2338,13 @@ int ObTableInHint::print_join_tables_in_hint(planText &plan_text,
return ret;
}
int ObTableInHint::print_table_in_hint(planText &plan_text,
int ObTableInHint::print_table_in_hint(PlanText &plan_text,
bool ignore_qb_name /* default false */) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
if (OB_UNLIKELY(table_name_.empty())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get empty table name for table in hint", K(ret), K(table_name_));
@ -2392,12 +2468,12 @@ const char *ObWindowDistHint::get_dist_algo_str(WinDistAlgo dist_algo)
return NULL;
};
int ObWindowDistHint::print_hint_desc(planText &plan_text) const
int ObWindowDistHint::print_hint_desc(PlanText &plan_text) const
{
int ret = OB_SUCCESS;
char *buf = plan_text.buf;
int64_t &buf_len = plan_text.buf_len;
int64_t &pos = plan_text.pos;
char *buf = plan_text.buf_;
int64_t &buf_len = plan_text.buf_len_;
int64_t &pos = plan_text.pos_;
FOREACH_CNT_X(v, algos_, OB_SUCC(ret)) {
if (OB_FAIL(BUF_PRINTF(" %s", get_dist_algo_str(*v)))) {
LOG_WARN("print failed", K(ret));