[to #51527424]fixed refcursor fetch bug

This commit is contained in:
LiuYoung00
2023-08-22 09:14:37 +00:00
committed by ob-robot
parent 0e8abd0b43
commit ddd3395763
3 changed files with 13 additions and 7 deletions

View File

@ -154,7 +154,8 @@ int ObMPStmtFetch::set_session_active(ObSQLSessionInfo &session) const
}
return ret;
}
int ObMPStmtFetch::do_process(ObSQLSessionInfo &session)
int ObMPStmtFetch::do_process(ObSQLSessionInfo &session,
bool &need_response_error)
{
int ret = OB_SUCCESS;
ObAuditRecordData &audit_record = session.get_raw_audit_record();
@ -197,7 +198,7 @@ int ObMPStmtFetch::do_process(ObSQLSessionInfo &session)
// 本分支内如果出错,全部会在response_result内部处理妥当
// 无需再额外处理回复错误包
session.set_current_execution_id(execution_id);
OX (need_response_error = false);
if (0 == fetch_limit && !cursor->is_streaming()
&& cursor->is_ps_cursor()
&& lib::is_oracle_mode()
@ -212,6 +213,7 @@ int ObMPStmtFetch::do_process(ObSQLSessionInfo &session)
// oracle return success when read nothing
ret = OB_SUCCESS;
}
OX (need_response_error = true);
}
//监控项统计结束
exec_end_timestamp_ = ObTimeUtility::current_time();
@ -601,7 +603,8 @@ int ObMPStmtFetch::response_result(pl::ObPLCursorInfo &cursor,
return ret;
}
int ObMPStmtFetch::process_fetch_stmt(ObSQLSessionInfo &session)
int ObMPStmtFetch::process_fetch_stmt(ObSQLSessionInfo &session,
bool &need_response_error)
{
int ret = OB_SUCCESS;
// 执行setup_wb后,所有WARNING都会写入到当前session的WARNING BUFFER中
@ -623,7 +626,7 @@ int ObMPStmtFetch::process_fetch_stmt(ObSQLSessionInfo &session)
LOG_WARN("update transmisson checksum flag failed", K(ret));
} else {
// do the real work
ret = do_process(session);
ret = do_process(session, need_response_error);
}
}
if (enable_trace_log) {
@ -718,7 +721,7 @@ int ObMPStmtFetch::process()
ObPLCursorInfo *cursor = NULL;
THIS_WORKER.set_timeout_ts(get_receive_timestamp() + query_timeout);
session.partition_hit().reset();
ret = process_fetch_stmt(session);
ret = process_fetch_stmt(session, need_response_error);
// set cursor fetched info. if cursor has be fetched, we need to disconnect
cursor = session.get_cursor(cursor_id_);
if (OB_NOT_NULL(cursor) && cursor->get_fetched()) {

View File

@ -74,9 +74,9 @@ protected:
virtual int deserialize() { return common::OB_SUCCESS; }
virtual int process();
private:
int do_process(sql::ObSQLSessionInfo &session);
int do_process(sql::ObSQLSessionInfo &session, bool &need_response_error);
int set_session_active(sql::ObSQLSessionInfo &session) const;
int process_fetch_stmt(sql::ObSQLSessionInfo &session);
int process_fetch_stmt(sql::ObSQLSessionInfo &session, bool &need_response_error);
int response_result(pl::ObPLCursorInfo &cursor,
sql::ObSQLSessionInfo &session,
int64_t fetch_limit,

View File

@ -5843,6 +5843,9 @@ int ObSPIService::spi_copy_ref_cursor(ObPLExecCtx *ctx,
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) {
// src cursor is already closed and do not has any ref
// dest cursor is null do not need copy
} else {
if (OB_NOT_NULL(dest_cursor) && dest_cursor->isopen()) {
LOG_DEBUG("copy ref cursor, dest ref count: ",K(*dest_cursor),