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 44 of file nodeBitmapAnd.c.

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

References elog, ERROR, and fb().

Referenced by ExecInitBitmapAnd().

◆ ExecEndBitmapAnd()

void ExecEndBitmapAnd ( BitmapAndState node)

Definition at line 180 of file nodeBitmapAnd.c.

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

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

Referenced by ExecEndNode().

◆ ExecInitBitmapAnd()

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

Definition at line 57 of file nodeBitmapAnd.c.

58{
61 int nplans;
62 int i;
63 ListCell *l;
65
66 /* check for unsupported flags */
68
69 /*
70 * Set up empty vector of subplan states
71 */
72 nplans = list_length(node->bitmapplans);
73
74 bitmapplanstates = (PlanState **) palloc0(nplans * sizeof(PlanState *));
75
76 /*
77 * create new BitmapAndState for our BitmapAnd node
78 */
79 bitmapandstate->ps.plan = (Plan *) node;
80 bitmapandstate->ps.state = estate;
81 bitmapandstate->ps.ExecProcNode = ExecBitmapAnd;
82 bitmapandstate->bitmapplans = bitmapplanstates;
83 bitmapandstate->nplans = nplans;
84
85 /*
86 * call ExecInitNode on each of the plans to be executed and save the
87 * results into the array "bitmapplanstates".
88 */
89 i = 0;
90 foreach(l, node->bitmapplans)
91 {
92 initNode = (Plan *) lfirst(l);
93 bitmapplanstates[i] = ExecInitNode(initNode, estate, eflags);
94 i++;
95 }
96
97 /*
98 * Miscellaneous initialization
99 *
100 * BitmapAnd plans don't have expression contexts because they never call
101 * ExecQual or ExecProject. They don't need any tuple slots either.
102 */
103
104 return bitmapandstate;
105}
#define Assert(condition)
Definition c.h:945
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:1417
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:509

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 203 of file nodeBitmapAnd.c.

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

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 112 of file nodeBitmapAnd.c.

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

Referenced by MultiExecProcNode().