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

@ -21,24 +21,27 @@
using namespace oceanbase::common;
namespace oceanbase {
namespace sql {
ObFastColumnConvExpr::ObFastColumnConvExpr(ObIAllocator& alloc)
namespace oceanbase
{
namespace sql
{
ObFastColumnConvExpr::ObFastColumnConvExpr(ObIAllocator &alloc)
: ObBaseExprColumnConv(alloc),
ObFastExprOperator(T_FUN_COLUMN_CONV),
column_type_(alloc),
value_item_(),
column_info_()
{}
{
}
int ObFastColumnConvExpr::assign(const ObFastExprOperator& other)
int ObFastColumnConvExpr::assign(const ObFastExprOperator &other)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(other.get_op_type() != T_FUN_COLUMN_CONV)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(other.get_op_type()));
} else {
const ObFastColumnConvExpr& other_conv = static_cast<const ObFastColumnConvExpr&>(other);
const ObFastColumnConvExpr &other_conv = static_cast<const ObFastColumnConvExpr&>(other);
column_type_ = other_conv.column_type_;
value_item_ = other_conv.value_item_;
if (OB_FAIL(ob_write_string(alloc_, other_conv.column_info_, column_info_))) {
@ -48,7 +51,7 @@ int ObFastColumnConvExpr::assign(const ObFastExprOperator& other)
return ret;
}
int ObFastColumnConvExpr::calc(ObExprCtx& expr_ctx, const ObNewRow& row, ObObj& result) const
int ObFastColumnConvExpr::calc(ObExprCtx &expr_ctx, const ObNewRow &row, ObObj &result) const
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(OB_ISNULL(expr_ctx.my_session_))) {
@ -56,8 +59,8 @@ int ObFastColumnConvExpr::calc(ObExprCtx& expr_ctx, const ObNewRow& row, ObObj&
LOG_WARN("expr context is invalid", K(ret), K(expr_ctx.my_session_), K(expr_ctx.phy_plan_ctx_));
} else {
bool is_strict = is_strict_mode(expr_ctx.my_session_->get_sql_mode());
const ObObj* value = NULL;
const ObString* column_info = NULL;
const ObObj *value = NULL;
const ObString *column_info = NULL;
if (has_column_info()) {
column_info = &column_info_;
}
@ -65,15 +68,16 @@ int ObFastColumnConvExpr::calc(ObExprCtx& expr_ctx, const ObNewRow& row, ObObj&
LOG_WARN("get item value directly from value item failed", K(ret), K_(value_item));
} else if (OB_FAIL(ObSqlExpressionUtil::expand_array_params(expr_ctx, *value, value))) {
LOG_WARN("expand array params failed", K(ret));
} else if (OB_FAIL(ObExprColumnConv::convert_skip_null_check(
result, *value, column_type_, is_strict, expr_ctx.column_conv_ctx_, &str_values_, column_info))) {
} else if (OB_FAIL(ObExprColumnConv::convert_skip_null_check(result, *value, column_type_,
is_strict, expr_ctx.column_conv_ctx_,
&str_values_, column_info))) {
LOG_WARN("convert column value failed", K(ret), K(*this));
}
}
return ret;
}
int ObFastColumnConvExpr::set_const_value(const ObObj& value)
int ObFastColumnConvExpr::set_const_value(const ObObj &value)
{
int ret = OB_SUCCESS;
ObObj tmp;
@ -84,82 +88,78 @@ int ObFastColumnConvExpr::set_const_value(const ObObj& value)
}
return ret;
}
// Because ObExprColumnConv uses the serialization function of the parent class ObExprOperator in the 14x version
// In order to ensure compatibility,
// first serialize the members of the parent class ObExprOperator, and then serialize its own members
//由于在14x的版本中ObExprColumnConv使用的是父类ObExprOperator的序列化函数
//为了保证兼容性,这里先序列化父类ObExprOperator的成员,再序列化自身的成员
OB_SERIALIZE_MEMBER(ObExprColumnConv, row_dimension_, real_param_num_, result_type_, input_types_, id_, str_values_);
ObExprColumnConv::ObExprColumnConv(ObIAllocator& alloc)
: ObBaseExprColumnConv(alloc), ObFuncExprOperator(alloc, T_FUN_COLUMN_CONV, N_COLUMN_CONV, -1, NOT_ROW_DIMENSION)
ObExprColumnConv::ObExprColumnConv(ObIAllocator &alloc)
: ObBaseExprColumnConv(alloc),
ObFuncExprOperator(alloc, T_FUN_COLUMN_CONV, N_COLUMN_CONV, -1, NOT_ROW_DIMENSION,
INTERNAL_IN_MYSQL_MODE, INTERNAL_IN_ORACLE_MODE)
{
disable_operand_auto_cast();
// obexprcolumnconv has its own special processing, not need charset_convert
//obexprcolumnconv有自己特殊处理,不走字符集自动转换框架
need_charset_convert_ = false;
}
ObExprColumnConv::~ObExprColumnConv()
{}
{
}
int ObExprColumnConv::calc_resultN(ObObj& result, const ObObj* objs, int64_t param_num, ObExprCtx& expr_ctx) const
int ObExprColumnConv::assign(const ObExprOperator &other)
{
int ret = OB_SUCCESS;
// objs[0] type
// objs[1] collation_type
// objs[2] accuray_expr
// objs[3] nullable_expr
// objs[4] value
// objs[5] column_info only for error msg in oracle mode
if (((PARAMS_COUNT_WITH_COLUMN_INFO != param_num) && (PARAMS_COUNT_WITHOUT_COLUMN_INFO != param_num)) ||
OB_ISNULL(objs)) {
const ObExprColumnConv *tmp_other = dynamic_cast<const ObExprColumnConv *>(&other);
if (OB_UNLIKELY(NULL == tmp_other)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument number", K(param_num), K(objs));
} else if (OB_ISNULL(expr_ctx.my_session_)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid session info", K(expr_ctx.my_session_));
} else {
ObString column_info;
if (PARAMS_COUNT_WITH_COLUMN_INFO == param_num) {
column_info = objs[5].get_string();
LOG_WARN("invalid argument. wrong type for other", K(ret), K(other));
} else if (OB_LIKELY(this != tmp_other)) {
if (OB_FAIL(ObFuncExprOperator::assign(other))) {
LOG_WARN("copy in Base class ObFuncExprOperator failed", K(ret));
} else if (tmp_other->str_values_.count() > 0 &&
OB_FAIL(deep_copy_str_values(tmp_other->str_values_))) {
LOG_WARN("copy str_values failed", K(ret));
}
bool is_strict = is_strict_mode(expr_ctx.my_session_->get_sql_mode());
if (OB_FAIL(ObExprColumnConv::convert_skip_null_check(
result, objs[4], get_result_type(), is_strict, expr_ctx.column_conv_ctx_, &str_values_, &column_info))) {
LOG_WARN("convert ObExprColumnConv failed", K(ret), K(get_result_type()), K(objs[4]), K_(str_values));
}
}
if (OB_SUCC(ret)) {
LOG_DEBUG("calc result for column conv", K(objs[0]), K(objs[1]), K(objs[2]), K(objs[3]), K(objs[4]), K(result));
}
return ret;
}
int ObExprColumnConv::convert_with_null_check(ObObj& result, const ObObj& obj, const ObExprResType& res_type,
bool is_strict, ObCastCtx& cast_ctx, const ObIArray<ObString>* type_infos)
int ObExprColumnConv::convert_with_null_check(ObObj &result,
const ObObj &obj,
const ObExprResType &res_type,
bool is_strict,
ObCastCtx &cast_ctx,
const ObIArray<ObString> *type_infos)
{
int ret = OB_SUCCESS;
bool is_not_null = res_type.has_result_flag(OB_MYSQL_NOT_NULL_FLAG);
if (OB_FAIL(ObExprColumnConv::convert_skip_null_check(result, obj, res_type, is_strict, cast_ctx, type_infos))) {
bool is_not_null = res_type.is_not_null_for_write();
if (OB_FAIL(ObExprColumnConv::convert_skip_null_check(result, obj, res_type, is_strict,
cast_ctx, type_infos))) {
LOG_WARN("fail to convert skip null check", K(ret));
} else {
// if (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_2220) {
if (is_not_null && (result.is_null() || (lib::is_oracle_mode() && result.is_null_oracle()))) {
ret = OB_BAD_NULL_ERROR;
LOG_WARN("Column should not be null", K(ret));
// }
// if (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_2220) {
if (is_not_null && (result.is_null() || (lib::is_oracle_mode() && result.is_null_oracle()))) {
ret = OB_BAD_NULL_ERROR;
LOG_WARN("Column should not be null", K(ret));
// }
}
}
return ret;
}
int ObExprColumnConv::convert_skip_null_check(ObObj& result, const ObObj& obj, const ObExprResType& res_type,
bool is_strict, ObCastCtx& cast_ctx, const ObIArray<ObString>* type_infos, const ObString* column_info)
int ObExprColumnConv::convert_skip_null_check(ObObj &result,
const ObObj &obj,
const ObExprResType &res_type,
bool is_strict,
ObCastCtx &cast_ctx,
const ObIArray<ObString> *type_infos,
const ObString *column_info)
{
int ret = OB_SUCCESS;
ObObjType type = res_type.get_type();
const ObAccuracy& accuracy = res_type.get_accuracy();
const ObAccuracy &accuracy = res_type.get_accuracy();
ObCollationType collation_type = res_type.get_collation_type();
bool is_not_null = res_type.has_result_flag(OB_MYSQL_NOT_NULL_FLAG);
const ObObj* res_obj = NULL;
const ObObj *res_obj = NULL;
cast_ctx.expect_obj_collation_ = collation_type;
cast_ctx.dest_collation_ = collation_type;
@ -182,60 +182,60 @@ int ObExprColumnConv::convert_skip_null_check(ObObj& result, const ObObj& obj, c
LOG_DEBUG("succ to to_type", K(type), K(obj), K(result), K(collation_type));
}
if (OB_SUCC(ret)) {
const int64_t max_accuracy_len = static_cast<int64_t>(res_type.get_accuracy().get_length());
const int64_t max_accuracy_len = static_cast<int64_t>(res_type.
get_accuracy().get_length());
const int64_t str_len_byte = static_cast<int64_t>(result.get_string_len());
if (OB_FAIL(obj_collation_check(is_strict, collation_type, *const_cast<ObObj*>(res_obj)))) {
LOG_WARN("failed to check collation", K(ret), K(collation_type), KPC(res_obj));
} else if (OB_FAIL(obj_accuracy_check(cast_ctx, accuracy, collation_type, *res_obj, result, res_obj))) {
LOG_WARN("failed to check accuracy", K(ret), K(accuracy), K(collation_type), KPC(res_obj));
if (OB_ERR_DATA_TOO_LONG == ret && lib::is_oracle_mode() && OB_NOT_NULL(column_info) && !column_info->empty()) {
if (OB_ERR_DATA_TOO_LONG == ret && lib::is_oracle_mode()
&& OB_NOT_NULL(column_info) && !column_info->empty()) {
ObString column_info_connection;
ObArenaAllocator allocator;
ObSQLUtils::copy_and_convert_string_charset(allocator,
*column_info,
column_info_connection,
CS_TYPE_UTF8MB4_BIN,
cast_ctx.dtc_params_.connection_collation_);
LOG_ORACLE_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2,
column_info_connection.length(),
column_info_connection.ptr(),
str_len_byte,
max_accuracy_len);
ObSQLUtils::copy_and_convert_string_charset(allocator, *column_info,
column_info_connection, CS_TYPE_UTF8MB4_BIN,
cast_ctx.dtc_params_.connection_collation_);
LOG_ORACLE_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2, column_info_connection.length(),
column_info_connection.ptr(), str_len_byte, max_accuracy_len);
}
}
}
if (OB_SUCC(ret)) {
if (res_obj != &result) {
// res_obj does not point to the address of result, need to copy the value of res_obj to result
//res_obj没有指向result的地址,需要将res_obj的值拷贝到result
result = *res_obj;
}
// if (is_not_null && (result.is_null() || (is_oracle_mode() && result.is_null_oracle()))) {
// ret = OB_BAD_NULL_ERROR;
// LOG_WARN("Column should not be null", K(ret));
// }
// if (is_not_null && (result.is_null() || (is_oracle_mode() && result.is_null_oracle()))) {
// ret = OB_BAD_NULL_ERROR;
// LOG_WARN("Column should not be null", K(ret));
// }
}
return ret;
}
int ObExprColumnConv::calc_result_typeN(
ObExprResType& type, ObExprResType* types, int64_t param_num, common::ObExprTypeCtx& type_ctx) const
int ObExprColumnConv::calc_result_typeN(ObExprResType &type,
ObExprResType *types,
int64_t param_num,
common::ObExprTypeCtx &type_ctx) const
{
int ret = common::OB_SUCCESS;
// objs[0] type
// objs[1] collation_type
// objs[2] accuray_expr
// objs[3] nullable_expr
// objs[4] value
// objs[5] column_info
//objs[0] type
//objs[1] collation_type
//objs[2] accuray_expr
//objs[3] nullable_expr
//objs[4] value
//objs[5] column_info
ObCollationType coll_type = CS_TYPE_INVALID;
if (OB_ISNULL(type_ctx.get_session()) || OB_ISNULL(type_ctx.get_raw_expr())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is NULL or raw expr is NULL", K(ret));
} else if (OB_UNLIKELY(
((PARAMS_COUNT_WITHOUT_COLUMN_INFO != param_num) && (PARAMS_COUNT_WITH_COLUMN_INFO != param_num)) ||
OB_ISNULL(types))) {
} else if (OB_UNLIKELY(((PARAMS_COUNT_WITHOUT_COLUMN_INFO != param_num)
&& (PARAMS_COUNT_WITH_COLUMN_INFO != param_num))
|| OB_ISNULL(types))) {
ret = OB_INVALID_ARGUMENT;
SQL_ENG_LOG(WARN, "invalid argument, param_num should be 5 or 6", K(param_num), K(types), K(ret));
SQL_ENG_LOG(WARN, "invalid argument, param_num should be 5 or 6",
K(param_num), K(types), K(ret));
} else if (OB_FAIL(type_ctx.get_session()->get_collation_connection(coll_type))) {
SQL_ENG_LOG(WARN, "fail to get_collation_connection", K(coll_type), K(ret));
} else {
@ -243,12 +243,12 @@ int ObExprColumnConv::calc_result_typeN(
type.set_collation_type(types[1].get_collation_type());
type.set_collation_level(common::CS_LEVEL_IMPLICIT);
type.set_accuracy(types[2].get_accuracy());
if (types[3].is_not_null()) {
type.set_result_flag(OB_MYSQL_NOT_NULL_FLAG);
if (types[3].is_not_null_for_read()) {
type.set_result_flag(NOT_NULL_FLAG | NOT_NULL_WRITE_FLAG);
}
bool enumset_to_varchar = false;
// here will wrap type_to_str if necessary
//here will wrap type_to_str if necessary
if (ob_is_enumset_tc(types[4].get_type())) {
ObObjType calc_type = enumset_calc_types_[OBJ_TYPE_TO_CLASS[types[0].get_type()]];
if (OB_UNLIKELY(ObMaxType == calc_type)) {
@ -259,24 +259,26 @@ int ObExprColumnConv::calc_result_typeN(
types[4].set_calc_type(calc_type);
types[4].set_calc_collation_type(coll_type);
types[4].set_calc_collation_level(CS_LEVEL_IMPLICIT);
if (type_ctx.get_session()->use_static_typing_engine()) {
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | type_ctx.get_raw_expr()->get_extra());
}
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | type_ctx.get_raw_expr()->get_extra());
}
}
// for table modify in oracle mode, we ignore charset convert failed
if (OB_SUCC(ret) && lib::is_oracle_mode()) {
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_CHARSET_CONVERT_IGNORE_ERR);
}
if (OB_SUCC(ret) && !enumset_to_varchar) {
// cast type when type not same.
//cast type when type not same.
const ObObjTypeClass value_tc = ob_obj_type_class(types[4].get_type());
const ObObjTypeClass type_tc = ob_obj_type_class(types[0].get_type());
if (lib::is_oracle_mode() && OB_UNLIKELY(!cast_supported(types[4].get_type(),
types[4].get_collation_type(),
types[0].get_type(),
types[1].get_collation_type()))) {
if (lib::is_oracle_mode()
&& OB_UNLIKELY(!cast_supported(types[4].get_type(), types[4].get_collation_type(),
types[0].get_type(), types[1].get_collation_type()))) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("inconsistent datatypes", "expected", type_tc, "got", value_tc);
} else if (type_ctx.get_session()->use_static_typing_engine()) {
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | type_ctx.get_raw_expr()->get_extra() | CM_COLUMN_CONVERT);
} else {
type_ctx.set_cast_mode(
type_ctx.get_cast_mode() | type_ctx.get_raw_expr()->get_extra() | CM_COLUMN_CONVERT);
types[4].set_calc_meta(type);
}
}
@ -285,30 +287,35 @@ int ObExprColumnConv::calc_result_typeN(
return ret;
}
int ObExprColumnConv::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
int ObExprColumnConv::cg_expr(ObExprCGCtx &op_cg_ctx,
const ObRawExpr &raw_expr,
ObExpr &rt_expr) const
{
int ret = OB_SUCCESS;
UNUSED(raw_expr);
// compatible with old code
CK((PARAMS_COUNT_WITHOUT_COLUMN_INFO == rt_expr.arg_cnt_) || (PARAMS_COUNT_WITH_COLUMN_INFO == rt_expr.arg_cnt_));
if (OB_ISNULL(op_cg_ctx.exec_ctx_)) {
//compatible with old code
CK((PARAMS_COUNT_WITHOUT_COLUMN_INFO == rt_expr.arg_cnt_)
|| (PARAMS_COUNT_WITH_COLUMN_INFO == rt_expr.arg_cnt_));
if (OB_ISNULL(op_cg_ctx.session_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("exec ctx is null", K(ret));
} else if (OB_FAIL(ObEnumSetInfo::init_enum_set_info(
op_cg_ctx.allocator_, rt_expr, type_, raw_expr.get_extra(), str_values_))) {
} else if (OB_FAIL(ObEnumSetInfo::init_enum_set_info(op_cg_ctx.allocator_, rt_expr, type_,
raw_expr.get_extra(), str_values_))) {
LOG_WARN("fail to init_enum_set_info", K(ret), K(type_), K(str_values_));
} else {
ObPhysicalPlanCtx* plan_ctx = GET_PHY_PLAN_CTX(*op_cg_ctx.exec_ctx_);
if (plan_ctx->is_ignore_stmt()) {
ObEnumSetInfo* enumset_info = static_cast<ObEnumSetInfo*>(rt_expr.extra_info_);
enumset_info->cast_mode_ = enumset_info->cast_mode_ | CM_WARN_ON_FAIL | CM_CHARSET_CONVERT_IGNORE_ERR;
if (op_cg_ctx.session_->is_ignore_stmt()) {
ObEnumSetInfo *enumset_info = static_cast<ObEnumSetInfo *>(rt_expr.extra_info_);
enumset_info->cast_mode_ = enumset_info->cast_mode_ | CM_WARN_ON_FAIL
| CM_CHARSET_CONVERT_IGNORE_ERR;
}
rt_expr.eval_func_ = column_convert;
}
return ret;
}
int ObExprColumnConv::column_convert(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
int ObExprColumnConv::column_convert(const ObExpr &expr,
ObEvalCtx &ctx,
ObDatum &datum)
{
int ret = OB_SUCCESS;
int warning = OB_SUCCESS;
@ -316,14 +323,14 @@ int ObExprColumnConv::column_convert(const ObExpr& expr, ObEvalCtx& ctx, ObDatum
ret = OB_ERR_UNEXPECTED;
LOG_WARN("extra_info_ is unexpected", K(ret), KP(expr.extra_info_));
} else {
const ObEnumSetInfo* enumset_info = static_cast<ObEnumSetInfo*>(expr.extra_info_);
const ObEnumSetInfo *enumset_info = static_cast<ObEnumSetInfo *>(expr.extra_info_);
const uint64_t cast_mode = enumset_info->cast_mode_;
bool is_strict = CM_IS_STRICT_MODE(cast_mode);
ObObjType out_type = expr.datum_meta_.type_;
ObCollationType out_cs_type = expr.datum_meta_.cs_type_;
ObDatum* val = NULL;
ObDatum *val = NULL;
if (ob_is_enum_or_set_type(out_type) && !expr.args_[4]->obj_meta_.is_enum_or_set()) {
ObExpr* old_expr = expr.args_[0];
ObExpr *old_expr = expr.args_[0];
expr.args_[0] = expr.args_[4];
if (OB_FAIL(expr.eval_enumset(ctx, enumset_info->str_values_, cast_mode, val))) {
LOG_WARN("fail to eval_enumset", KPC(enumset_info), K(ret));
@ -350,20 +357,24 @@ int ObExprColumnConv::column_convert(const ObExpr& expr, ObEvalCtx& ctx, ObDatum
if (OB_SUCC(ret)) {
const int64_t max_accuracy_len = static_cast<int64_t>(expr.max_length_);
const int64_t str_len_byte = static_cast<int64_t>(val->len_);
if (OB_FAIL(datum_accuracy_check(expr, cast_mode, ctx, *val, datum, warning))) {
LOG_WARN("fail to check accuracy", K(ret), K(datum), K(expr), K(warning));
if (OB_ERR_DATA_TOO_LONG == ret && PARAMS_COUNT_WITH_COLUMN_INFO == expr.arg_cnt_) {
if (OB_FAIL(datum_accuracy_check(expr,
cast_mode,
ctx,
*val,
datum,
warning))) {
LOG_WARN("fail to check accuracy", K(ret), K(expr), K(warning));
//compatible with old code
if (OB_ERR_DATA_TOO_LONG == ret && lib::is_oracle_mode()
&& PARAMS_COUNT_WITH_COLUMN_INFO == expr.arg_cnt_) {
ObString column_info_str;
ObDatum* column_info = NULL;
ObDatum *column_info = NULL;
if (OB_FAIL(expr.args_[5]->eval(ctx, column_info))) {
LOG_WARN("evaluate parameter failed", K(ret));
} else {
column_info_str = column_info->get_string();
LOG_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2,
column_info_str.length(),
column_info_str.ptr(),
str_len_byte,
max_accuracy_len);
LOG_ORACLE_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2, column_info_str.length(),
column_info_str.ptr(), str_len_byte, max_accuracy_len);
}
ret = OB_ERR_DATA_TOO_LONG;
}
@ -376,8 +387,8 @@ int ObExprColumnConv::column_convert(const ObExpr& expr, ObEvalCtx& ctx, ObDatum
return ret;
}
// TODO():(duplicate_with_type_to_str, remove later
int ObBaseExprColumnConv::shallow_copy_str_values(const common::ObIArray<common::ObString>& str_values)
//TODO(yaoying.yyy):(duplicate_with_type_to_str, remove later
int ObBaseExprColumnConv::shallow_copy_str_values(const common::ObIArray<common::ObString> &str_values)
{
int ret = OB_SUCCESS;
str_values_.reset();
@ -386,12 +397,11 @@ int ObBaseExprColumnConv::shallow_copy_str_values(const common::ObIArray<common:
LOG_WARN("invalid str_values", K(str_values), K(ret));
} else if (OB_FAIL(str_values_.assign(str_values))) {
LOG_WARN("fail to assign str values", K(ret));
} else { /*do nothing*/
}
} else {/*do nothing*/}
return ret;
}
int ObBaseExprColumnConv::deep_copy_str_values(const ObIArray<ObString>& str_values)
int ObBaseExprColumnConv::deep_copy_str_values(const ObIArray<ObString> &str_values)
{
int ret = OB_SUCCESS;
str_values_.reset();
@ -400,16 +410,15 @@ int ObBaseExprColumnConv::deep_copy_str_values(const ObIArray<ObString>& str_val
LOG_WARN("invalid str_values", K(str_values), K(ret));
} else if (OB_FAIL(str_values_.reserve(str_values.count()))) {
LOG_WARN("fail to init str_values_", K(ret));
} else { /*do nothing*/
}
} else {/*do nothing*/}
for (int64_t i = 0; OB_SUCC(ret) && i < str_values.count(); ++i) {
const ObString& str = str_values.at(i);
char* buf = NULL;
const ObString &str = str_values.at(i);
char *buf = NULL;
ObString str_tmp;
if (str.empty()) {
// just keep str_tmp empty
} else if (OB_UNLIKELY(NULL == (buf = static_cast<char*>(alloc_.alloc(str.length()))))) {
//just keep str_tmp empty
} else if (OB_UNLIKELY(NULL == (buf = static_cast<char *>(alloc_.alloc(str.length()))))) {
ret = common::OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to allocate memory", K(i), K(str), K(ret));
} else {
@ -425,5 +434,5 @@ int ObBaseExprColumnConv::deep_copy_str_values(const ObIArray<ObString>& str_val
}
return ret;
}
} // namespace sql
} // namespace oceanbase
}//sql
}//oceanbase