fix pushdown none const exprs into set query bug
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
#include "sql/optimizer/ob_log_table_scan.h"
|
#include "sql/optimizer/ob_log_table_scan.h"
|
||||||
#include "share/location_cache/ob_location_service.h"
|
#include "share/location_cache/ob_location_service.h"
|
||||||
#include "share/ob_order_perserving_encoder.h"
|
#include "share/ob_order_perserving_encoder.h"
|
||||||
|
#include "sql/rewrite/ob_predicate_deduce.h"
|
||||||
|
|
||||||
using namespace oceanbase;
|
using namespace oceanbase;
|
||||||
using namespace sql;
|
using namespace sql;
|
||||||
@ -6473,8 +6474,10 @@ int ObOptimizerUtil::check_pushdown_filter(const ObDMLStmt &parent_stmt,
|
|||||||
remain_filters))) {
|
remain_filters))) {
|
||||||
LOG_WARN("failed to check pushdown filter overlap index", K(ret));
|
LOG_WARN("failed to check pushdown filter overlap index", K(ret));
|
||||||
}
|
}
|
||||||
} else {
|
} else if (OB_FAIL(candi_filters.assign(pushdown_filters))) {
|
||||||
ret = candi_filters.assign(pushdown_filters);
|
LOG_WARN("failed to assign exprs", K(ret));
|
||||||
|
} else if (OB_FAIL(remove_special_exprs(candi_filters, remain_filters))) {
|
||||||
|
LOG_WARN("failed to remove special exprs", K(ret));
|
||||||
}
|
}
|
||||||
} else if (OB_FAIL(get_groupby_win_func_common_exprs(subquery,
|
} else if (OB_FAIL(get_groupby_win_func_common_exprs(subquery,
|
||||||
common_exprs,
|
common_exprs,
|
||||||
@ -6506,6 +6509,30 @@ int ObOptimizerUtil::check_pushdown_filter(const ObDMLStmt &parent_stmt,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObOptimizerUtil::remove_special_exprs(ObIArray<ObRawExpr*> &pushdown_filters,
|
||||||
|
ObIArray<ObRawExpr*> &remain_filters)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObSEArray<ObRawExpr *, 4> normal_filters;
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < pushdown_filters.count(); ++i) {
|
||||||
|
if (OB_ISNULL(pushdown_filters.at(i))) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("predicate is null", K(ret));
|
||||||
|
} else if (ObPredicateDeduce::contain_special_expr(*pushdown_filters.at(i))) {
|
||||||
|
if (OB_FAIL(remain_filters.push_back(pushdown_filters.at(i)))) {
|
||||||
|
LOG_WARN("failed to push back expr", K(ret));
|
||||||
|
}
|
||||||
|
} else if (OB_FAIL(normal_filters.push_back(pushdown_filters.at(i)))) {
|
||||||
|
LOG_WARN("failed to push back expr", K(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret) &&
|
||||||
|
OB_FAIL(pushdown_filters.assign(normal_filters))) {
|
||||||
|
LOG_WARN("failed to assign filters", K(ret));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ObOptimizerUtil::check_pushdown_filter_overlap_index(const ObDMLStmt &stmt,
|
int ObOptimizerUtil::check_pushdown_filter_overlap_index(const ObDMLStmt &stmt,
|
||||||
ObOptimizerContext &opt_ctx,
|
ObOptimizerContext &opt_ctx,
|
||||||
ObIArray<ObRawExpr*> &pushdown_filters,
|
ObIArray<ObRawExpr*> &pushdown_filters,
|
||||||
@ -6540,9 +6567,15 @@ int ObOptimizerUtil::check_pushdown_filter_overlap_index(const ObDMLStmt &stmt,
|
|||||||
}
|
}
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
} else if (is_match_index) {
|
} else if (is_match_index) {
|
||||||
ret = candi_filters.assign(pushdown_filters);
|
if (OB_FAIL(candi_filters.assign(pushdown_filters))) {
|
||||||
|
LOG_WARN("failed to assign exprs", K(ret));
|
||||||
|
} else if (OB_FAIL(remove_special_exprs(candi_filters, remain_filters))) {
|
||||||
|
LOG_WARN("failed to remove special exprs", K(ret));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = remain_filters.assign(pushdown_filters);
|
if (OB_FAIL(remain_filters.assign(pushdown_filters))) {
|
||||||
|
LOG_WARN("failed to assign exprs", K(ret));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -6583,6 +6616,8 @@ int ObOptimizerUtil::check_pushdown_filter_for_set(const ObSelectStmt &parent_st
|
|||||||
if (OB_ISNULL(expr)) {
|
if (OB_ISNULL(expr)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("unexpect null expr", K(ret));
|
LOG_WARN("unexpect null expr", K(ret));
|
||||||
|
} else if (ObPredicateDeduce::contain_special_expr(*expr)) {
|
||||||
|
is_simple_expr = false;
|
||||||
} else if (expr->has_flag(CNT_WINDOW_FUNC) ||
|
} else if (expr->has_flag(CNT_WINDOW_FUNC) ||
|
||||||
expr->has_flag(CNT_AGG) ||
|
expr->has_flag(CNT_AGG) ||
|
||||||
expr->has_flag(CNT_SUB_QUERY) ||
|
expr->has_flag(CNT_SUB_QUERY) ||
|
||||||
@ -6654,6 +6689,8 @@ int ObOptimizerUtil::check_pushdown_filter_for_subquery(const ObDMLStmt &parent_
|
|||||||
if (OB_ISNULL(expr)) {
|
if (OB_ISNULL(expr)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("unexpect null expr", K(ret));
|
LOG_WARN("unexpect null expr", K(ret));
|
||||||
|
} else if (ObPredicateDeduce::contain_special_expr(*expr)) {
|
||||||
|
is_simple_expr = false;
|
||||||
} else if (expr->has_flag(CNT_WINDOW_FUNC) ||
|
} else if (expr->has_flag(CNT_WINDOW_FUNC) ||
|
||||||
expr->has_flag(CNT_AGG) ||
|
expr->has_flag(CNT_AGG) ||
|
||||||
expr->has_flag(CNT_SUB_QUERY)) {
|
expr->has_flag(CNT_SUB_QUERY)) {
|
||||||
|
|||||||
@ -1150,6 +1150,9 @@ public:
|
|||||||
ObIArray<ObRawExpr*> &remain_filters,
|
ObIArray<ObRawExpr*> &remain_filters,
|
||||||
bool check_match_index = true);
|
bool check_match_index = true);
|
||||||
|
|
||||||
|
static int remove_special_exprs(ObIArray<ObRawExpr*> &pushdown_filters,
|
||||||
|
ObIArray<ObRawExpr*> &remain_filters);
|
||||||
|
|
||||||
static int check_pushdown_filter_overlap_index(const ObDMLStmt &stmt,
|
static int check_pushdown_filter_overlap_index(const ObDMLStmt &stmt,
|
||||||
ObOptimizerContext &opt_ctx,
|
ObOptimizerContext &opt_ctx,
|
||||||
ObIArray<ObRawExpr*> &pushdown_filters,
|
ObIArray<ObRawExpr*> &pushdown_filters,
|
||||||
|
|||||||
Reference in New Issue
Block a user