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

@ -14,20 +14,26 @@
#include "sql/engine/expr/ob_expr_char_length.h"
namespace oceanbase {
namespace oceanbase
{
using namespace oceanbase::common;
using namespace oceanbase::sql;
namespace sql {
namespace sql
{
ObExprCharLength::ObExprCharLength(ObIAllocator& alloc)
ObExprCharLength::ObExprCharLength(ObIAllocator &alloc)
: ObFuncExprOperator(alloc, T_FUN_SYS_CHAR_LENGTH, N_CHAR_LENGTH, 1, NOT_ROW_DIMENSION)
{}
{
}
ObExprCharLength::~ObExprCharLength()
{}
{
}
int ObExprCharLength::calc_result_type1(ObExprResType& type, ObExprResType& text, ObExprTypeCtx& type_ctx) const
int ObExprCharLength::calc_result_type1(ObExprResType &type,
ObExprResType &text,
ObExprTypeCtx &type_ctx) const
{
UNUSED(type_ctx);
@ -50,25 +56,11 @@ int ObExprCharLength::calc_result_type1(ObExprResType& type, ObExprResType& text
return ret;
}
int ObExprCharLength::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ctx) const
int ObExprCharLength::eval_char_length(const ObExpr &expr, ObEvalCtx &ctx,
ObDatum &res)
{
int ret = OB_SUCCESS;
ObObjTypeClass type_class = ob_obj_type_class(obj.get_type());
if (!ob_is_castable_type_class(type_class)) {
result.set_null();
} else {
TYPE_CHECK(obj, ObVarcharType);
size_t length = ObCharset::strlen_char(obj.get_collation_type(), obj.get_string_ptr(), obj.get_string_len());
result.set_int(static_cast<int>(length));
}
UNUSED(expr_ctx);
return ret;
}
int ObExprCharLength::eval_char_length(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res)
{
int ret = OB_SUCCESS;
ObDatum* arg = NULL;
ObDatum *arg = NULL;
ObObjTypeClass in_tc = ob_obj_type_class(expr.args_[0]->datum_meta_.type_);
if (!ob_is_castable_type_class(in_tc)) {
res.set_null();
@ -77,14 +69,16 @@ int ObExprCharLength::eval_char_length(const ObExpr& expr, ObEvalCtx& ctx, ObDat
} else if (arg->is_null()) {
res.set_null();
} else {
const ObString& arg_str = arg->get_string();
size_t length = ObCharset::strlen_char(expr.args_[0]->datum_meta_.cs_type_, arg_str.ptr(), arg_str.length());
const ObString &arg_str = arg->get_string();
size_t length = ObCharset::strlen_char(expr.args_[0]->datum_meta_.cs_type_,
arg_str.ptr(), arg_str.length());
res.set_int(length);
}
return ret;
}
int ObExprCharLength::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
int ObExprCharLength::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr,
ObExpr &rt_expr) const
{
int ret = OB_SUCCESS;
UNUSED(expr_cg_ctx);
@ -92,5 +86,5 @@ int ObExprCharLength::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_exp
rt_expr.eval_func_ = eval_char_length;
return ret;
}
} // namespace sql
} // namespace oceanbase
} // namespace sql
} // namespace oceanbase