From dec60a0f6e867839a6f298a4a1741c47ed45cc93 Mon Sep 17 00:00:00 2001 From: johnnyjiang1 Date: Fri, 4 Jul 2025 10:05:23 +0800 Subject: [PATCH] fix core when calling function in declaring cursor due to empty param_buf --- pkg/src/ctsql/pl/executor/pl_lines_executor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/src/ctsql/pl/executor/pl_lines_executor.c b/pkg/src/ctsql/pl/executor/pl_lines_executor.c index 5eb59020..1d81e628 100644 --- a/pkg/src/ctsql/pl/executor/pl_lines_executor.c +++ b/pkg/src/ctsql/pl/executor/pl_lines_executor.c @@ -1499,6 +1499,17 @@ status_t ple_open(ple_line_assist_t *line_ass) exec->recent_rows = sub_stmt->total_rows; sub_stmt->cursor_info.sql_executed = CT_TRUE; + if (sub_stmt->cursor_info.param_buf == NULL && exec->curr_input != NULL) { + if (ple_keep_input(sub_stmt, exec, (void *)exec->curr_input, exec->is_dyncur) != CT_SUCCESS) { + sql_free_stmt(sub_stmt); + ref_cursor->stmt_id = CT_INVALID_ID16; + ple_free_ref_cursor(ref_cursor); + var->value.v_cursor.ref_cursor = NULL; + PLE_RESTORE_STMT(stmt); + return CT_ERROR; + } + } + // sql is reparsed, sub stmt's context is changed if (ple_check_substmt_ctx(sub_stmt, save_ctx)) { // set procedure/function status to invalid -- Gitee