Skip to content

Commit

Permalink
fix:json agg coredump when serialize string
Browse files Browse the repository at this point in the history
  • Loading branch information
obdev authored and ob-robot committed Aug 30, 2023
1 parent 0ca7c02 commit 7e912e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/sql/engine/expr/ob_expr_json_func_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,16 @@ int ObJsonExprHelper::oracle_datum2_json_val(const ObDatum *json_datum,

uint32_t parse_flag = ObJsonParser::JSN_RELAXED_FLAG;
ObString j_str = json_datum->get_string();
ObString out_str;
bool need_convert = (cs_type != CS_TYPE_INVALID && cs_type != CS_TYPE_BINARY);
if (OB_FAIL(ObTextStringHelper::read_real_string_data(
allocator, val_type, cs_type, data_meta.has_lob_header(), j_str))) {
LOG_WARN("fail to get real data.", K(ret), K(j_str));
} else if (need_convert && OB_FAIL(ObExprUtil::convert_string_collation(j_str, cs_type, j_str, CS_TYPE_UTF8MB4_BIN, *allocator))) {
} else if (need_convert && OB_FAIL(ObExprUtil::convert_string_collation(j_str, cs_type, out_str, CS_TYPE_UTF8MB4_BIN, *allocator))) {
LOG_WARN("fail to convert charset.", K(ret), K(j_str), K(cs_type));
} else if (!need_convert && OB_FAIL(deep_copy_ob_string(*allocator, j_str, j_str))) {
} else if ((!need_convert || out_str.ptr() == j_str.ptr()) && OB_FAIL(deep_copy_ob_string(*allocator, j_str, out_str))) {
LOG_WARN("fail to deep copy string.", K(ret), K(j_str));
} else if (FALSE_IT(j_str.assign_ptr(out_str.ptr(), out_str.length()))) {
} else if (!is_format_json || is_raw_type) {
if (is_raw_type) {
ObObj tmp_result;
Expand Down

0 comments on commit 7e912e0

Please sign in to comment.