MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecInitPruningContext

Function ExecInitPruningContext

src/backend/executor/execPartition.c:1978–2038  ·  view source on GitHub ↗

* Initialize a PartitionPruneContext for the given list of pruning steps. */

Source from the content-addressed store, hash-verified

1976 * Initialize a PartitionPruneContext for the given list of pruning steps.
1977 */
1978static void
1979ExecInitPruningContext(PartitionPruneContext *context,
1980 List *pruning_steps,
1981 PartitionDesc partdesc,
1982 PartitionKey partkey,
1983 PlanState *planstate)
1984{
1985 int n_steps;
1986 int partnatts;
1987 ListCell *lc;
1988
1989 n_steps = list_length(pruning_steps);
1990
1991 context->strategy = partkey->strategy;
1992 context->partnatts = partnatts = partkey->partnatts;
1993 context->nparts = partdesc->nparts;
1994 context->boundinfo = partdesc->boundinfo;
1995 context->partcollation = partkey->partcollation;
1996 context->partsupfunc = partkey->partsupfunc;
1997
1998 /* We'll look up type-specific support functions as needed */
1999 context->stepcmpfuncs = (FmgrInfo *)
2000 palloc0(sizeof(FmgrInfo) * n_steps * partnatts);
2001
2002 context->ppccontext = CurrentMemoryContext;
2003 context->planstate = planstate;
2004
2005 /* Initialize expression state for each expression we need */
2006 context->exprstates = (ExprState **)
2007 palloc0(sizeof(ExprState *) * n_steps * partnatts);
2008 foreach(lc, pruning_steps)
2009 {
2010 PartitionPruneStepOp *step = (PartitionPruneStepOp *) lfirst(lc);
2011 ListCell *lc2;
2012 int keyno;
2013
2014 /* not needed for other step kinds */
2015 if (!IsA(step, PartitionPruneStepOp))
2016 continue;
2017
2018 Assert(list_length(step->exprs) <= partnatts);
2019
2020 keyno = 0;
2021 foreach(lc2, step->exprs)
2022 {
2023 Expr *expr = (Expr *) lfirst(lc2);
2024
2025 /* not needed for Consts */
2026 if (!IsA(expr, Const))
2027 {
2028 int stateidx = PruneCxtStateIdx(partnatts,
2029 step->step.step_id,
2030 keyno);
2031
2032 context->exprstates[stateidx] =
2033 ExecInitExpr(expr, context->planstate);
2034 }
2035 keyno++;

Callers 1

Calls 4

list_lengthFunction · 0.85
ExecInitExprFunction · 0.85
palloc0Function · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected