src/backend/utils/sort/logtape.c
/*
 * Obtain next data block number in the reverse direction, or -1L if no more.
 *
 * Note this fetches the block# before the one last returned, no matter which
 * direction of call returned that one.  If we fail, no change in state.
 *
 * This routine can only be used in 'frozen' state, so there's no need to
 * pass a parameter telling whether to release blocks ... we never do.
 */
Obtain next data block number in the reverse direction, or -1L if no more.
Note this fetches the block# before the one last returned, no matter which
direction of call returned that one.  If we fail, no change in state.

This routine can only be used in 'frozen' state, so there's no need to
pass a parameter telling whether to release blocks ... we never do.
Obtain next data block number in the reverse direction or - 1L if no more . Note this fetches the block# before the one last returned no matter which direction of call returned that one . If we fail no change in state . This routine can only be used in ' frozen ' state so there ' s no need to pass a parameter telling whether to release blocks ... we never do .
static long
ltsRecallPrevBlockNum(LogicalTapeSet *lts,
					  IndirectBlock *indirect)
{
	if (indirect == NULL)
		return -1L;
	if (indirect->nextSlot <= 1)
	{
		long		indirblock;
		if (indirect->nextup == NULL)
			return -1L;			
		indirblock = ltsRecallPrevBlockNum(lts, indirect->nextup);
		if (indirblock == -1L)
			return -1L;			
		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
		indirect->nextSlot = BLOCKS_PER_INDIR_BLOCK + 1;
	}
	indirect->nextSlot--;
	return indirect->ptrs[indirect->nextSlot - 1];
}
static long ltsRecallPrevBlockNum ( LogicalTapeSet * lts , IndirectBlock * indirect ) { if ( indirect == NULL ) return -1L ; if ( indirect -> nextSlot <= 1 ) { long indirblock ; if ( indirect -> nextup == NULL ) return -1L ; indirblock = ltsRecallPrevBlockNum ( lts , indirect -> nextup ) ; if ( indirblock == -1L ) return -1L ; ltsReadBlock ( lts , indirblock , ( void * ) indirect -> ptrs ) ; indirect -> nextSlot = BLOCKS_PER_INDIR_BLOCK + 1 ; } indirect -> nextSlot -- ; return indirect -> ptrs [ indirect -> nextSlot - 1 ] ; }
Obtain next data block number in the reverse direction, or -1L if no more.
Obtain next data block number in the reverse direction or - 1L if no more .
/* Handle case of never-written-to tape */ /* nothing left at this level */ /* nothing left at this level */ /*
		 * The previous block would only have been written out if full, so we
		 * need not search it for a -1 sentinel.
		 */