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

@ -18,27 +18,33 @@
using namespace oceanbase::common;
using namespace oceanbase::sql;
namespace oceanbase {
namespace sql {}
} // namespace oceanbase
namespace oceanbase
{
namespace sql
{
}
}
ObExprElt::ObExprElt(ObIAllocator& alloc)
: ObExprOperator(alloc, T_FUN_SYS_ELT, N_ELT, MORE_THAN_ONE, NOT_ROW_DIMENSION)
{}
ObExprElt::ObExprElt(ObIAllocator &alloc)
: ObExprOperator(alloc, T_FUN_SYS_ELT, N_ELT, MORE_THAN_ONE, NOT_ROW_DIMENSION) {}
int ObExprElt::calc_result_typeN(
ObExprResType& type, ObExprResType* types_stack, int64_t param_num, ObExprTypeCtx& type_ctx) const
ObExprResType &type,
ObExprResType *types_stack,
int64_t param_num,
ObExprTypeCtx &type_ctx) const
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(param_num < 2)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument, input arguments should > 2", K(ret));
} else if (OB_ISNULL(types_stack)) {
} else if (OB_ISNULL(types_stack)){
ret = OB_INVALID_ARGUMENT;
LOG_WARN("null stack", K(types_stack), K(ret));
} else {
type.set_varchar();
ret = aggregate_charsets_for_string_result(type, types_stack + 1, param_num - 1, type_ctx.get_coll_type());
ret = aggregate_charsets_for_string_result(
type, types_stack + 1, param_num - 1, type_ctx.get_coll_type());
if (OB_SUCC(ret)) {
int32_t length = 0;
for (int64_t i = 1; i < param_num; ++i) {
@ -58,43 +64,10 @@ int ObExprElt::calc_result_typeN(
}
return ret;
}
int ObExprElt::calc_resultN(
common::ObObj& result, const common::ObObj* obj_stack, int64_t param_num, ObExprCtx& expr_ctx) const
{
int ret = OB_SUCCESS;
UNUSED(expr_ctx);
if (OB_ISNULL(obj_stack)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("null stack", K(obj_stack), K(ret));
result.set_null();
} else if (OB_UNLIKELY(param_num < 2)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("param error", K(param_num), K(ret));
result.set_null();
} else {
const ObObj& obj_judge = obj_stack[0];
int64_t index = -1;
if (OB_UNLIKELY(obj_judge.is_null())) {
result.set_null();
} else {
TYPE_CHECK(obj_judge, ObIntType);
index = obj_judge.get_int();
if (OB_UNLIKELY(index <= 0 || index >= param_num)) {
result.set_null();
} else if (obj_stack[index].is_null()) {
result.set_null();
} else {
TYPE_CHECK(obj_stack[index], ObVarcharType);
result = obj_stack[index];
}
}
}
return ret;
}
int ObExprElt::cg_expr(ObExprCGCtx&, const ObRawExpr&, ObExpr& expr) const
int ObExprElt::cg_expr(ObExprCGCtx &, const ObRawExpr &, ObExpr &expr) const
{
int ret = OB_SUCCESS;
CK(expr.arg_cnt_ > 1);
@ -102,11 +75,11 @@ int ObExprElt::cg_expr(ObExprCGCtx&, const ObRawExpr&, ObExpr& expr) const
return ret;
}
int ObExprElt::eval_elt(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
int ObExprElt::eval_elt(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
{
int ret = OB_SUCCESS;
ObDatum* first = NULL;
ObDatum* d = NULL;
ObDatum *first = NULL;
ObDatum *d = NULL;
if (OB_FAIL(expr.args_[0]->eval(ctx, first))) {
LOG_WARN("evaluate parameter failed", K(ret));
} else if (first->is_null() || first->get_int() <= 0 || first->get_int() >= expr.arg_cnt_) {