From 9ddbc67e62c9c3c5fc9d539246b160677cbb7371 Mon Sep 17 00:00:00 2001 From: SetnameWang <1944647332@qq.com> Date: Tue, 29 Oct 2024 19:53:37 +0800 Subject: [PATCH] bugfix: fix NOT_EXISTS_SUBLINK logic while scan subplan for spq --- .../runtime/executor/nodeSubplan.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/gausskernel/runtime/executor/nodeSubplan.cpp b/src/gausskernel/runtime/executor/nodeSubplan.cpp index 5f78ba810..fe9319fe1 100644 --- a/src/gausskernel/runtime/executor/nodeSubplan.cpp +++ b/src/gausskernel/runtime/executor/nodeSubplan.cpp @@ -294,6 +294,13 @@ static Datum ExecScanSubPlan(SubPlanState* node, ExprContext* econtext, bool* is result = BoolGetDatum(true); break; } +#ifdef USE_SPQ + if (sub_link_type == NOT_EXISTS_SUBLINK) { + found = true; + result = BoolGetDatum(false); + break; + } +#endif if (sub_link_type == EXPR_SUBLINK) { /* cannot allow multiple input tuples for EXPR sublink */ @@ -1008,13 +1015,22 @@ void ExecSetParamPlan(SubPlanState* node, ExprContext* econtext) Assert(slot->tts_tupleDescriptor != NULL); int i = 1; +#ifdef USE_SPQ + if (sub_link_type == EXISTS_SUBLINK || sub_link_type == NOT_EXISTS_SUBLINK) { +#else if (sub_link_type == EXISTS_SUBLINK) { +#endif /* There can be only one setParam... */ int paramid = linitial_int(subplan->setParam); ParamExecData* prm = &(econtext->ecxt_param_exec_vals[paramid]); prm->execPlan = NULL; prm->value = BoolGetDatum(true); +#ifdef USE_SPQ + if (sub_link_type == NOT_EXISTS_SUBLINK) { + prm->value = BoolGetDatum(false); + } +#endif prm->isnull = false; found = true; break; @@ -1091,13 +1107,22 @@ void ExecSetParamPlan(SubPlanState* node, ExprContext* econtext) prm->value = node->curArray; prm->isnull = false; } else if (!found) { +#ifdef USE_SPQ + if (sub_link_type == EXISTS_SUBLINK || sub_link_type == NOT_EXISTS_SUBLINK) { +#else if (sub_link_type == EXISTS_SUBLINK) { +#endif /* There can be only one setParam... */ int paramid = linitial_int(subplan->setParam); ParamExecData* prm = &(econtext->ecxt_param_exec_vals[paramid]); prm->execPlan = NULL; prm->value = BoolGetDatum(false); +#ifdef USE_SPQ + if (sub_link_type == NOT_EXISTS_SUBLINK) { + prm->value = BoolGetDatum(true); + } +#endif prm->isnull = false; } else { foreach (l, subplan->setParam) {