From 41ccc2f04605cf2b33304fec6c097ba812416400 Mon Sep 17 00:00:00 2001 From: totaj Date: Mon, 29 Jan 2024 14:35:44 +0800 Subject: [PATCH] Fix missing ignore in fmgr sql. --- src/gausskernel/runtime/executor/functions.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gausskernel/runtime/executor/functions.cpp b/src/gausskernel/runtime/executor/functions.cpp index 9873ef97d..3bd71ea38 100644 --- a/src/gausskernel/runtime/executor/functions.cpp +++ b/src/gausskernel/runtime/executor/functions.cpp @@ -165,8 +165,8 @@ static Node* sql_fn_param_ref(ParseState* p_state, ParamRef* p_ref); static Node* sql_fn_post_column_ref(ParseState* p_state, ColumnRef* c_ref, Node* var); static Node* sql_fn_make_param(SQLFunctionParseInfoPtr p_info, int param_no, int location); static Node* sql_fn_resolve_param_name(SQLFunctionParseInfoPtr p_info, const char* param_name, int location); -static List* init_execution_state(List* query_tree_list, SQLFunctionCachePtr fcache, bool lazy_eval_ok); -static void init_sql_fcache(FmgrInfo* finfo, Oid collation, bool lazy_eval_ok); +static List* init_execution_state(List* query_tree_list, SQLFunctionCachePtr fcache, bool lazy_eval_ok, bool can_ignore); +static void init_sql_fcache(FmgrInfo* finfo, Oid collation, bool lazy_eval_ok, bool can_ignore); static void postquel_start(execution_state* es, SQLFunctionCachePtr fcache); static bool postquel_getnext(execution_state* es, SQLFunctionCachePtr fcache); static void postquel_end(execution_state* es); @@ -467,7 +467,7 @@ static Node* sql_fn_resolve_param_name(SQLFunctionParseInfoPtr p_info, const cha * The input is a List of Lists of parsed and rewritten, but not planned, * querytrees. The sublist structure denotes the original query boundaries. */ -static List* init_execution_state(List* query_tree_list, SQLFunctionCachePtr fcache, bool lazy_eval_ok) +static List* init_execution_state(List* query_tree_list, SQLFunctionCachePtr fcache, bool lazy_eval_ok, bool can_ignore) { List* es_list = NIL; execution_state* last_tages = NULL; @@ -503,6 +503,9 @@ static List* init_execution_state(List* query_tree_list, SQLFunctionCachePtr fca PG_END_TRY(); recover_set_hint(nest_level); + if (likely(stmt != NULL && IsA(stmt, PlannedStmt))) { + ((PlannedStmt*)stmt)->hasIgnore = can_ignore; + } } /* Precheck all commands for validity in a function */ @@ -572,7 +575,7 @@ static List* init_execution_state(List* query_tree_list, SQLFunctionCachePtr fca /* * Initialize the SQLFunctionCache for a SQL function */ -static void init_sql_fcache(FmgrInfo* finfo, Oid collation, bool lazy_eval_ok) +static void init_sql_fcache(FmgrInfo* finfo, Oid collation, bool lazy_eval_ok, bool can_ignore) { Oid f_oid = finfo->fn_oid; MemoryContext f_context; @@ -748,7 +751,7 @@ static void init_sql_fcache(FmgrInfo* finfo, Oid collation, bool lazy_eval_ok) } /* Finally, plan the queries */ - fcache->func_state = init_execution_state(query_tree_list, fcache, lazy_eval_ok); + fcache->func_state = init_execution_state(query_tree_list, fcache, lazy_eval_ok, can_ignore); /* Mark fcache with time of creation to show it's valid */ fcache->lxid = t_thrd.proc->lxid; @@ -1123,7 +1126,7 @@ Datum fmgr_sql(PG_FUNCTION_ARGS) } if (fcache == NULL) { - init_sql_fcache(fcinfo->flinfo, PG_GET_COLLATION(), lazy_eval_ok); + init_sql_fcache(fcinfo->flinfo, PG_GET_COLLATION(), lazy_eval_ok, fcinfo->can_ignore); fcache = (SQLFunctionCachePtr)fcinfo->flinfo->fn_extra; }