26
26
*
27
27
*
28
28
* IDENTIFICATION
29
- * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.313 2008/08/25 22:42:32 tgl Exp $
29
+ * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.314 2008/10/31 21:07:54 tgl Exp $
30
30
*
31
31
*-------------------------------------------------------------------------
32
32
*/
@@ -76,7 +76,7 @@ typedef struct evalPlanQual
76
76
static void InitPlan (QueryDesc * queryDesc , int eflags );
77
77
static void ExecCheckPlanOutput (Relation resultRel , List * targetList );
78
78
static void ExecEndPlan (PlanState * planstate , EState * estate );
79
- static TupleTableSlot * ExecutePlan (EState * estate , PlanState * planstate ,
79
+ static void ExecutePlan (EState * estate , PlanState * planstate ,
80
80
CmdType operation ,
81
81
long numberTuples ,
82
82
ScanDirection direction ,
@@ -220,34 +220,35 @@ ExecutorStart(QueryDesc *queryDesc, int eflags)
220
220
* Note: count = 0 is interpreted as no portal limit, i.e., run to
221
221
* completion.
222
222
*
223
+ * There is no return value, but output tuples (if any) are sent to
224
+ * the destination receiver specified in the QueryDesc; and the number
225
+ * of tuples processed at the top level can be found in
226
+ * estate->es_processed.
227
+ *
223
228
* We provide a function hook variable that lets loadable plugins
224
229
* get control when ExecutorRun is called. Such a plugin would
225
230
* normally call standard_ExecutorRun().
226
231
*
227
232
* ----------------------------------------------------------------
228
233
*/
229
- TupleTableSlot *
234
+ void
230
235
ExecutorRun (QueryDesc * queryDesc ,
231
236
ScanDirection direction , long count )
232
237
{
233
- TupleTableSlot * result ;
234
-
235
238
if (ExecutorRun_hook )
236
- result = (* ExecutorRun_hook ) (queryDesc , direction , count );
239
+ (* ExecutorRun_hook ) (queryDesc , direction , count );
237
240
else
238
- result = standard_ExecutorRun (queryDesc , direction , count );
239
- return result ;
241
+ standard_ExecutorRun (queryDesc , direction , count );
240
242
}
241
243
242
- TupleTableSlot *
244
+ void
243
245
standard_ExecutorRun (QueryDesc * queryDesc ,
244
246
ScanDirection direction , long count )
245
247
{
246
248
EState * estate ;
247
249
CmdType operation ;
248
250
DestReceiver * dest ;
249
251
bool sendTuples ;
250
- TupleTableSlot * result ;
251
252
MemoryContext oldcontext ;
252
253
253
254
/* sanity checks */
@@ -283,15 +284,13 @@ standard_ExecutorRun(QueryDesc *queryDesc,
283
284
/*
284
285
* run plan
285
286
*/
286
- if (ScanDirectionIsNoMovement (direction ))
287
- result = NULL ;
288
- else
289
- result = ExecutePlan (estate ,
290
- queryDesc -> planstate ,
291
- operation ,
292
- count ,
293
- direction ,
294
- dest );
287
+ if (!ScanDirectionIsNoMovement (direction ))
288
+ ExecutePlan (estate ,
289
+ queryDesc -> planstate ,
290
+ operation ,
291
+ count ,
292
+ direction ,
293
+ dest );
295
294
296
295
/*
297
296
* shutdown tuple receiver, if we started it
@@ -300,8 +299,6 @@ standard_ExecutorRun(QueryDesc *queryDesc,
300
299
(* dest -> rShutdown ) (dest );
301
300
302
301
MemoryContextSwitchTo (oldcontext );
303
-
304
- return result ;
305
302
}
306
303
307
304
/* ----------------------------------------------------------------
@@ -1271,19 +1268,16 @@ ExecEndPlan(PlanState *planstate, EState *estate)
1271
1268
/* ----------------------------------------------------------------
1272
1269
* ExecutePlan
1273
1270
*
1274
- * processes the query plan to retrieve 'numberTuples' tuples in the
1275
- * direction specified.
1276
- *
1277
- * Retrieves all tuples if numberTuples is 0
1271
+ * Processes the query plan until we have processed 'numberTuples' tuples,
1272
+ * moving in the specified direction.
1278
1273
*
1279
- * result is either a slot containing the last tuple in the case
1280
- * of a SELECT or NULL otherwise.
1274
+ * Runs to completion if numberTuples is 0
1281
1275
*
1282
1276
* Note: the ctid attribute is a 'junk' attribute that is removed before the
1283
1277
* user can see it
1284
1278
* ----------------------------------------------------------------
1285
1279
*/
1286
- static TupleTableSlot *
1280
+ static void
1287
1281
ExecutePlan (EState * estate ,
1288
1282
PlanState * planstate ,
1289
1283
CmdType operation ,
@@ -1297,13 +1291,11 @@ ExecutePlan(EState *estate,
1297
1291
ItemPointer tupleid = NULL ;
1298
1292
ItemPointerData tuple_ctid ;
1299
1293
long current_tuple_count ;
1300
- TupleTableSlot * result ;
1301
1294
1302
1295
/*
1303
1296
* initialize local variables
1304
1297
*/
1305
1298
current_tuple_count = 0 ;
1306
- result = NULL ;
1307
1299
1308
1300
/*
1309
1301
* Set the direction.
@@ -1332,7 +1324,6 @@ ExecutePlan(EState *estate,
1332
1324
/*
1333
1325
* Loop until we've processed the proper number of tuples from the plan.
1334
1326
*/
1335
-
1336
1327
for (;;)
1337
1328
{
1338
1329
/* Reset the per-output-tuple exprcontext */
@@ -1353,13 +1344,10 @@ lnext: ;
1353
1344
1354
1345
/*
1355
1346
* if the tuple is null, then we assume there is nothing more to
1356
- * process so we just return null ...
1347
+ * process so we just end the loop ...
1357
1348
*/
1358
1349
if (TupIsNull (planSlot ))
1359
- {
1360
- result = NULL ;
1361
1350
break ;
1362
- }
1363
1351
slot = planSlot ;
1364
1352
1365
1353
/*
@@ -1453,7 +1441,6 @@ lnext: ;
1453
1441
default :
1454
1442
elog (ERROR , "unrecognized heap_lock_tuple status: %u" ,
1455
1443
test );
1456
- return NULL ;
1457
1444
}
1458
1445
}
1459
1446
}
@@ -1488,35 +1475,30 @@ lnext: ;
1488
1475
1489
1476
/*
1490
1477
* now that we have a tuple, do the appropriate thing with it.. either
1491
- * return it to the user , add it to a relation someplace, delete it
1492
- * from a relation, or modify some of its attributes.
1478
+ * send it to the output destination , add it to a relation someplace,
1479
+ * delete it from a relation, or modify some of its attributes.
1493
1480
*/
1494
1481
switch (operation )
1495
1482
{
1496
1483
case CMD_SELECT :
1497
1484
ExecSelect (slot , dest , estate );
1498
- result = slot ;
1499
1485
break ;
1500
1486
1501
1487
case CMD_INSERT :
1502
1488
ExecInsert (slot , tupleid , planSlot , dest , estate );
1503
- result = NULL ;
1504
1489
break ;
1505
1490
1506
1491
case CMD_DELETE :
1507
1492
ExecDelete (tupleid , planSlot , dest , estate );
1508
- result = NULL ;
1509
1493
break ;
1510
1494
1511
1495
case CMD_UPDATE :
1512
1496
ExecUpdate (slot , tupleid , planSlot , dest , estate );
1513
- result = NULL ;
1514
1497
break ;
1515
1498
1516
1499
default :
1517
1500
elog (ERROR , "unrecognized operation code: %d" ,
1518
1501
(int ) operation );
1519
- result = NULL ;
1520
1502
break ;
1521
1503
}
1522
1504
@@ -1548,12 +1530,6 @@ lnext: ;
1548
1530
/* do nothing */
1549
1531
break ;
1550
1532
}
1551
-
1552
- /*
1553
- * here, result is either a slot containing a tuple in the case of a
1554
- * SELECT or NULL otherwise.
1555
- */
1556
- return result ;
1557
1533
}
1558
1534
1559
1535
/* ----------------------------------------------------------------
0 commit comments