Fix dblink bug when dblink sql contains outline
This commit is contained in:
parent
0a734f9343
commit
13327b58d4
@ -668,7 +668,7 @@ int ObQueryHint::print_stmt_hint(PlanText &plan_text, const ObDMLStmt &stmt,
|
||||
if (OB_FAIL(print_outline_data(plan_text))) {
|
||||
LOG_WARN("failed to print outline data", K(ret));
|
||||
}
|
||||
} else if (!has_outline_data()) {
|
||||
} else if (!has_outline_data() || OB_INVALID_ID != stmt.get_dblink_id()) {
|
||||
// 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.
|
||||
// For query "select_1 union all select_2", root stmt is "union all" and the first stmt to print hint is select_1
|
||||
|
@ -808,10 +808,10 @@ int ObRawExprPrinter::print(ObOpRawExpr *expr)
|
||||
}
|
||||
case T_OP_BOOL:{
|
||||
CK(1 == expr->get_param_count());
|
||||
if (print_params_.for_dblink_) {
|
||||
DATA_PRINTF("(case when (");
|
||||
if (print_params_.for_dblink_ && lib::is_mysql_mode()) {
|
||||
DATA_PRINTF("!!(");
|
||||
PRINT_EXPR(expr->get_param_expr(0));
|
||||
DATA_PRINTF(") then 1 else 0 end)");
|
||||
DATA_PRINTF(")");
|
||||
} else if (expr->has_flag(IS_INNER_ADDED_EXPR)) {
|
||||
// ignore print inner added expr
|
||||
PRINT_EXPR(expr->get_param_expr(0));
|
||||
|
@ -1477,34 +1477,15 @@ int ObTransformDBlink::formalize_bool_select_expr(ObDMLStmt *stmt)
|
||||
ObIArray<SelectItem> &select_items = select_stmt->get_select_items();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < select_items.count(); ++i) {
|
||||
SelectItem &select_item = select_items.at(i);
|
||||
ObRawExpr *case_when_expr = NULL;
|
||||
ObConstRawExpr *one_expr = NULL;
|
||||
ObConstRawExpr *zero_expr = NULL;
|
||||
bool is_bool_expr = false;
|
||||
if (OB_ISNULL(select_item.expr_)) {
|
||||
LOG_WARN("unexpected select item", K(ret));
|
||||
} else if (OB_FAIL(ObRawExprUtils::check_is_bool_expr(select_item.expr_, is_bool_expr))) {
|
||||
LOG_WARN("failed to check is bool expr", K(ret));
|
||||
} else if (!is_bool_expr) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObRawExprUtils::build_const_int_expr(*ctx_->expr_factory_,
|
||||
ObIntType,
|
||||
1,
|
||||
one_expr))) {
|
||||
LOG_WARN("failed to build const number expr", K(ret));
|
||||
} else if (OB_FAIL(ObRawExprUtils::build_const_int_expr(*ctx_->expr_factory_,
|
||||
ObIntType,
|
||||
0,
|
||||
zero_expr))) {
|
||||
LOG_WARN("failed to build const number expr", K(ret));
|
||||
} else if (OB_FAIL(ObRawExprUtils::build_case_when_expr(*ctx_->expr_factory_,
|
||||
select_item.expr_,
|
||||
one_expr,
|
||||
zero_expr,
|
||||
case_when_expr))) {
|
||||
LOG_WARN("failed to build case when expr", K(ret));
|
||||
} else {
|
||||
select_item.expr_ = case_when_expr;
|
||||
} else if (is_bool_expr) {
|
||||
// TODO : BOOL SELECT ITEM NOT SUPPORTED IN ORACLE MODE
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("bool select item for oracle dblink not supported", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user