src/backend/utils/sort/logtape.c
/*
 * Read as many blocks as we can into the per-tape buffer.
 *
 * The caller can specify the next physical block number to read, in
 * datablocknum, or -1 to fetch the next block number from the internal block.
 * If datablocknum == -1, the caller must've already set curBlockNumber.
 *
 * Returns true if anything was read, 'false' on EOF.
 */
Read as many blocks as we can into the per-tape buffer.
The caller can specify the next physical block number to read, in
datablocknum, or -1 to fetch the next block number from the internal block.
If datablocknum == -1, the caller must've already set curBlockNumber.

Returns true if anything was read, 'false' on EOF.
Read as many blocks as we can into the per - tape buffer . The caller can specify the next physical block number to read in datablocknum or - 1 to fetch the next block number from the internal block . If datablocknum == - 1 the caller must ' ve already set curBlockNumber . Returns true if anything was read ' false ' on EOF .
static bool
ltsReadFillBuffer(LogicalTapeSet *lts, LogicalTape *lt, long datablocknum)
{
	lt->pos = 0;
	lt->nbytes = 0;
	do
	{
		if (datablocknum == -1)
		{
			datablocknum = ltsRecallNextBlockNum(lts, lt->indirect, lt->frozen);
			if (datablocknum == -1L)
				break;			
			lt->curBlockNumber++;
		}
		ltsReadBlock(lts, datablocknum, (void *) (lt->buffer + lt->nbytes));
		if (!lt->frozen)
			ltsReleaseBlock(lts, datablocknum);
		if (lt->curBlockNumber < lt->numFullBlocks)
			lt->nbytes += BLCKSZ;
		else
		{
			lt->nbytes += lt->lastBlockBytes;
			break;
		}
		datablocknum = -1;
	} while (lt->nbytes < lt->buffer_size);
	return (lt->nbytes > 0);
}
static bool ltsReadFillBuffer ( LogicalTapeSet * lts , LogicalTape * lt , long datablocknum ) { lt -> pos = 0 ; lt -> nbytes = 0 ; do { if ( datablocknum == -1 ) { datablocknum = ltsRecallNextBlockNum ( lts , lt -> indirect , lt -> frozen ) ; if ( datablocknum == -1L ) break ; lt -> curBlockNumber ++ ; } ltsReadBlock ( lts , datablocknum , ( void * ) ( lt -> buffer + lt -> nbytes ) ) ; if ( ! lt -> frozen ) ltsReleaseBlock ( lts , datablocknum ) ; if ( lt -> curBlockNumber < lt -> numFullBlocks ) lt -> nbytes += BLCKSZ ; else { lt -> nbytes += lt -> lastBlockBytes ; break ; } datablocknum = -1 ; } while ( lt -> nbytes < lt -> buffer_size ) ; return ( lt -> nbytes > 0 ) ; }
Read as many blocks as we can into the per-tape buffer.
Read as many blocks as we can into the per - tape buffer .
/* Fetch next block number (unless provided by caller) */ /* EOF */ /* Read the block */ /* EOF */ /* Advance to next block, if we have buffer space left */