issue/47511246 json obj_compare adapt lob

This commit is contained in:
obdev
2023-02-06 19:45:27 +08:00
committed by ob-robot
parent 0e74af55d2
commit a6ba1d2999
4 changed files with 62 additions and 29 deletions

View File

@ -1323,20 +1323,36 @@ int ObObjCmpFuncs::cmp_func<ObEnumSetTC, ObUIntTC>(const ObObj &obj1, \
int cmp_ret = CR_OB_ERROR; \
int ret = OB_SUCCESS; \
int result = 0; \
ObJsonBin j_bin1(obj1.v_.string_, obj1.val_len_); \
ObJsonBin j_bin2(obj2.v_.string_, obj2.val_len_); \
ObIJsonBase *j_base1 = &j_bin1; \
ObIJsonBase *j_base2 = &j_bin2; \
if (OB_FAIL(j_bin1.reset_iter())) { \
LOG_WARN("fail to reset json bin1 iter", K(ret), K(obj1.val_len_)); \
} else if (OB_FAIL(j_bin2.reset_iter())) { \
LOG_WARN("fail to reset json bin2 iter", K(ret), K(obj2.val_len_)); \
} else if (OB_FAIL(j_base1->compare(*j_base2, result))) { \
LOG_WARN("fail to compare json", K(ret), K(obj1.val_len_), K(obj1.val_len_)); \
ObString data_str1; \
ObString data_str2; \
if (obj1.is_outrow_lob() || obj2.is_outrow_lob()) { \
LOG_ERROR("not support outrow json lobs", K(obj1), K(obj2)); \
ret = CR_OB_ERROR; \
} else if (OB_FAIL(obj1.get_string(data_str1))) { \
LOG_ERROR("invalid json lob object1", \
K(obj1.get_collation_type()), K(obj2.get_collation_type()), \
K(obj1), K(obj2)); \
ret = CR_OB_ERROR; \
} else if (OB_FAIL(obj2.get_string(data_str2))) { \
LOG_ERROR("invalid json lob object2", \
K(obj1.get_collation_type()), K(obj2.get_collation_type()), \
K(obj1), K(obj2)); \
ret = CR_OB_ERROR; \
} else { \
cmp_ret = result op_str 0; \
ObJsonBin j_bin1(data_str1.ptr(), data_str1.length()); \
ObJsonBin j_bin2(data_str2.ptr(), data_str2.length()); \
ObIJsonBase *j_base1 = &j_bin1; \
ObIJsonBase *j_base2 = &j_bin2; \
if (OB_FAIL(j_bin1.reset_iter())) { \
LOG_WARN("fail to reset json bin1 iter", K(ret), K(data_str1.length())); \
} else if (OB_FAIL(j_bin2.reset_iter())) { \
LOG_WARN("fail to reset json bin2 iter", K(ret), K(data_str2.length())); \
} else if (OB_FAIL(j_base1->compare(*j_base2, result))) { \
LOG_WARN("fail to compare json", K(ret), K(data_str1.length()), K(data_str2.length())); \
} else { \
cmp_ret = result op_str 0; \
} \
} \
\
return cmp_ret; \
}
@ -1351,18 +1367,35 @@ int ObObjCmpFuncs::cmp_func<ObEnumSetTC, ObUIntTC>(const ObObj &obj1, \
UNUSED(cmp_ctx); \
int ret = OB_SUCCESS; \
int result = CR_OB_ERROR; \
ObJsonBin j_bin1(obj1.v_.string_, obj1.val_len_); \
ObJsonBin j_bin2(obj2.v_.string_, obj2.val_len_); \
ObIJsonBase *j_base1 = &j_bin1; \
ObIJsonBase *j_base2 = &j_bin2; \
if (OB_FAIL(j_bin1.reset_iter())) { \
LOG_WARN("fail to reset json bin1 iter", K(ret), K(obj1.val_len_)); \
} else if (OB_FAIL(j_bin2.reset_iter())) { \
LOG_WARN("fail to reset json bin2 iter", K(ret), K(obj2.val_len_)); \
} else if (OB_FAIL(j_base1->compare(*j_base2, result))) { \
LOG_WARN("fail to compare json", K(ret), K(obj1.val_len_), K(obj1.val_len_)); \
ObString data_str1; \
ObString data_str2; \
if (obj1.is_outrow_lob() || obj2.is_outrow_lob()) { \
LOG_ERROR("not support outrow json lobs", K(obj1), K(obj2)); \
ret = CR_OB_ERROR; \
} else if (OB_FAIL(obj1.get_string(data_str1))) { \
LOG_ERROR("invalid json lob object1", \
K(obj1.get_collation_type()), K(obj2.get_collation_type()), \
K(obj1), K(obj2)); \
ret = CR_OB_ERROR; \
} else if (OB_FAIL(obj2.get_string(data_str2))) { \
LOG_ERROR("invalid json lob object2", \
K(obj1.get_collation_type()), K(obj2.get_collation_type()), \
K(obj1), K(obj2)); \
ret = CR_OB_ERROR; \
} else { \
result = INT_TO_CR(result); \
ObJsonBin j_bin1(data_str1.ptr(), data_str1.length()); \
ObJsonBin j_bin2(data_str2.ptr(), data_str2.length()); \
ObIJsonBase *j_base1 = &j_bin1; \
ObIJsonBase *j_base2 = &j_bin2; \
if (OB_FAIL(j_bin1.reset_iter())) { \
LOG_WARN("fail to reset json bin1 iter", K(ret), K(data_str1.length())); \
} else if (OB_FAIL(j_bin2.reset_iter())) { \
LOG_WARN("fail to reset json bin2 iter", K(ret), K(data_str2.length())); \
} else if (OB_FAIL(j_base1->compare(*j_base2, result))) { \
LOG_WARN("fail to compare json", K(ret), K(data_str1.length()), K(data_str2.length())); \
} else { \
result = INT_TO_CR(result); \
} \
} \
\
return result; \

View File

@ -1965,10 +1965,10 @@ int ObJsonBin::set_curr_by_type(int64_t new_pos, uint64_t val_offset, uint8_t ty
int64_t pos = 0;
if (OB_FAIL(serialization::decode_i16(data_, curr_.length() - new_pos, pos, &prec))) {
LOG_WARN("fail to deserialize decimal precision.", K(ret), K(new_pos), K(curr_.length()));
} else if (serialization::decode_i16(data_, curr_.length() - new_pos, pos, &scale)) {
} else if (OB_FAIL(serialization::decode_i16(data_, curr_.length() - new_pos, pos, &scale))) {
LOG_WARN("fail to deserialize decimal scale.", K(ret), K(new_pos), K(pos), K(curr_.length()));
} else if (OB_FAIL(number_.deserialize(data_, curr_.length() - new_pos, pos))) {
LOG_WARN("failed to deserialize decimal data", K(ret));
LOG_WARN("failed to deserialize decimal data", K(ret), K(new_pos), K(pos), K(curr_.length()));
} else {
prec_ = prec;
scale_ = scale;

View File

@ -57,7 +57,10 @@ int ObJsonExprHelper::get_json_or_str_data(ObExpr *expr, ObEvalCtx &ctx,
LOG_WARN("eval json arg failed", K(ret));
} else if (json_datum->is_null() || val_type == ObNullType) {
is_null = true;
} else if (val_type != ObExtendType && val_type != ObJsonType && !ob_is_string_type(val_type)) {
} else if (!ob_is_extend(val_type)
&& !ob_is_json(val_type)
&& !ob_is_raw(val_type)
&& !ob_is_string_type(val_type)) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("input type error", K(val_type));
} else if (OB_FAIL(ObTextStringHelper::read_real_string_data(allocator, *json_datum,

View File

@ -59,9 +59,6 @@ int ObExprTreat::calc_result_type2(ObExprResType &type,
type.set_length(OB_MAX_SQL_LENGTH);
type.set_length_semantics(LS_CHAR);
type.set_calc_type(ObJsonType);
} else if(ob_is_extend(as_type)){
type.set_type(ObExtendType);
type.set_udt_id(type2.get_udt_id());
} else {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("target type not json", K(ret), K(type1), K(type2));