patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -17,36 +17,48 @@
using namespace oceanbase::sql;
using namespace oceanbase::common;
int ObRawExprAddToContext::add_to_context(ObRawExpr& expr)
int ObRawExprAddToContext::add_to_context(ObRawExpr &expr)
{
return expr.postorder_accept(*this);
}
int ObRawExprAddToContext::visit(ObConstRawExpr& expr)
int ObRawExprAddToContext::visit(ObConstRawExpr &expr)
{
int ret = OB_SUCCESS;
UNUSED(expr);
return ret;
}
int ObRawExprAddToContext::visit(ObVarRawExpr& expr)
int ObRawExprAddToContext::visit(ObVarRawExpr &expr)
{
int ret = OB_SUCCESS;
UNUSED(expr);
return ret;
}
int ObRawExprAddToContext::visit(ObQueryRefRawExpr& expr)
int ObRawExprAddToContext::visit(ObOpPseudoColumnRawExpr &expr)
{
int ret = OB_SUCCESS;
UNUSED(expr);
return ret;
}
int ObRawExprAddToContext::visit(ObQueryRefRawExpr &expr)
{
return add_expr(expr);
}
int ObRawExprAddToContext::visit(ObColumnRefRawExpr& expr)
int ObRawExprAddToContext::visit(ObPlQueryRefRawExpr &expr)
{
return add_expr(expr);
}
int ObRawExprAddToContext::visit(ObOpRawExpr& expr)
int ObRawExprAddToContext::visit(ObColumnRefRawExpr &expr)
{
return add_expr(expr);
}
int ObRawExprAddToContext::visit(ObOpRawExpr &expr)
{
int ret = OB_SUCCESS;
if (expr.has_generalized_column() && T_OP_ROW != expr.get_expr_type()) {
@ -55,7 +67,7 @@ int ObRawExprAddToContext::visit(ObOpRawExpr& expr)
return ret;
}
int ObRawExprAddToContext::visit(ObCaseOpRawExpr& expr)
int ObRawExprAddToContext::visit(ObCaseOpRawExpr &expr)
{
int ret = OB_SUCCESS;
if (expr.has_generalized_column()) {
@ -64,23 +76,23 @@ int ObRawExprAddToContext::visit(ObCaseOpRawExpr& expr)
return ret;
}
int ObRawExprAddToContext::visit(ObAggFunRawExpr& expr)
int ObRawExprAddToContext::visit(ObAggFunRawExpr &expr)
{
// /* When we recursively add the expressions to the list, it is because the expression
// can only be produced by us - ie. the aggregation function of group by. In this case
// we would want to skip adding the aggregation funtion to the request list */
// int ret = OB_SUCCESS;
//// UNUSED(expr);
//// return ret;
// if (expr.has_flag(CNT_COLUMN) || IS_COUNT_STAR(&expr)) {
// return add_expr(expr);
// }
//
// return ret;
// /* When we recursively add the expressions to the list, it is because the expression
// can only be produced by us - ie. the aggregation function of group by. In this case
// we would want to skip adding the aggregation funtion to the request list */
// int ret = OB_SUCCESS;
//// UNUSED(expr);
//// return ret;
// if (expr.has_flag(CNT_COLUMN) || IS_COUNT_STAR(&expr)) {
// return add_expr(expr);
// }
//
// return ret;
return add_expr(expr);
}
int ObRawExprAddToContext::visit(ObSysFunRawExpr& expr)
int ObRawExprAddToContext::visit(ObSysFunRawExpr &expr)
{
int ret = OB_SUCCESS;
if (expr.has_generalized_column() || expr.has_flag(CNT_RAND_FUNC)) {
@ -89,26 +101,26 @@ int ObRawExprAddToContext::visit(ObSysFunRawExpr& expr)
return ret;
}
int ObRawExprAddToContext::visit(ObSetOpRawExpr& expr)
int ObRawExprAddToContext::visit(ObSetOpRawExpr &expr)
{
return add_expr(expr);
}
int ObRawExprAddToContext::visit(ObWinFunRawExpr& expr)
int ObRawExprAddToContext::visit(ObWinFunRawExpr &expr)
{
return add_expr(expr);
}
int ObRawExprAddToContext::visit(ObPseudoColumnRawExpr& expr)
int ObRawExprAddToContext::visit(ObPseudoColumnRawExpr &expr)
{
return add_expr(expr);
}
/**
* TODO: the complexity of the algorithm used in add_expr is quite high. * We may need to revisit it later if it turns
* out to be an optimization we have to do.
* TODO(jiuman): the complexity of the algorithm used in add_expr is quite high. * We may need to revisit it later if it turns out to be an optimization we have
* to do.
*/
int ObRawExprAddToContext::add_expr(ObRawExpr& expr)
int ObRawExprAddToContext::add_expr(ObRawExpr &expr)
{
int ret = OB_SUCCESS;
@ -116,24 +128,24 @@ int ObRawExprAddToContext::add_expr(ObRawExpr& expr)
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid argument", K(ret));
} else {
ExprProducer* existing_producer = NULL;
ExprProducer *existing_producer = NULL;
if (!ObOptimizerUtil::find_expr(ctx_, expr, existing_producer)) {
ExprProducer expr_producer(&expr, consumer_id_);
if (OB_FAIL(ctx_->push_back(expr_producer))) {
LOG_PRINT_EXPR(WARN, "failed to add expr to request list", &expr, "# of expr", ctx_->count());
LOG_PRINT_EXPR(WARN, "failed to add expr to request list", &expr,
"# of expr", ctx_->count());
} else {
LOG_PRINT_EXPR(DEBUG, "add expr to request list", &expr, "# of expr", ctx_->count());
LOG_PRINT_EXPR(DEBUG, "add expr to request list", &expr,
"# of expr", ctx_->count());
}
} else if (OB_ISNULL(existing_producer)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("existing_producer is unexpected null", K(ret));
} else {
// if we need the same expr below the predetermined producer
// restore predetermined_producer_ so it can be produced here
LOG_TRACE("restore predetermined_producer",
K(existing_producer->expr_),
K(existing_producer->producer_id_),
K(existing_producer->consumer_id_));
//if we need the same expr below the predetermined producer
//restore predetermined_producer_ so it can be produced here
LOG_TRACE("restore predetermined_producer", K(existing_producer->expr_),
K(existing_producer->producer_id_), K(existing_producer->consumer_id_));
existing_producer->producer_id_ = OB_INVALID_ID;
}
}