Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitadbfab1

Browse files
committed
Remove dead code supporting mark/restore in SeqScan, TidScan, ValuesScan.
There seems no prospect that any of this will ever be useful, and indeedit's questionable whether some of it would work if it ever got called;it's certainly not been exercised in a very long time, if ever. So let'sget rid of it, and make the comments about mark/restore in execAmi.c lesswishy-washy.The mark/restore support for Result nodes is also currently dead code,but that's due to planner limitations not because it's impossible thatit could be useful. So I left it in.
1 parenta34fa8e commitadbfab1

File tree

11 files changed

+13
-213
lines changed

11 files changed

+13
-213
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
*heap_multi_insert - insert multiple tuples into a relation
2828
*heap_delete- delete a tuple from a relation
2929
*heap_update- replace a tuple in a relation with another tuple
30-
*heap_markpos- mark scan position
31-
*heap_restrpos- restore position to marked location
3230
*heap_sync- sync heap, for when no WAL has been written
3331
*
3432
* NOTES
@@ -280,9 +278,6 @@ initscan(HeapScanDesc scan, ScanKey key, bool is_rescan)
280278
scan->rs_cbuf=InvalidBuffer;
281279
scan->rs_cblock=InvalidBlockNumber;
282280

283-
/* we don't have a marked position... */
284-
ItemPointerSetInvalid(&(scan->rs_mctid));
285-
286281
/* page-at-a-time fields are always invalid when not rs_inited */
287282

288283
/*
@@ -6317,71 +6312,6 @@ heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
63176312
return false;
63186313
}
63196314

6320-
/* ----------------
6321-
*heap_markpos- mark scan position
6322-
* ----------------
6323-
*/
6324-
void
6325-
heap_markpos(HeapScanDescscan)
6326-
{
6327-
/* Note: no locking manipulations needed */
6328-
6329-
if (scan->rs_ctup.t_data!=NULL)
6330-
{
6331-
scan->rs_mctid=scan->rs_ctup.t_self;
6332-
if (scan->rs_pageatatime)
6333-
scan->rs_mindex=scan->rs_cindex;
6334-
}
6335-
else
6336-
ItemPointerSetInvalid(&scan->rs_mctid);
6337-
}
6338-
6339-
/* ----------------
6340-
*heap_restrpos- restore position to marked location
6341-
* ----------------
6342-
*/
6343-
void
6344-
heap_restrpos(HeapScanDescscan)
6345-
{
6346-
/* XXX no amrestrpos checking that ammarkpos called */
6347-
6348-
if (!ItemPointerIsValid(&scan->rs_mctid))
6349-
{
6350-
scan->rs_ctup.t_data=NULL;
6351-
6352-
/*
6353-
* unpin scan buffers
6354-
*/
6355-
if (BufferIsValid(scan->rs_cbuf))
6356-
ReleaseBuffer(scan->rs_cbuf);
6357-
scan->rs_cbuf=InvalidBuffer;
6358-
scan->rs_cblock=InvalidBlockNumber;
6359-
scan->rs_inited= false;
6360-
}
6361-
else
6362-
{
6363-
/*
6364-
* If we reached end of scan, rs_inited will now be false. We must
6365-
* reset it to true to keep heapgettup from doing the wrong thing.
6366-
*/
6367-
scan->rs_inited= true;
6368-
scan->rs_ctup.t_self=scan->rs_mctid;
6369-
if (scan->rs_pageatatime)
6370-
{
6371-
scan->rs_cindex=scan->rs_mindex;
6372-
heapgettup_pagemode(scan,
6373-
NoMovementScanDirection,
6374-
0,/* needn't recheck scan keys */
6375-
NULL);
6376-
}
6377-
else
6378-
heapgettup(scan,
6379-
NoMovementScanDirection,
6380-
0,/* needn't recheck scan keys */
6381-
NULL);
6382-
}
6383-
}
6384-
63856315
/*
63866316
* If 'tuple' contains any visible XID greater than latestRemovedXid,
63876317
* ratchet forwards latestRemovedXid to the greatest one found.

‎src/backend/executor/execAmi.c

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,20 @@ ExecReScan(PlanState *node)
271271
* ExecMarkPos
272272
*
273273
* Marks the current scan position.
274+
*
275+
* NOTE: mark/restore capability is currently needed only for plan nodes
276+
* that are the immediate inner child of a MergeJoin node. Since MergeJoin
277+
* requires sorted input, there is never any need to support mark/restore in
278+
* node types that cannot produce sorted output. There are some cases in
279+
* which a node can pass through sorted data from its child; if we don't
280+
* implement mark/restore for such a node type, the planner compensates by
281+
* inserting a Material node above that node.
274282
*/
275283
void
276284
ExecMarkPos(PlanState*node)
277285
{
278286
switch (nodeTag(node))
279287
{
280-
caseT_SeqScanState:
281-
ExecSeqMarkPos((SeqScanState*)node);
282-
break;
283-
284288
caseT_IndexScanState:
285289
ExecIndexMarkPos((IndexScanState*)node);
286290
break;
@@ -289,14 +293,6 @@ ExecMarkPos(PlanState *node)
289293
ExecIndexOnlyMarkPos((IndexOnlyScanState*)node);
290294
break;
291295

292-
caseT_TidScanState:
293-
ExecTidMarkPos((TidScanState*)node);
294-
break;
295-
296-
caseT_ValuesScanState:
297-
ExecValuesMarkPos((ValuesScanState*)node);
298-
break;
299-
300296
caseT_CustomScanState:
301297
ExecCustomMarkPos((CustomScanState*)node);
302298
break;
@@ -338,10 +334,6 @@ ExecRestrPos(PlanState *node)
338334
{
339335
switch (nodeTag(node))
340336
{
341-
caseT_SeqScanState:
342-
ExecSeqRestrPos((SeqScanState*)node);
343-
break;
344-
345337
caseT_IndexScanState:
346338
ExecIndexRestrPos((IndexScanState*)node);
347339
break;
@@ -350,14 +342,6 @@ ExecRestrPos(PlanState *node)
350342
ExecIndexOnlyRestrPos((IndexOnlyScanState*)node);
351343
break;
352344

353-
caseT_TidScanState:
354-
ExecTidRestrPos((TidScanState*)node);
355-
break;
356-
357-
caseT_ValuesScanState:
358-
ExecValuesRestrPos((ValuesScanState*)node);
359-
break;
360-
361345
caseT_CustomScanState:
362346
ExecCustomRestrPos((CustomScanState*)node);
363347
break;
@@ -386,14 +370,6 @@ ExecRestrPos(PlanState *node)
386370
* This is used during planning and so must accept a Path, not a Plan.
387371
* We keep it here to be adjacent to the routines above, which also must
388372
* know which plan types support mark/restore.
389-
*
390-
* XXX Ideally, all plan node types would support mark/restore, and this
391-
* wouldn't be needed. For now, this had better match the routines above.
392-
*
393-
* (However, since the only present use of mark/restore is in mergejoin,
394-
* there is no need to support mark/restore in any plan type that is not
395-
* capable of generating ordered output. So the seqscan, tidscan,
396-
* and valuesscan support is actually useless code at present.)
397373
*/
398374
bool
399375
ExecSupportsMarkRestore(Path*pathnode)
@@ -405,11 +381,8 @@ ExecSupportsMarkRestore(Path *pathnode)
405381
*/
406382
switch (pathnode->pathtype)
407383
{
408-
caseT_SeqScan:
409384
caseT_IndexScan:
410385
caseT_IndexOnlyScan:
411-
caseT_TidScan:
412-
caseT_ValuesScan:
413386
caseT_Material:
414387
caseT_Sort:
415388
return true;
@@ -426,7 +399,11 @@ ExecSupportsMarkRestore(Path *pathnode)
426399
* Although Result supports mark/restore if it has a child plan
427400
* that does, we presently come here only for ResultPath nodes,
428401
* which represent Result plans without a child plan. So there is
429-
* nothing to recurse to and we can just say "false".
402+
* nothing to recurse to and we can just say "false". (This means
403+
* that Result's support for mark/restore is in fact dead code.
404+
* We keep it since it's not much code, and someday the planner
405+
* might be smart enough to use it. That would require making
406+
* this function smarter too, of course.)
430407
*/
431408
Assert(IsA(pathnode,ResultPath));
432409
return false;

‎src/backend/executor/nodeSeqscan.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*ExecInitSeqScancreates and initializes a seqscan node.
2020
*ExecEndSeqScanreleases any storage allocated.
2121
*ExecReScanSeqScanrescans the relation
22-
*ExecSeqMarkPosmarks scan position
23-
*ExecSeqRestrPosrestores scan position
2422
*/
2523
#include"postgres.h"
2624

@@ -274,39 +272,3 @@ ExecReScanSeqScan(SeqScanState *node)
274272

275273
ExecScanReScan((ScanState*)node);
276274
}
277-
278-
/* ----------------------------------------------------------------
279-
*ExecSeqMarkPos(node)
280-
*
281-
*Marks scan position.
282-
* ----------------------------------------------------------------
283-
*/
284-
void
285-
ExecSeqMarkPos(SeqScanState*node)
286-
{
287-
HeapScanDescscan=node->ss_currentScanDesc;
288-
289-
heap_markpos(scan);
290-
}
291-
292-
/* ----------------------------------------------------------------
293-
*ExecSeqRestrPos
294-
*
295-
*Restores scan position.
296-
* ----------------------------------------------------------------
297-
*/
298-
void
299-
ExecSeqRestrPos(SeqScanState*node)
300-
{
301-
HeapScanDescscan=node->ss_currentScanDesc;
302-
303-
/*
304-
* Clear any reference to the previously returned tuple. This is needed
305-
* because the slot is simply pointing at scan->rs_cbuf, which
306-
* heap_restrpos will change; we'd have an internally inconsistent slot if
307-
* we didn't do this.
308-
*/
309-
ExecClearTuple(node->ss_ScanTupleSlot);
310-
311-
heap_restrpos(scan);
312-
}

‎src/backend/executor/nodeTidscan.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*ExecInitTidScancreates and initializes state info.
2020
*ExecReScanTidScanrescans the tid relation.
2121
*ExecEndTidScanreleases all storage.
22-
*ExecTidMarkPosmarks scan position.
23-
*ExecTidRestrPosrestores scan position.
2422
*/
2523
#include"postgres.h"
2624

@@ -440,34 +438,6 @@ ExecEndTidScan(TidScanState *node)
440438
ExecCloseScanRelation(node->ss.ss_currentRelation);
441439
}
442440

443-
/* ----------------------------------------------------------------
444-
*ExecTidMarkPos
445-
*
446-
*Marks scan position by marking the current tid.
447-
*Returns nothing.
448-
* ----------------------------------------------------------------
449-
*/
450-
void
451-
ExecTidMarkPos(TidScanState*node)
452-
{
453-
node->tss_MarkTidPtr=node->tss_TidPtr;
454-
}
455-
456-
/* ----------------------------------------------------------------
457-
*ExecTidRestrPos
458-
*
459-
*Restores scan position by restoring the current tid.
460-
*Returns nothing.
461-
*
462-
*XXX Assumes previously marked scan position belongs to current tid
463-
* ----------------------------------------------------------------
464-
*/
465-
void
466-
ExecTidRestrPos(TidScanState*node)
467-
{
468-
node->tss_TidPtr=node->tss_MarkTidPtr;
469-
}
470-
471441
/* ----------------------------------------------------------------
472442
*ExecInitTidScan
473443
*

‎src/backend/executor/nodeValuesscan.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags)
246246
/*
247247
* Other node-specific setup
248248
*/
249-
scanstate->marked_idx=-1;
250249
scanstate->curr_idx=-1;
251250
scanstate->array_len=list_length(node->values_lists);
252251

@@ -293,30 +292,6 @@ ExecEndValuesScan(ValuesScanState *node)
293292
ExecClearTuple(node->ss.ss_ScanTupleSlot);
294293
}
295294

296-
/* ----------------------------------------------------------------
297-
*ExecValuesMarkPos
298-
*
299-
*Marks scan position.
300-
* ----------------------------------------------------------------
301-
*/
302-
void
303-
ExecValuesMarkPos(ValuesScanState*node)
304-
{
305-
node->marked_idx=node->curr_idx;
306-
}
307-
308-
/* ----------------------------------------------------------------
309-
*ExecValuesRestrPos
310-
*
311-
*Restores scan position.
312-
* ----------------------------------------------------------------
313-
*/
314-
void
315-
ExecValuesRestrPos(ValuesScanState*node)
316-
{
317-
node->curr_idx=node->marked_idx;
318-
}
319-
320295
/* ----------------------------------------------------------------
321296
*ExecReScanValuesScan
322297
*

‎src/include/access/heapam.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ extern void simple_heap_delete(Relation relation, ItemPointer tid);
161161
externvoidsimple_heap_update(Relationrelation,ItemPointerotid,
162162
HeapTupletup);
163163

164-
externvoidheap_markpos(HeapScanDescscan);
165-
externvoidheap_restrpos(HeapScanDescscan);
166-
167164
externvoidheap_sync(Relationrelation);
168165

169166
/* in heap/pruneheap.c */

‎src/include/access/relscan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ typedef struct HeapScanDescData
4848
BlockNumberrs_cblock;/* current block # in scan, if any */
4949
Bufferrs_cbuf;/* current buffer in scan, if any */
5050
/* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
51-
ItemPointerDatars_mctid;/* marked scan position, if any */
5251

5352
/* these fields only used in page-at-a-time mode and for bitmap scans */
5453
intrs_cindex;/* current tuple's index in vistuples */
55-
intrs_mindex;/* marked tuple's saved index */
5654
intrs_ntuples;/* number of visible tuples on page */
5755
OffsetNumberrs_vistuples[MaxHeapTuplesPerPage];/* their offsets */
5856
}HeapScanDescData;

‎src/include/executor/nodeSeqscan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
externSeqScanState*ExecInitSeqScan(SeqScan*node,EState*estate,inteflags);
2020
externTupleTableSlot*ExecSeqScan(SeqScanState*node);
2121
externvoidExecEndSeqScan(SeqScanState*node);
22-
externvoidExecSeqMarkPos(SeqScanState*node);
23-
externvoidExecSeqRestrPos(SeqScanState*node);
2422
externvoidExecReScanSeqScan(SeqScanState*node);
2523

2624
#endif/* NODESEQSCAN_H */

‎src/include/executor/nodeTidscan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
externTidScanState*ExecInitTidScan(TidScan*node,EState*estate,inteflags);
2020
externTupleTableSlot*ExecTidScan(TidScanState*node);
2121
externvoidExecEndTidScan(TidScanState*node);
22-
externvoidExecTidMarkPos(TidScanState*node);
23-
externvoidExecTidRestrPos(TidScanState*node);
2422
externvoidExecReScanTidScan(TidScanState*node);
2523

2624
#endif/* NODETIDSCAN_H */

‎src/include/executor/nodeValuesscan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
externValuesScanState*ExecInitValuesScan(ValuesScan*node,EState*estate,inteflags);
2020
externTupleTableSlot*ExecValuesScan(ValuesScanState*node);
2121
externvoidExecEndValuesScan(ValuesScanState*node);
22-
externvoidExecValuesMarkPos(ValuesScanState*node);
23-
externvoidExecValuesRestrPos(ValuesScanState*node);
2422
externvoidExecReScanValuesScan(ValuesScanState*node);
2523

2624
#endif/* NODEVALUESSCAN_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp