diff --git a/src/pl/ob_pl_resolver.cpp b/src/pl/ob_pl_resolver.cpp index 8d46eea110..683a525b6c 100644 --- a/src/pl/ob_pl_resolver.cpp +++ b/src/pl/ob_pl_resolver.cpp @@ -4456,11 +4456,11 @@ int ObPLResolver::resolve_cursor_for_loop( const ObPLCursor *cursor = stmt->get_cursor(); if (OB_FAIL(stmt->get_var(var))) { LOG_WARN("failed to get var", K(ret)); - } else if (OB_ISNULL(cursor) || OB_ISNULL(var)) { + } else if (OB_ISNULL(cursor)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("value is NULL", K(ret)); } else if (ObPLCursor::DEFINED != cursor->get_state()) { - if (var->get_pl_data_type().is_ref_cursor_type()) { + if (OB_NOT_NULL(var) && var->get_pl_data_type().is_ref_cursor_type()) { ret = OB_ERR_UNDEFINED; LOG_WARN("ref cursor not defined", KPC(var), K(ret)); LOG_USER_ERROR(OB_ERR_UNDEFINED, var->get_name().ptr()); diff --git a/src/pl/ob_pl_user_type.cpp b/src/pl/ob_pl_user_type.cpp index a7a5bc47ea..e895ed8f86 100644 --- a/src/pl/ob_pl_user_type.cpp +++ b/src/pl/ob_pl_user_type.cpp @@ -1849,7 +1849,6 @@ int ObCollectionType::newx(common::ObIAllocator &allocator, const ObPLINS *ns, i OX (new (table)class(user_type_id_)); \ OX (collection_allocator = new(collection_allocator)ObPLCollAllocator(table)); \ OX (table->set_allocator(collection_allocator)); \ - OX (table->set_count(0)); \ if (OB_SUCC(ret)) { \ ObElemDesc elem_desc; \ elem_desc.set_pl_type(element_type_.get_type()); \ diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 8f3cd4ecdf..aadbc5509f 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -5486,6 +5486,11 @@ int ObSPIService::spi_set_collection(int64_t tenant_id, CK (type->is_collection_type()); CK (OB_NOT_NULL(collection_type = static_cast(type))); OZ (collection_type->get_element_type().newx(*coll.get_allocator(), ns, ptr)); + if (OB_SUCC(ret) && collection_type->get_element_type().is_collection_type()) { + ObPLCollection *collection = NULL; + CK (OB_NOT_NULL(collection = reinterpret_cast(ptr))); + OX (collection->set_count(0)); + } OZ (collection_type->get_element_type().get_size(*ns, PL_TYPE_INIT_SIZE, init_size)); OX (row->set_extend(ptr, collection_type->get_element_type().get_type(), init_size)); }