1/*-------------------------------------------------------------------------
4 * routines to handle BitmapOr nodes.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/executor/nodeBitmapOr.c
13 *-------------------------------------------------------------------------
16 * ExecInitBitmapOr - initialize the BitmapOr node
17 * MultiExecBitmapOr - retrieve the result bitmap from the node
18 * ExecEndBitmapOr - shut down the BitmapOr node
19 * ExecReScanBitmapOr - rescan the BitmapOr node
22 * BitmapOr nodes don't make use of their left and right
23 * subtrees, rather they maintain a list of subplans,
24 * much like Append nodes. The logic is much simpler than
25 * Append, however, since we needn't cope with forward/backward
36/* ----------------------------------------------------------------
39 * stub for pro forma compliance
40 * ----------------------------------------------------------------
45 elog(
ERROR,
"BitmapOr node does not support ExecProcNode call convention");
49/* ----------------------------------------------------------------
52 * Begin all of the subscans of the BitmapOr node.
53 * ----------------------------------------------------------------
65 /* check for unsupported flags */
69 * Set up empty vector of subplan states
76 * create new BitmapOrState for our BitmapOr node
79 bitmaporstate->
ps.
state = estate;
82 bitmaporstate->
nplans = nplans;
85 * call ExecInitNode on each of the plans to be executed and save the
86 * results into the array "bitmapplanstates".
97 * Miscellaneous initialization
99 * BitmapOr plans don't have expression contexts because they never call
100 * ExecQual or ExecProject. They don't need any tuple slots either.
103 return bitmaporstate;
106/* ----------------------------------------------------------------
108 * ----------------------------------------------------------------
118 /* must provide our own instrumentation support */
123 * get information from the node
129 * Scan all the subplans and OR their result bitmaps
131 for (
i = 0;
i < nplans;
i++)
137 * We can special-case BitmapIndexScan children to avoid an explicit
138 * tbm_union step for each child: just pass down the current result
139 * bitmap and let the child OR directly into it.
143 if (result == NULL)
/* first subplan */
145 /* XXX should we use less than work_mem for this? */
155 if (subresult != result)
156 elog(
ERROR,
"unrecognized result from subplan");
160 /* standard implementation */
164 elog(
ERROR,
"unrecognized result from subplan");
167 result = subresult;
/* first subplan */
176 /* We could return an empty result set here? */
178 elog(
ERROR,
"BitmapOr doesn't support zero inputs");
180 /* must provide our own instrumentation support */
184 return (
Node *) result;
187/* ----------------------------------------------------------------
190 * Shuts down the subscans of the BitmapOr node.
192 * Returns nothing of interest.
193 * ----------------------------------------------------------------
203 * get information from the node
209 * shut down each of the subscans (that we've initialized)
211 for (
i = 0;
i < nplans;
i++)
228 * ExecReScan doesn't know about my subplans, so I have to do
229 * changed-parameter signaling myself.
235 * If chgParam of subnode is not null then plan will be re-scanned by
236 * first ExecProcNode.
void ExecReScan(PlanState *node)
Node * MultiExecProcNode(PlanState *node)
void ExecEndNode(PlanState *node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
#define EXEC_FLAG_BACKWARD
Assert(PointerIsAligned(start, uint64))
void InstrStartNode(Instrumentation *instr)
void InstrStopNode(Instrumentation *instr, double nTuples)
void * palloc0(Size size)
void ExecEndBitmapOr(BitmapOrState *node)
Node * MultiExecBitmapOr(BitmapOrState *node)
void ExecReScanBitmapOr(BitmapOrState *node)
BitmapOrState * ExecInitBitmapOr(BitmapOr *node, EState *estate, int eflags)
static TupleTableSlot * ExecBitmapOr(PlanState *pstate)
#define IsA(nodeptr, _type_)
static int list_length(const List *l)
struct dsa_area * es_query_dsa
Instrumentation * instrument
ExecProcNodeMtd ExecProcNode
void tbm_free(TIDBitmap *tbm)
void tbm_union(TIDBitmap *a, const TIDBitmap *b)
TIDBitmap * tbm_create(Size maxbytes, dsa_area *dsa)