Fix a dblink bug
This commit is contained in:
@ -768,8 +768,23 @@ int ObSelectStmtPrinter::print_order_by()
|
|||||||
const OrderItem &order_item = select_stmt->get_order_item(i);
|
const OrderItem &order_item = select_stmt->get_order_item(i);
|
||||||
ObRawExpr *order_expr = order_item.expr_;
|
ObRawExpr *order_expr = order_item.expr_;
|
||||||
int64_t sel_item_pos = -1;
|
int64_t sel_item_pos = -1;
|
||||||
for (int64_t j = 0; j < select_stmt->get_select_item_size(); ++j) {
|
if (OB_ISNULL(order_expr)) {
|
||||||
if (order_item.expr_ == select_stmt->get_select_item(j).expr_) {
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected null", K(ret));
|
||||||
|
} else if (T_FUN_SYS_CAST == order_expr->get_expr_type() &&
|
||||||
|
CM_IS_IMPLICIT_CAST(order_expr->get_extra())) {
|
||||||
|
order_expr = order_expr->get_param_expr(0);
|
||||||
|
}
|
||||||
|
for (int64_t j = 0; OB_SUCC(ret) && j < select_stmt->get_select_item_size(); ++j) {
|
||||||
|
ObRawExpr *select_expr = select_stmt->get_select_item(j).expr_;
|
||||||
|
if (OB_ISNULL(select_expr)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected null", K(ret));
|
||||||
|
} else if (T_FUN_SYS_CAST == select_expr->get_expr_type() &&
|
||||||
|
CM_IS_IMPLICIT_CAST(select_expr->get_extra())) {
|
||||||
|
select_expr = select_expr->get_param_expr(0);
|
||||||
|
}
|
||||||
|
if (order_expr == select_expr) {
|
||||||
sel_item_pos = j + 1;
|
sel_item_pos = j + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,6 +82,7 @@ int ObTransformMinMax::check_transform_validity(ObSelectStmt *select_stmt,
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
const ObRawExpr *select_expr = NULL;
|
const ObRawExpr *select_expr = NULL;
|
||||||
is_valid = false;
|
is_valid = false;
|
||||||
|
bool invalid_for_dblink = false;
|
||||||
if (OB_ISNULL(select_stmt)) {
|
if (OB_ISNULL(select_stmt)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("unexpected null", K(ret), K(select_stmt));
|
LOG_WARN("unexpected null", K(ret), K(select_stmt));
|
||||||
@ -95,7 +96,13 @@ int ObTransformMinMax::check_transform_validity(ObSelectStmt *select_stmt,
|
|||||||
|| select_stmt->get_aggr_item_size() != 1) {
|
|| select_stmt->get_aggr_item_size() != 1) {
|
||||||
//do nothing
|
//do nothing
|
||||||
OPT_TRACE("not a simple query");
|
OPT_TRACE("not a simple query");
|
||||||
} else if (OB_FAIL(is_valid_select_list(*select_stmt, select_expr, is_valid))) {
|
} else if (OB_FAIL(ObTransformUtils::check_stmt_from_one_dblink(select_stmt, invalid_for_dblink))) {
|
||||||
|
LOG_WARN("failed to check if all tables from one dblink", K(ret));
|
||||||
|
} else if (invalid_for_dblink) {
|
||||||
|
is_valid = false;
|
||||||
|
// do not transform,
|
||||||
|
// for compatibility with Oracle before 12c
|
||||||
|
} else if (OB_FAIL(is_valid_select_list(*select_stmt, select_expr, is_valid))) {
|
||||||
LOG_WARN("failed to check is valid select list", K(ret));
|
LOG_WARN("failed to check is valid select list", K(ret));
|
||||||
} else if (!is_valid) {
|
} else if (!is_valid) {
|
||||||
//do nothing
|
//do nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user