fix some optimizer bugs
This commit is contained in:
@ -378,13 +378,14 @@ int ObGlobalHint::assign(const ObGlobalHint &other)
|
||||
// hints below not print
|
||||
// MAX_CONCURRENT
|
||||
// ObDDLSchemaVersionHint
|
||||
int ObGlobalHint::print_global_hint(PlanText &plan_text, const bool ignore_parallel) 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_;
|
||||
const char* outline_indent = ObQueryHint::get_outline_indent(plan_text.is_oneline_);
|
||||
const bool ignore_parallel_for_dblink = EXPLAIN_DBLINK_STMT == plan_text.type_;
|
||||
|
||||
#define PRINT_GLOBAL_HINT_STR(hint_str) \
|
||||
if (OB_FAIL(BUF_PRINTF("%s%s", outline_indent, hint_str))) { \
|
||||
@ -410,7 +411,7 @@ int ObGlobalHint::print_global_hint(PlanText &plan_text, const bool ignore_paral
|
||||
}
|
||||
|
||||
//DOP
|
||||
if (OB_SUCC(ret) && !dops_.empty() && !ignore_parallel) {
|
||||
if (OB_SUCC(ret) && !dops_.empty() && !ignore_parallel_for_dblink) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < dops_.count(); ++i) {
|
||||
if (OB_FAIL(BUF_PRINTF("%sDOP(%lu, %lu)", outline_indent, dops_.at(i).dfo_, dops_.at(i).dop_))) {
|
||||
LOG_WARN("failed to print dop hint", K(ret));
|
||||
@ -466,9 +467,11 @@ int ObGlobalHint::print_global_hint(PlanText &plan_text, const bool ignore_paral
|
||||
LOG_WARN("failed to print log level hint", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && has_parallel_hint() && !ignore_parallel) { //PARALLEL
|
||||
if (OB_SUCC(ret) && has_parallel_hint() && !ignore_parallel_for_dblink) { //PARALLEL
|
||||
if (has_parallel_degree()) {
|
||||
PRINT_GLOBAL_HINT_NUM("PARALLEL", parallel_);
|
||||
} else if (plan_text.is_outline_data_) {
|
||||
/* do not print parallel policy for outline data */
|
||||
} else if (enable_auto_dop()) {
|
||||
PRINT_GLOBAL_HINT_STR("PARALLEL( AUTO )");
|
||||
} else if (enable_manual_dop()) {
|
||||
@ -480,7 +483,7 @@ int ObGlobalHint::print_global_hint(PlanText &plan_text, const bool ignore_paral
|
||||
}
|
||||
if (OB_SUCC(ret) && ObPDMLOption::NOT_SPECIFIED != pdml_option_) { //PDML
|
||||
if (ObPDMLOption::ENABLE == pdml_option_) {
|
||||
if (!ignore_parallel) {
|
||||
if (!ignore_parallel_for_dblink) {
|
||||
PRINT_GLOBAL_HINT_STR("ENABLE_PARALLEL_DML");
|
||||
}
|
||||
} else if (ObPDMLOption::DISABLE == pdml_option_) {
|
||||
|
||||
@ -154,7 +154,7 @@ struct ObGlobalHint {
|
||||
void merge_dynamic_sampling_hint(int64_t dynamic_sampling);
|
||||
|
||||
bool has_hint_exclude_concurrent() const;
|
||||
int print_global_hint(PlanText &plan_text, const bool ignore_parallel) const;
|
||||
int print_global_hint(PlanText &plan_text) const;
|
||||
int print_monitoring_hints(PlanText &plan_text) const;
|
||||
|
||||
ObPDMLOption get_pdml_option() const { return pdml_option_; }
|
||||
|
||||
@ -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 bool ignore_parallel) const
|
||||
const bool is_root_stmt) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t stmt_id = stmt.get_stmt_id();
|
||||
@ -673,9 +673,9 @@ int ObQueryHint::print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt,
|
||||
// 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()) &&
|
||||
OB_FAIL(get_global_hint().print_global_hint(plan_text, ignore_parallel))) {
|
||||
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, ignore_parallel))) {
|
||||
} 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) {
|
||||
int tmp = OB_SUCCESS;
|
||||
@ -725,7 +725,7 @@ int ObQueryHint::print_outline_data(PlanText &plan_text) const
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(get_global_hint().print_global_hint(plan_text, /*ignore_parallel*/false))) {
|
||||
} else if (OB_FAIL(get_global_hint().print_global_hint(plan_text))) {
|
||||
LOG_WARN("failed to print global hint", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF("%sEND_OUTLINE_DATA", ObQueryHint::get_outline_indent(is_oneline)))) {
|
||||
LOG_WARN("fail to print buf", K(ret));
|
||||
@ -1064,11 +1064,12 @@ DEF_TO_STRING(ObStmtHint)
|
||||
return pos;
|
||||
}
|
||||
|
||||
int ObStmtHint::print_stmt_hint(PlanText &plan_text, const bool ignore_parallel) const
|
||||
int ObStmtHint::print_stmt_hint(PlanText &plan_text) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObHint *hint = NULL;
|
||||
const int64_t N = get_hint_count();
|
||||
const bool ignore_parallel = EXPLAIN_DBLINK_STMT == plan_text.type_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) {
|
||||
if (OB_ISNULL(hint = get_hint_by_idx(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
||||
@ -137,8 +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 bool ignore_parallel) const;
|
||||
int print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt, const bool is_root_stmt) 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;
|
||||
@ -206,7 +205,7 @@ struct ObStmtHint
|
||||
int init_stmt_hint(const ObDMLStmt &stmt,
|
||||
const ObQueryHint &query_hint,
|
||||
bool use_stmt_id_hints);
|
||||
int print_stmt_hint(PlanText &plan_text, const bool ignore_parallel) const;
|
||||
int print_stmt_hint(PlanText &plan_text) const;
|
||||
const ObHint *get_normal_hint(ObItemType hint_type, int64_t *idx = NULL) const;
|
||||
ObHint *get_normal_hint(ObItemType hint_type, int64_t *idx = NULL);
|
||||
void set_query_hint(const ObQueryHint *query_hint) { query_hint_ = query_hint; }
|
||||
|
||||
Reference in New Issue
Block a user