diff --git a/deps/oblib/src/common/object/ob_object.cpp b/deps/oblib/src/common/object/ob_object.cpp index a5910b461b..7f4375bd11 100644 --- a/deps/oblib/src/common/object/ob_object.cpp +++ b/deps/oblib/src/common/object/ob_object.cpp @@ -560,8 +560,13 @@ int ObLobLocatorV2::get_disk_locator(ObString &disc_loc_buff) const COMMON_LOG(WARN, "Lob: get disk locator failed", K(ret)); } else { int64_t handle_size = reinterpret_cast(disk_loc) - reinterpret_cast(ptr_); - handle_size = size_ - handle_size; - disc_loc_buff.assign_ptr(reinterpret_cast(disk_loc), handle_size); + if (handle_size > size_) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get invalid handle size", K(ret), K(size_), K(disk_loc), K(ptr_)); + } else { + handle_size = size_ - handle_size; + disc_loc_buff.assign_ptr(reinterpret_cast(disk_loc), handle_size); + } } return ret; } @@ -624,8 +629,8 @@ bool ObLobLocatorV2::is_empty_lob() const bool bret = false; ObString disk_loc_buff; ObMemLobCommon *loc = reinterpret_cast(ptr_); - if (!has_lob_header_) { - bret = (ptr_ == NULL && size_ == 0); + if (!has_lob_header_ || size_ == 0) { + bret = (size_ == 0); } else if (!is_lob_disk_locator() && loc->is_simple()) { bret = (size_ - MEM_LOB_COMMON_HEADER_LEN == 0); } else if (OB_FAIL(get_disk_locator(disk_loc_buff))) { diff --git a/src/sql/engine/expr/ob_expr_initcap.cpp b/src/sql/engine/expr/ob_expr_initcap.cpp index b27a50b896..444fc08f84 100644 --- a/src/sql/engine/expr/ob_expr_initcap.cpp +++ b/src/sql/engine/expr/ob_expr_initcap.cpp @@ -176,7 +176,8 @@ int calc_initcap_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum) } else if (OB_FAIL(output_result.init(input_byte_len * case_multiply))) { LOG_WARN("init stringtext result failed"); } else if (input_byte_len == 0) { - output_result.set_result(); + // do nothing, let res_str become empty string + res_str.assign_ptr(NULL, 0); } else if (OB_FAIL(output_result.get_reserved_buffer(res_buf, buf_size))) { LOG_WARN("stringtext result reserve buffer failed"); } else { @@ -204,7 +205,7 @@ int calc_initcap_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum) } } if (OB_SUCC(ret)) { - if (0 == res_str.length() || ob_is_empty_lob(expr.datum_meta_.type_, res_datum, expr.obj_meta_.has_lob_header())) { + if (0 == res_str.length()) { // initcap is only for oracle mode. set res be null when string length is 0. res_datum.set_null(); } else { diff --git a/src/sql/resolver/dml/ob_dml_resolver.cpp b/src/sql/resolver/dml/ob_dml_resolver.cpp index bc07a45a45..4967acf46b 100755 --- a/src/sql/resolver/dml/ob_dml_resolver.cpp +++ b/src/sql/resolver/dml/ob_dml_resolver.cpp @@ -5877,6 +5877,10 @@ int ObDMLResolver::do_resolve_subquery_info(const ObSubQueryInfo &subquery_info, const ObExprResType &column_type = target_expr->get_result_type(); if (OB_FAIL(subquery_info.ref_expr_->add_column_type(column_type))) { LOG_WARN("add column type to subquery ref expr failed", K(ret)); + } else if (column_type.is_lob_storage() && !IS_CLUSTER_VERSION_BEFORE_4_1_0_0) { + ObExprResType &last_item = subquery_info.ref_expr_->get_column_types(). + at(subquery_info.ref_expr_->get_column_types().count() - 1); + last_item.set_has_lob_header(); } } } diff --git a/src/sql/resolver/expr/ob_raw_expr_util.cpp b/src/sql/resolver/expr/ob_raw_expr_util.cpp index c01248b77f..9c0f0eb800 100644 --- a/src/sql/resolver/expr/ob_raw_expr_util.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_util.cpp @@ -5714,7 +5714,7 @@ int ObRawExprUtils::init_column_expr(const ObColumnSchemaV2 &column_schema, ObCo column_schema.get_column_name_str().length()); column_expr.set_column_flags(column_schema.get_column_flags()); column_expr.set_hidden_column(column_schema.is_hidden()); - column_expr.set_lob_column(ob_is_text_tc(column_schema.get_data_type())); + column_expr.set_lob_column(is_lob_storage(column_schema.get_data_type())); column_expr.set_is_rowkey_column(column_schema.is_rowkey_column()); column_expr.set_srs_id(column_schema.get_srs_id()); if (ob_is_string_type(column_schema.get_data_type())