issue/47511246 json obj_compare adapt lob
This commit is contained in:
55
deps/oblib/src/common/object/ob_obj_compare.cpp
vendored
55
deps/oblib/src/common/object/ob_obj_compare.cpp
vendored
@ -1323,20 +1323,36 @@ int ObObjCmpFuncs::cmp_func<ObEnumSetTC, ObUIntTC>(const ObObj &obj1, \
|
|||||||
int cmp_ret = CR_OB_ERROR; \
|
int cmp_ret = CR_OB_ERROR; \
|
||||||
int ret = OB_SUCCESS; \
|
int ret = OB_SUCCESS; \
|
||||||
int result = 0; \
|
int result = 0; \
|
||||||
ObJsonBin j_bin1(obj1.v_.string_, obj1.val_len_); \
|
ObString data_str1; \
|
||||||
ObJsonBin j_bin2(obj2.v_.string_, obj2.val_len_); \
|
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 { \
|
||||||
|
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_base1 = &j_bin1; \
|
||||||
ObIJsonBase *j_base2 = &j_bin2; \
|
ObIJsonBase *j_base2 = &j_bin2; \
|
||||||
if (OB_FAIL(j_bin1.reset_iter())) { \
|
if (OB_FAIL(j_bin1.reset_iter())) { \
|
||||||
LOG_WARN("fail to reset json bin1 iter", K(ret), K(obj1.val_len_)); \
|
LOG_WARN("fail to reset json bin1 iter", K(ret), K(data_str1.length())); \
|
||||||
} else if (OB_FAIL(j_bin2.reset_iter())) { \
|
} else if (OB_FAIL(j_bin2.reset_iter())) { \
|
||||||
LOG_WARN("fail to reset json bin2 iter", K(ret), K(obj2.val_len_)); \
|
LOG_WARN("fail to reset json bin2 iter", K(ret), K(data_str2.length())); \
|
||||||
} else if (OB_FAIL(j_base1->compare(*j_base2, result))) { \
|
} 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_)); \
|
LOG_WARN("fail to compare json", K(ret), K(data_str1.length()), K(data_str2.length())); \
|
||||||
} else { \
|
} else { \
|
||||||
cmp_ret = result op_str 0; \
|
cmp_ret = result op_str 0; \
|
||||||
} \
|
} \
|
||||||
\
|
} \
|
||||||
return cmp_ret; \
|
return cmp_ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1351,18 +1367,35 @@ int ObObjCmpFuncs::cmp_func<ObEnumSetTC, ObUIntTC>(const ObObj &obj1, \
|
|||||||
UNUSED(cmp_ctx); \
|
UNUSED(cmp_ctx); \
|
||||||
int ret = OB_SUCCESS; \
|
int ret = OB_SUCCESS; \
|
||||||
int result = CR_OB_ERROR; \
|
int result = CR_OB_ERROR; \
|
||||||
ObJsonBin j_bin1(obj1.v_.string_, obj1.val_len_); \
|
ObString data_str1; \
|
||||||
ObJsonBin j_bin2(obj2.v_.string_, obj2.val_len_); \
|
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 { \
|
||||||
|
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_base1 = &j_bin1; \
|
||||||
ObIJsonBase *j_base2 = &j_bin2; \
|
ObIJsonBase *j_base2 = &j_bin2; \
|
||||||
if (OB_FAIL(j_bin1.reset_iter())) { \
|
if (OB_FAIL(j_bin1.reset_iter())) { \
|
||||||
LOG_WARN("fail to reset json bin1 iter", K(ret), K(obj1.val_len_)); \
|
LOG_WARN("fail to reset json bin1 iter", K(ret), K(data_str1.length())); \
|
||||||
} else if (OB_FAIL(j_bin2.reset_iter())) { \
|
} else if (OB_FAIL(j_bin2.reset_iter())) { \
|
||||||
LOG_WARN("fail to reset json bin2 iter", K(ret), K(obj2.val_len_)); \
|
LOG_WARN("fail to reset json bin2 iter", K(ret), K(data_str2.length())); \
|
||||||
} else if (OB_FAIL(j_base1->compare(*j_base2, result))) { \
|
} 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_)); \
|
LOG_WARN("fail to compare json", K(ret), K(data_str1.length()), K(data_str2.length())); \
|
||||||
} else { \
|
} else { \
|
||||||
result = INT_TO_CR(result); \
|
result = INT_TO_CR(result); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return result; \
|
return result; \
|
||||||
|
|||||||
4
deps/oblib/src/lib/json_type/ob_json_bin.cpp
vendored
4
deps/oblib/src/lib/json_type/ob_json_bin.cpp
vendored
@ -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;
|
int64_t pos = 0;
|
||||||
if (OB_FAIL(serialization::decode_i16(data_, curr_.length() - new_pos, pos, &prec))) {
|
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()));
|
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()));
|
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))) {
|
} 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 {
|
} else {
|
||||||
prec_ = prec;
|
prec_ = prec;
|
||||||
scale_ = scale;
|
scale_ = scale;
|
||||||
|
|||||||
@ -57,7 +57,10 @@ int ObJsonExprHelper::get_json_or_str_data(ObExpr *expr, ObEvalCtx &ctx,
|
|||||||
LOG_WARN("eval json arg failed", K(ret));
|
LOG_WARN("eval json arg failed", K(ret));
|
||||||
} else if (json_datum->is_null() || val_type == ObNullType) {
|
} else if (json_datum->is_null() || val_type == ObNullType) {
|
||||||
is_null = true;
|
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;
|
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||||
LOG_WARN("input type error", K(val_type));
|
LOG_WARN("input type error", K(val_type));
|
||||||
} else if (OB_FAIL(ObTextStringHelper::read_real_string_data(allocator, *json_datum,
|
} else if (OB_FAIL(ObTextStringHelper::read_real_string_data(allocator, *json_datum,
|
||||||
|
|||||||
@ -59,9 +59,6 @@ int ObExprTreat::calc_result_type2(ObExprResType &type,
|
|||||||
type.set_length(OB_MAX_SQL_LENGTH);
|
type.set_length(OB_MAX_SQL_LENGTH);
|
||||||
type.set_length_semantics(LS_CHAR);
|
type.set_length_semantics(LS_CHAR);
|
||||||
type.set_calc_type(ObJsonType);
|
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 {
|
} else {
|
||||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||||
LOG_WARN("target type not json", K(ret), K(type1), K(type2));
|
LOG_WARN("target type not json", K(ret), K(type1), K(type2));
|
||||||
|
|||||||
Reference in New Issue
Block a user