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

@ -532,7 +532,7 @@ int ObCreateViewResolver::stmt_print(const ObSelectStmt *stmt,
params_.schema_checker_->get_schema_guard(),
obj_print_params, true);
stmt_printer.set_column_list(column_list);
stmt_printer.set_is_root(true); // print hint as root stmt
stmt_printer.set_is_first_stmt_for_hint(true); // need print global hint
if (OB_FAIL(stmt_printer.do_print())) {
if (OB_SIZE_OVERFLOW == ret && buf_len < OB_MAX_PACKET_LENGTH) {
buf_len = std::min(buf_len * 2, OB_MAX_PACKET_LENGTH);

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) {

View File

@ -137,7 +137,7 @@ struct ObQueryHint {
|| global_hint_.has_hint_exclude_concurrent(); }
// print hint
int print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt, const bool is_root_stmt) const;
int print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt, const bool is_first_stmt_for_hint) const;
int print_outline_data(PlanText &plan_text) const;
int print_qb_name_hints(PlanText &plan_text) const;
int print_qb_name_hint(PlanText &plan_text, int64_t stmt_id) const;