PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nodeBitmapAnd.c File Reference
Include dependency graph for nodeBitmapAnd.c:

Go to the source code of this file.

Functions

static TupleTableSlotExecBitmapAnd (PlanState *pstate)
 
BitmapAndStateExecInitBitmapAnd (BitmapAnd *node, EState *estate, int eflags)
 
NodeMultiExecBitmapAnd (BitmapAndState *node)
 
void ExecEndBitmapAnd (BitmapAndState *node)
 
void ExecReScanBitmapAnd (BitmapAndState *node)
 

Function Documentation

◆ ExecBitmapAnd()

static TupleTableSlot * ExecBitmapAnd ( PlanState pstate)
static

Definition at line 45 of file nodeBitmapAnd.c.

46{
47 elog(ERROR, "BitmapAnd node does not support ExecProcNode call convention");
48 return NULL;
49}
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
static int fb(int x)

References elog, ERROR, and fb().

Referenced by ExecInitBitmapAnd().

◆ ExecEndBitmapAnd()

void ExecEndBitmapAnd ( BitmapAndState node)

Definition at line 181 of file nodeBitmapAnd.c.

182{
183 PlanState **bitmapplans;
184 int nplans;
185 int i;
186
187 /*
188 * get information from the node
189 */
190 bitmapplans = node->bitmapplans;
191 nplans = node->nplans;
192
193 /*
194 * shut down each of the subscans (that we've initialized)
195 */
196 for (i = 0; i < nplans; i++)
197 {
198 if (bitmapplans[i])
199 ExecEndNode(bitmapplans[i]);
200 }
201}
void ExecEndNode(PlanState *node)
int i
Definition isn.c:77
PlanState ** bitmapplans
Definition execnodes.h:1623

References BitmapAndState::bitmapplans, ExecEndNode(), i, and BitmapAndState::nplans.

Referenced by ExecEndNode().

◆ ExecInitBitmapAnd()

BitmapAndState * ExecInitBitmapAnd ( BitmapAnd node,
EState estate,
int  eflags 
)

Definition at line 58 of file nodeBitmapAnd.c.

59{
62 int nplans;
63 int i;
64 ListCell *l;
66
67 /* check for unsupported flags */
69
70 /*
71 * Set up empty vector of subplan states
72 */
73 nplans = list_length(node->bitmapplans);
74
75 bitmapplanstates = (PlanState **) palloc0(nplans * sizeof(PlanState *));
76
77 /*
78 * create new BitmapAndState for our BitmapAnd node
79 */
80 bitmapandstate->ps.plan = (Plan *) node;
81 bitmapandstate->ps.state = estate;
82 bitmapandstate->ps.ExecProcNode = ExecBitmapAnd;
83 bitmapandstate->bitmapplans = bitmapplanstates;
84 bitmapandstate->nplans = nplans;
85
86 /*
87 * call ExecInitNode on each of the plans to be executed and save the
88 * results into the array "bitmapplanstates".
89 */
90 i = 0;
91 foreach(l, node->bitmapplans)
92 {
93 initNode = (Plan *) lfirst(l);
94 bitmapplanstates[i] = ExecInitNode(initNode, estate, eflags);
95 i++;
96 }
97
98 /*
99 * Miscellaneous initialization
100 *
101 * BitmapAnd plans don't have expression contexts because they never call
102 * ExecQual or ExecProject. They don't need any tuple slots either.
103 */
104
105 return bitmapandstate;
106}
#define Assert(condition)
Definition c.h:943
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
#define EXEC_FLAG_BACKWARD
Definition executor.h:70
#define EXEC_FLAG_MARK
Definition executor.h:71
void * palloc0(Size size)
Definition mcxt.c:1420
static TupleTableSlot * ExecBitmapAnd(PlanState *pstate)
#define makeNode(_type_)
Definition nodes.h:161
#define lfirst(lc)
Definition pg_list.h:172
static int list_length(const List *l)
Definition pg_list.h:152
List * bitmapplans
Definition plannodes.h:513

References Assert, BitmapAnd::bitmapplans, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecBitmapAnd(), ExecInitNode(), fb(), i, lfirst, list_length(), makeNode, and palloc0().

Referenced by ExecInitNode().

◆ ExecReScanBitmapAnd()

void ExecReScanBitmapAnd ( BitmapAndState node)

Definition at line 204 of file nodeBitmapAnd.c.

205{
206 int i;
207
208 for (i = 0; i < node->nplans; i++)
209 {
210 PlanState *subnode = node->bitmapplans[i];
211
212 /*
213 * ExecReScan doesn't know about my subplans, so I have to do
214 * changed-parameter signaling myself.
215 */
216 if (node->ps.chgParam != NULL)
218
219 /*
220 * If chgParam of subnode is not null then plan will be re-scanned by
221 * first ExecProcNode.
222 */
223 if (subnode->chgParam == NULL)
225 }
226}
void ExecReScan(PlanState *node)
Definition execAmi.c:78
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition execUtils.c:936
PlanState ps
Definition execnodes.h:1622
Bitmapset * chgParam
Definition execnodes.h:1235

References BitmapAndState::bitmapplans, PlanState::chgParam, ExecReScan(), fb(), i, BitmapAndState::nplans, BitmapAndState::ps, and UpdateChangedParamSet().

Referenced by ExecReScan().

◆ MultiExecBitmapAnd()

Node * MultiExecBitmapAnd ( BitmapAndState node)

Definition at line 113 of file nodeBitmapAnd.c.

114{
115 PlanState **bitmapplans;
116 int nplans;
117 int i;
119
120 /* must provide our own instrumentation support */
121 if (node->ps.instrument)
123
124 /*
125 * get information from the node
126 */
127 bitmapplans = node->bitmapplans;
128 nplans = node->nplans;
129
130 /*
131 * Scan all the subplans and AND their result bitmaps
132 */
133 for (i = 0; i < nplans; i++)
134 {
135 PlanState *subnode = bitmapplans[i];
137
139
140 if (!subresult || !IsA(subresult, TIDBitmap))
141 elog(ERROR, "unrecognized result from subplan");
142
143 if (result == NULL)
144 result = subresult; /* first subplan */
145 else
146 {
149 }
150
151 /*
152 * If at any stage we have a completely empty bitmap, we can fall out
153 * without evaluating the remaining subplans, since ANDing them can no
154 * longer change the result. (Note: the fact that indxpath.c orders
155 * the subplans by selectivity should make this case more likely to
156 * occur.)
157 */
158 if (tbm_is_empty(result))
159 break;
160 }
161
162 if (result == NULL)
163 elog(ERROR, "BitmapAnd doesn't support zero inputs");
164
165 /* must provide our own instrumentation support */
166 if (node->ps.instrument)
167 InstrStopNode(node->ps.instrument, 0 /* XXX */ );
168
169 return (Node *) result;
170}
uint32 result
Node * MultiExecProcNode(PlanState *node)
void InstrStartNode(NodeInstrumentation *instr)
Definition instrument.c:132
void InstrStopNode(NodeInstrumentation *instr, double nTuples)
Definition instrument.c:139
#define IsA(nodeptr, _type_)
Definition nodes.h:164
Definition nodes.h:135
NodeInstrumentation * instrument
Definition execnodes.h:1211
void tbm_free(TIDBitmap *tbm)
Definition tidbitmap.c:312
bool tbm_is_empty(const TIDBitmap *tbm)
Definition tidbitmap.c:657
void tbm_intersect(TIDBitmap *a, const TIDBitmap *b)
Definition tidbitmap.c:528

References BitmapAndState::bitmapplans, elog, ERROR, fb(), i, InstrStartNode(), InstrStopNode(), PlanState::instrument, IsA, MultiExecProcNode(), BitmapAndState::nplans, BitmapAndState::ps, result, tbm_free(), tbm_intersect(), and tbm_is_empty().

Referenced by MultiExecProcNode().