[FEAT MERGE] Lob SQL refactoring (Mem-LobLocator, expressions and dbms_lob adaptions)
Co-authored-by: chaser-ch <chaser.ch@antgroup.com>
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
#define USING_LOG_PREFIX SQL_ENG
|
||||
|
||||
#include "sql/engine/expr/ob_expr_char_length.h"
|
||||
#include "sql/engine/expr/ob_expr_lob_utils.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -48,7 +49,9 @@ int ObExprCharLength::calc_result_type1(ObExprResType &type,
|
||||
type.set_int();
|
||||
type.set_precision(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].precision_);
|
||||
type.set_scale(DEFAULT_SCALE_FOR_INTEGER);
|
||||
text.set_calc_type(ObVarcharType);
|
||||
if (!ob_is_text_tc(text.get_type())) {
|
||||
text.set_calc_type(ObVarcharType);
|
||||
}
|
||||
text.set_calc_collation_type(text.get_collation_type());
|
||||
text.set_calc_collation_level(text.get_collation_level());
|
||||
}
|
||||
@ -68,11 +71,19 @@ int ObExprCharLength::eval_char_length(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
LOG_WARN("eval arg failed", K(ret));
|
||||
} else if (arg->is_null()) {
|
||||
res.set_null();
|
||||
} else {
|
||||
} else if (in_tc != ObTextTC) {
|
||||
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);
|
||||
} else {
|
||||
int64_t char_len = 0;
|
||||
if (OB_FAIL(ObTextStringHelper::get_char_len(ctx, *arg,
|
||||
expr.args_[0]->datum_meta_, expr.args_[0]->obj_meta_.has_lob_header(), char_len))) {
|
||||
LOG_WARN("failed to read realdata", K(ret));
|
||||
} else {
|
||||
res.set_int(static_cast<size_t>(char_len));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user