fix some bugs

This commit is contained in:
chimyue
2023-05-26 06:47:00 +00:00
committed by ob-robot
parent f244dded1a
commit 70ed82ee89
6 changed files with 27 additions and 138 deletions

View File

@ -1130,90 +1130,8 @@ int ObStmtHint::merge_stmt_hint(const ObStmtHint &other,
LOG_WARN("failed to merge normal hint", K(ret));
}
}
if (OB_FAIL(ret)) {
} else if (HINT_DOMINATED_EQUAL == policy) {
if (OB_FAIL(append_array_no_dup(other_opt_hints_, other.other_opt_hints_))) {
LOG_WARN("failed to append other opt hint", K(ret));
}
} else {
ObSEArray<ObItemType, 4> hint_types;
ObSEArray<ObHint*, 8> final_hints;
const ObIArray<ObHint*> &dominated_hints = LEFT_HINT_DOMINATED == policy ? other_opt_hints_
: other.other_opt_hints_;
const ObIArray<ObHint*> &other_hints = LEFT_HINT_DOMINATED == policy ? other.other_opt_hints_
: other_opt_hints_;
if (OB_FAIL(merge_other_opt_hint(dominated_hints, true, hint_types, final_hints))) {
LOG_WARN("failed to merge other opt hints", K(ret));
} else if (OB_FAIL(merge_other_opt_hint(other_hints, false, hint_types, final_hints))) {
LOG_WARN("failed to merge other opt hints", K(ret));
} else if (OB_FAIL(other_opt_hints_.assign(final_hints))) {
LOG_WARN("failed to assign other opt hints", K(ret));
}
}
return ret;
}
int ObStmtHint::merge_other_opt_hint(const ObIArray<ObHint*> &hints,
const bool dominated,
ObIArray<ObItemType> &hint_types,
ObIArray<ObHint*> &final_hints)
{
int ret = OB_SUCCESS;
ObHint *hint = NULL;
ObItemType hint_type = T_INVALID;
bool exists = false;
static const int64_t classify_cnt = 8; // max count in hint_types
if (classify_cnt == hint_types.count() && !dominated) {
//all classify type exists in dominated hints, do nothing
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < hints.count(); ++i) {
if (OB_ISNULL(hint = hints.at(i))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null", K(ret));
} else {
switch (hint->get_hint_type()) {
case T_INDEX_HINT:
case T_NO_INDEX_HINT:
case T_FULL_HINT:
case T_INDEX_SS_HINT:
case T_INDEX_SS_ASC_HINT:
case T_INDEX_SS_DESC_HINT:
case T_USE_DAS_HINT: {
hint_type = T_INDEX_HINT;
break;
}
case T_USE_NL:
case T_USE_MERGE:
case T_USE_HASH: {
hint_type = T_USE_NL;
break;
}
case T_USE_NL_MATERIALIZATION:
case T_PQ_DISTRIBUTE:
case T_PQ_MAP:
case T_PX_JOIN_FILTER:
case T_PX_PART_JOIN_FILTER:
case T_TABLE_PARALLEL: {
hint_type = hint->get_hint_type();
break;
}
default: {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected hint type in other_opt_hints_", K(ret), K(*hint));
}
}
if (OB_SUCC(ret)) {
exists = has_exist_in_array(hint_types, hint_type);
if (dominated && !exists &&
OB_FAIL(hint_types.push_back(hint_type))) {
LOG_WARN("failed to push back hint type", K(ret));
} else if ((dominated || !exists) &&
OB_FAIL(final_hints.push_back(hint))) {
LOG_WARN("failed to push back hint", K(ret));
}
}
}
}
if (OB_SUCC(ret) && OB_FAIL(append_array_no_dup(other_opt_hints_, other.other_opt_hints_))) {
LOG_WARN("failed to append other opt hint", K(ret));
}
return ret;
}