[to #2024122000106577236] fix assign null to refcursor

This commit is contained in:
obdev 2025-01-01 11:45:03 +00:00 committed by ob-robot
parent f46f1268ee
commit 69cfd4405e
2 changed files with 12 additions and 7 deletions

View File

@ -211,11 +211,15 @@ int ObExprPLGetCursorAttr::calc_pl_get_cursor_attr(
if (info->pl_cursor_info_.is_explicit_cursor()) {
CK (ObExtendType == datum_meta.type_);
OX (datum->to_obj(obj, obj_meta));
if (OB_SUCC(ret)
&& obj.get_meta().get_extend_type() != pl::PL_CURSOR_TYPE
&& obj.get_meta().get_extend_type() != pl::PL_REF_CURSOR_TYPE) {
ret = OB_ERR_CURSOR_ATTR_APPLY;
LOG_WARN("cursor attribute may not applied to non-cursor", K(ret), K(obj.get_meta()));
if (OB_SUCC(ret)) {
if (obj.is_null()) {
// do nothing, null cursor is legal...
} else if (!obj.is_ext()
|| (obj.get_meta().get_extend_type() != pl::PL_CURSOR_TYPE
&& obj.get_meta().get_extend_type() != pl::PL_REF_CURSOR_TYPE)) {
ret = OB_ERR_CURSOR_ATTR_APPLY;
LOG_WARN("cursor attribute may not applied to non-cursor", K(ret), K(obj.get_meta()));
}
}
OX (cursor = reinterpret_cast<const pl::ObPLCursorInfo*>(obj.get_ext()));
} else {

View File

@ -5864,13 +5864,14 @@ int ObSPIService::spi_copy_ref_cursor(ObPLExecCtx *ctx,
// 到了这里先把returning状态重置,ref count先不加,等赋值成功再加
OX (src_cursor->set_is_returning(false));
}
if (src_cursor == dest_cursor) {
if (OB_FAIL(ret)) {
} else if (src_cursor == dest_cursor) {
// 说明指向同一个内存,或者都为null, 这个时候应该不干,除了一个特殊的场景,即return场景,需要将count+1
// 例如: c1 := c2; c1 := c2; c2 may null or not null;
if (need_inc_ref_cnt) {
OX (src_cursor->inc_ref_count());
}
} else if (!src_cursor->isopen() && 0 == src_cursor->get_ref_count() && NULL == dest_cursor) {
} else if (OB_NOT_NULL(src_cursor) && !src_cursor->isopen() && 0 == src_cursor->get_ref_count() && NULL == dest_cursor) {
// src cursor is already closed and do not has any ref
// dest cursor is null do not need copy
} else {