src/backend/utils/sort/logtape.c
/*
 * Obtain next data block number in the forward direction, or -1L if no more.
 *
 * Unless 'frozen' is true, release indirect blocks to the free pool after
 * reading them.
 */
Obtain next data block number in the forward direction, or -1L if no more.
Unless 'frozen' is true, release indirect blocks to the free pool after
reading them.
Obtain next data block number in the forward direction or - 1L if no more . Unless ' frozen ' is true release indirect blocks to the free pool after reading them .
static long
ltsRecallNextBlockNum(LogicalTapeSet *lts,
					  IndirectBlock *indirect,
					  bool frozen)
{
	if (indirect == NULL)
		return -1L;
	if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK ||
		indirect->ptrs[indirect->nextSlot] == -1L)
	{
		long		indirblock;
		if (indirect->nextup == NULL)
			return -1L;			
		indirblock = ltsRecallNextBlockNum(lts, indirect->nextup, frozen);
		if (indirblock == -1L)
			return -1L;			
		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
		if (!frozen)
			ltsReleaseBlock(lts, indirblock);
		indirect->nextSlot = 0;
	}
	if (indirect->ptrs[indirect->nextSlot] == -1L)
		return -1L;
	return indirect->ptrs[indirect->nextSlot++];
}
static long ltsRecallNextBlockNum ( LogicalTapeSet * lts , IndirectBlock * indirect , bool frozen ) { if ( indirect == NULL ) return -1L ; if ( indirect -> nextSlot >= BLOCKS_PER_INDIR_BLOCK || indirect -> ptrs [ indirect -> nextSlot ] == -1L ) { long indirblock ; if ( indirect -> nextup == NULL ) return -1L ; indirblock = ltsRecallNextBlockNum ( lts , indirect -> nextup , frozen ) ; if ( indirblock == -1L ) return -1L ; ltsReadBlock ( lts , indirblock , ( void * ) indirect -> ptrs ) ; if ( ! frozen ) ltsReleaseBlock ( lts , indirblock ) ; indirect -> nextSlot = 0 ; } if ( indirect -> ptrs [ indirect -> nextSlot ] == -1L ) return -1L ; return indirect -> ptrs [ indirect -> nextSlot ++ ] ; }
Obtain next data block number in the forward direction, or -1L if no more.
Obtain next data block number in the forward direction or - 1L if no more .
/* Handle case of never-written-to tape */ /* nothing left at this level */ /* nothing left at this level */