fix print global hint bug for set stmt

This commit is contained in:
chimyue
2023-05-12 04:11:25 +00:00
committed by ob-robot
parent 3674a6668d
commit 40e9a1b569
8 changed files with 19 additions and 8 deletions

View File

@ -657,7 +657,7 @@ int ObQueryHint::print_qb_name_hints(PlanText &plan_text) const
// If outline_stmt_id_ is invalid stmt id and has_outline_data(), do not print hint.
// This may happened for outline data from SPM.
int ObQueryHint::print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt,
const bool is_root_stmt) const
const bool is_first_stmt_for_hint) const
{
int ret = OB_SUCCESS;
const int64_t stmt_id = stmt.get_stmt_id();
@ -671,13 +671,13 @@ int ObQueryHint::print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt,
} else if (!has_outline_data()) {
// Not outline data, print current stmt hint here.
// If stmt is the first stmt can add hint, print global hint and hint with qb name.
const bool is_first_stmt = is_root_stmt;
if ((is_first_stmt || OB_INVALID_ID != stmt.get_dblink_id()) &&
// For query "select_1 union all select_2", root stmt is "union all" and the first stmt to print hint is select_1
if ((is_first_stmt_for_hint || OB_INVALID_ID != stmt.get_dblink_id()) &&
OB_FAIL(get_global_hint().print_global_hint(plan_text))) {
LOG_WARN("failed to print global hint", K(ret));
} else if (OB_FAIL(stmt.get_stmt_hint().print_stmt_hint(plan_text))) {
LOG_WARN("failed to print stmt hint", K(ret));
} else if (is_first_stmt) {
} else if (is_first_stmt_for_hint) {
int tmp = OB_SUCCESS;
int64_t tmp_stmt_id = OB_INVALID_STMT_ID;
for (int64_t i = 0; OB_SUCC(ret) && i < qb_hints_.count(); ++i) {