@@ -422,23 +422,10 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
422422 */
423423if (accessor -> sts -> meta_data_size > 0 )
424424{
425- if (BufFileRead (accessor -> read_file ,
426- meta_data ,
427- accessor -> sts -> meta_data_size )!=
428- accessor -> sts -> meta_data_size )
429- ereport (ERROR ,
430- (errcode_for_file_access (),
431- errmsg ("could not read from shared tuplestore temporary file" ),
432- errdetail_internal ("Short read while reading meta-data." )));
425+ BufFileReadExact (accessor -> read_file ,meta_data ,accessor -> sts -> meta_data_size );
433426accessor -> read_bytes += accessor -> sts -> meta_data_size ;
434427}
435- if (BufFileRead (accessor -> read_file ,
436- & size ,
437- sizeof (size ))!= sizeof (size ))
438- ereport (ERROR ,
439- (errcode_for_file_access (),
440- errmsg ("could not read from shared tuplestore temporary file" ),
441- errdetail_internal ("Short read while reading size." )));
428+ BufFileReadExact (accessor -> read_file ,& size ,sizeof (size ));
442429accessor -> read_bytes += sizeof (size );
443430if (size > accessor -> read_buffer_size )
444431{
@@ -455,13 +442,7 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
455442this_chunk_size = Min (remaining_size ,
456443BLCKSZ * STS_CHUNK_PAGES - accessor -> read_bytes );
457444destination = accessor -> read_buffer + sizeof (uint32 );
458- if (BufFileRead (accessor -> read_file ,
459- destination ,
460- this_chunk_size )!= this_chunk_size )
461- ereport (ERROR ,
462- (errcode_for_file_access (),
463- errmsg ("could not read from shared tuplestore temporary file" ),
464- errdetail_internal ("Short read while reading tuple." )));
445+ BufFileReadExact (accessor -> read_file ,destination ,this_chunk_size );
465446accessor -> read_bytes += this_chunk_size ;
466447remaining_size -= this_chunk_size ;
467448destination += this_chunk_size ;
@@ -473,12 +454,7 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
473454/* We are now positioned at the start of an overflow chunk. */
474455SharedTuplestoreChunk chunk_header ;
475456
476- if (BufFileRead (accessor -> read_file ,& chunk_header ,STS_CHUNK_HEADER_SIZE )!=
477- STS_CHUNK_HEADER_SIZE )
478- ereport (ERROR ,
479- (errcode_for_file_access (),
480- errmsg ("could not read from shared tuplestore temporary file" ),
481- errdetail_internal ("Short read while reading overflow chunk header." )));
457+ BufFileReadExact (accessor -> read_file ,& chunk_header ,STS_CHUNK_HEADER_SIZE );
482458accessor -> read_bytes = STS_CHUNK_HEADER_SIZE ;
483459if (chunk_header .overflow == 0 )
484460ereport (ERROR ,
@@ -489,13 +465,7 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
489465this_chunk_size = Min (remaining_size ,
490466BLCKSZ * STS_CHUNK_PAGES -
491467STS_CHUNK_HEADER_SIZE );
492- if (BufFileRead (accessor -> read_file ,
493- destination ,
494- this_chunk_size )!= this_chunk_size )
495- ereport (ERROR ,
496- (errcode_for_file_access (),
497- errmsg ("could not read from shared tuplestore temporary file" ),
498- errdetail_internal ("Short read while reading tuple." )));
468+ BufFileReadExact (accessor -> read_file ,destination ,this_chunk_size );
499469accessor -> read_bytes += this_chunk_size ;
500470remaining_size -= this_chunk_size ;
501471destination += this_chunk_size ;
@@ -551,7 +521,6 @@ sts_parallel_scan_next(SharedTuplestoreAccessor *accessor, void *meta_data)
551521if (!eof )
552522{
553523SharedTuplestoreChunk chunk_header ;
554- size_t nread ;
555524
556525/* Make sure we have the file open. */
557526if (accessor -> read_file == NULL )
@@ -570,13 +539,7 @@ sts_parallel_scan_next(SharedTuplestoreAccessor *accessor, void *meta_data)
570539(errcode_for_file_access (),
571540errmsg ("could not seek to block %u in shared tuplestore temporary file" ,
572541read_page )));
573- nread = BufFileRead (accessor -> read_file ,& chunk_header ,
574- STS_CHUNK_HEADER_SIZE );
575- if (nread != STS_CHUNK_HEADER_SIZE )
576- ereport (ERROR ,
577- (errcode_for_file_access (),
578- errmsg ("could not read from shared tuplestore temporary file: read only %zu of %zu bytes" ,
579- nread ,STS_CHUNK_HEADER_SIZE )));
542+ BufFileReadExact (accessor -> read_file ,& chunk_header ,STS_CHUNK_HEADER_SIZE );
580543
581544/*
582545 * If this is an overflow chunk, we skip it and any following