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

@ -15,19 +15,21 @@
#include "share/object/ob_obj_cast.h"
#include "sql/engine/expr/ob_expr_result_type_util.h"
#include "sql/session/ob_sql_session_info.h"
#include "sql/engine/ob_phy_operator.h"
#include "sql/engine/connect_by/ob_nested_loop_connect_by.h"
#include "sql/engine/ob_exec_context.h"
#include "sql/engine/connect_by/ob_nl_cnnt_by_with_index_op.h"
namespace oceanbase {
namespace oceanbase
{
using namespace common;
using namespace sql;
namespace sql {
namespace sql
{
ObExprPrior::ObExprPrior(ObIAllocator& alloc) : ObExprOperator(alloc, T_OP_PRIOR, N_NEG, 1, NOT_ROW_DIMENSION){};
ObExprPrior::ObExprPrior(ObIAllocator &alloc)
: ObExprOperator(alloc, T_OP_PRIOR, N_NEG, 1, NOT_ROW_DIMENSION) {
};
int ObExprPrior::calc_result_type1(ObExprResType& type, ObExprResType& type1, ObExprTypeCtx& type_ctx) const
int ObExprPrior::calc_result_type1(ObExprResType &type, ObExprResType &type1, ObExprTypeCtx &type_ctx) const
{
UNUSED(type_ctx);
type = type1;
@ -35,37 +37,10 @@ int ObExprPrior::calc_result_type1(ObExprResType& type, ObExprResType& type1, Ob
return ret;
}
int ObExprPrior::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ctx) const
{
int ret = OB_SUCCESS;
if (OB_ISNULL(expr_ctx.exec_ctx_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Got a null phy plan ctx", K(ret));
} else {
ObExecContext& exec_ctx = *expr_ctx.exec_ctx_;
ObPhyOperator::ObPhyOperatorCtx* op_ctx = NULL;
ObConnectByBase::ObConnectByBaseCtx* connect_by_ctx = NULL;
int64_t level = 0;
if (OB_ISNULL(
op_ctx = GET_PHY_OPERATOR_CTX(ObPhyOperator::ObPhyOperatorCtx, exec_ctx, expr_ctx.phy_operator_ctx_id_))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("failed to get nested loop connect by ctx", K(ret));
} else if (PHY_NESTED_LOOP_CONNECT_BY != op_ctx->get_op_type() &&
PHY_NESTED_LOOP_CONNECT_BY_WITH_INDEX != op_ctx->get_op_type()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys connect path can only generate by nestloop connect by join", K(ret), K(op_ctx->get_op_type()));
} else if (FALSE_IT(connect_by_ctx = static_cast<ObConnectByBase::ObConnectByBaseCtx*>(op_ctx))) {
} else if (FALSE_IT(level = connect_by_ctx->get_current_level())) {
} else {
result = obj;
if (1 == level) {
result.set_null();
}
}
}
return ret;
}
int ObExprPrior::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
int ObExprPrior::cg_expr(
ObExprCGCtx &expr_cg_ctx,
const ObRawExpr &raw_expr,
ObExpr &rt_expr) const
{
int ret = OB_SUCCESS;
UNUSED(expr_cg_ctx);
@ -79,17 +54,17 @@ int ObExprPrior::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, Ob
return ret;
}
int ObExprPrior::calc_prior_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res)
int ObExprPrior::calc_prior_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
{
int ret = OB_SUCCESS;
uint64_t operator_id = expr.extra_;
ObDatum* arg_datum = nullptr;
ObOperatorKit* kit = ctx.exec_ctx_.get_operator_kit(operator_id);
ObDatum *arg_datum = nullptr;
ObOperatorKit *kit = ctx.exec_ctx_.get_operator_kit(operator_id);
if (OB_ISNULL(kit) || OB_ISNULL(kit->op_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("operator is NULL", K(ret), K(operator_id), KP(kit));
} else if (OB_UNLIKELY(PHY_NESTED_LOOP_CONNECT_BY != kit->op_->get_spec().type_ &&
PHY_NESTED_LOOP_CONNECT_BY_WITH_INDEX != kit->op_->get_spec().type_)) {
} else if (OB_UNLIKELY(PHY_NESTED_LOOP_CONNECT_BY != kit->op_->get_spec().type_
&& PHY_NESTED_LOOP_CONNECT_BY_WITH_INDEX != kit->op_->get_spec().type_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("is not connect by operator", K(ret), K(operator_id), "spec", kit->op_->get_spec());
} else if (OB_FAIL(expr.args_[0]->eval(ctx, arg_datum))) {
@ -97,10 +72,10 @@ int ObExprPrior::calc_prior_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& re
} else {
int64_t level = 0;
if (PHY_NESTED_LOOP_CONNECT_BY == kit->op_->get_spec().type_) {
ObNLConnectByOp* cnntby_op = static_cast<ObNLConnectByOp*>(kit->op_);
ObNLConnectByOp *cnntby_op = static_cast<ObNLConnectByOp *>(kit->op_);
level = cnntby_op->connect_by_pump_.get_current_level();
} else {
ObNLConnectByWithIndexOp* cnntby_op = static_cast<ObNLConnectByWithIndexOp*>(kit->op_);
ObNLConnectByWithIndexOp *cnntby_op = static_cast<ObNLConnectByWithIndexOp *>(kit->op_);
level = cnntby_op->connect_by_pump_.get_current_level();
}
if (1 == level) {
@ -113,5 +88,7 @@ int ObExprPrior::calc_prior_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& re
return ret;
}
} // namespace sql
} // namespace oceanbase
}
}