1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
/*-------------------------------------------------------------------------
*
* execAmi.c
* miscellaneous executor access method routines
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: execAmi.c,v 1.64 2002/06/20 20:29:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "catalog/heap.h"
#include "executor/execdebug.h"
#include "executor/instrument.h"
#include "executor/nodeAgg.h"
#include "executor/nodeAppend.h"
#include "executor/nodeGroup.h"
#include "executor/nodeGroup.h"
#include "executor/nodeHash.h"
#include "executor/nodeHashjoin.h"
#include "executor/nodeIndexscan.h"
#include "executor/nodeTidscan.h"
#include "executor/nodeLimit.h"
#include "executor/nodeMaterial.h"
#include "executor/nodeMergejoin.h"
#include "executor/nodeNestloop.h"
#include "executor/nodeResult.h"
#include "executor/nodeSeqscan.h"
#include "executor/nodeSetOp.h"
#include "executor/nodeSort.h"
#include "executor/nodeSubplan.h"
#include "executor/nodeSubqueryscan.h"
#include "executor/nodeFunctionscan.h"
#include "executor/nodeUnique.h"
/* ----------------------------------------------------------------
* ExecReScan
*
* XXX this should be extended to cope with all the node types..
*
* takes the new expression context as an argument, so that
* index scans needn't have their scan keys updated separately
* - marcel 09/20/94
* ----------------------------------------------------------------
*/
void
ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
{
if (node->instrument)
InstrEndLoop(node->instrument);
if (node->chgParam != NULL) /* Wow! */
{
List *lst;
foreach(lst, node->initPlan)
{
Plan *splan = ((SubPlan *) lfirst(lst))->plan;
if (splan->extParam != NULL) /* don't care about child
* locParam */
SetChangedParamList(splan, node->chgParam);
if (splan->chgParam != NULL)
ExecReScanSetParamPlan((SubPlan *) lfirst(lst), node);
}
foreach(lst, node->subPlan)
{
Plan *splan = ((SubPlan *) lfirst(lst))->plan;
if (splan->extParam != NULL)
SetChangedParamList(splan, node->chgParam);
}
/* Well. Now set chgParam for left/right trees. */
if (node->lefttree != NULL)
SetChangedParamList(node->lefttree, node->chgParam);
if (node->righttree != NULL)
SetChangedParamList(node->righttree, node->chgParam);
}
switch (nodeTag(node))
{
case T_SeqScan:
ExecSeqReScan((SeqScan *) node, exprCtxt, parent);
break;
case T_IndexScan:
ExecIndexReScan((IndexScan *) node, exprCtxt, parent);
break;
case T_TidScan:
ExecTidReScan((TidScan *) node, exprCtxt, parent);
break;
case T_SubqueryScan:
ExecSubqueryReScan((SubqueryScan *) node, exprCtxt, parent);
break;
case T_FunctionScan:
ExecFunctionReScan((FunctionScan *) node, exprCtxt, parent);
break;
case T_Material:
ExecMaterialReScan((Material *) node, exprCtxt, parent);
break;
case T_NestLoop:
ExecReScanNestLoop((NestLoop *) node, exprCtxt, parent);
break;
case T_HashJoin:
ExecReScanHashJoin((HashJoin *) node, exprCtxt, parent);
break;
case T_Hash:
ExecReScanHash((Hash *) node, exprCtxt, parent);
break;
case T_Agg:
ExecReScanAgg((Agg *) node, exprCtxt, parent);
break;
case T_Group:
ExecReScanGroup((Group *) node, exprCtxt, parent);
break;
case T_Result:
ExecReScanResult((Result *) node, exprCtxt, parent);
break;
case T_Unique:
ExecReScanUnique((Unique *) node, exprCtxt, parent);
break;
case T_SetOp:
ExecReScanSetOp((SetOp *) node, exprCtxt, parent);
break;
case T_Limit:
ExecReScanLimit((Limit *) node, exprCtxt, parent);
break;
case T_Sort:
ExecReScanSort((Sort *) node, exprCtxt, parent);
break;
case T_MergeJoin:
ExecReScanMergeJoin((MergeJoin *) node, exprCtxt, parent);
break;
case T_Append:
ExecReScanAppend((Append *) node, exprCtxt, parent);
break;
default:
elog(ERROR, "ExecReScan: node type %d not supported",
nodeTag(node));
return;
}
if (node->chgParam != NULL)
{
freeList(node->chgParam);
node->chgParam = NULL;
}
}
/* ----------------------------------------------------------------
* ExecMarkPos
*
* Marks the current scan position.
*
* XXX Needs to be extended to include all the node types,
* or at least all the ones that can be directly below a mergejoin.
* ----------------------------------------------------------------
*/
void
ExecMarkPos(Plan *node)
{
switch (nodeTag(node))
{
case T_SeqScan:
ExecSeqMarkPos((SeqScan *) node);
break;
case T_IndexScan:
ExecIndexMarkPos((IndexScan *) node);
break;
case T_FunctionScan:
ExecFunctionMarkPos((FunctionScan *) node);
break;
case T_Material:
ExecMaterialMarkPos((Material *) node);
break;
case T_Sort:
ExecSortMarkPos((Sort *) node);
break;
case T_TidScan:
ExecTidMarkPos((TidScan *) node);
break;
default:
/* don't make hard error unless caller asks to restore... */
elog(LOG, "ExecMarkPos: node type %d not supported",
nodeTag(node));
break;
}
}
/* ----------------------------------------------------------------
* ExecRestrPos
*
* restores the scan position previously saved with ExecMarkPos()
*
* XXX Needs to be extended to include all the node types,
* or at least all the ones that can be directly below a mergejoin.
* ----------------------------------------------------------------
*/
void
ExecRestrPos(Plan *node)
{
switch (nodeTag(node))
{
case T_SeqScan:
ExecSeqRestrPos((SeqScan *) node);
break;
case T_IndexScan:
ExecIndexRestrPos((IndexScan *) node);
break;
case T_FunctionScan:
ExecFunctionRestrPos((FunctionScan *) node);
break;
case T_Material:
ExecMaterialRestrPos((Material *) node);
break;
case T_Sort:
ExecSortRestrPos((Sort *) node);
break;
default:
elog(ERROR, "ExecRestrPos: node type %d not supported",
nodeTag(node));
break;
}
}
|