src/backend/utils/sort/logtape.c
/*
 * Rewind a previously-frozen indirect-block hierarchy for another read pass.
 * This call returns the first data block number, or -1L if the tape
 * is empty.
 */
Rewind a previously-frozen indirect-block hierarchy for another read pass.
This call returns the first data block number, or -1L if the tape
is empty.
Rewind a previously - frozen indirect - block hierarchy for another read pass . This call returns the first data block number or - 1L if the tape is empty .
static long
ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts,
							 IndirectBlock *indirect)
{
	if (indirect == NULL)
		return -1L;
	if (indirect->nextup != NULL)
	{
		long		indirblock;
		indirblock = ltsRewindFrozenIndirectBlock(lts, indirect->nextup);
		Assert(indirblock != -1L);
		ltsReadBlock(lts, indirblock, (void *) indirect->ptrs);
	}
	indirect->nextSlot = 0;
	if (indirect->ptrs[0] == -1L)
		return -1L;
	return indirect->ptrs[indirect->nextSlot++];
}
static long ltsRewindFrozenIndirectBlock ( LogicalTapeSet * lts , IndirectBlock * indirect ) { if ( indirect == NULL ) return -1L ; if ( indirect -> nextup != NULL ) { long indirblock ; indirblock = ltsRewindFrozenIndirectBlock ( lts , indirect -> nextup ) ; Assert ( indirblock != -1L ) ; ltsReadBlock ( lts , indirblock , ( void * ) indirect -> ptrs ) ; } indirect -> nextSlot = 0 ; if ( indirect -> ptrs [ 0 ] == -1L ) return -1L ; return indirect -> ptrs [ indirect -> nextSlot ++ ] ; }
Rewind a previously-frozen indirect-block hierarchy for another read pass.
Rewind a previously - frozen indirect - block hierarchy for another read pass .
/* Handle case of never-written-to tape */ /*
	 * If block is not topmost, recurse to obtain address of first block in
	 * this hierarchy level.  Read that one in.
	 */ /*
	 * Reset my next-block pointer, and then fetch a block number if any.
	 */