@@ -422,23 +422,10 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
422422 */
423423 if (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 );
433426 accessor -> 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 ));
442429 accessor -> read_bytes += sizeof (size );
443430 if (size > accessor -> read_buffer_size )
444431 {
@@ -455,13 +442,7 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
455442 this_chunk_size = Min (remaining_size ,
456443 BLCKSZ * STS_CHUNK_PAGES - accessor -> read_bytes );
457444 destination = 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 );
465446 accessor -> read_bytes += this_chunk_size ;
466447 remaining_size -= this_chunk_size ;
467448 destination += 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. */
474455 SharedTuplestoreChunk 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 );
482458 accessor -> read_bytes = STS_CHUNK_HEADER_SIZE ;
483459 if (chunk_header .overflow == 0 )
484460 ereport (ERROR ,
@@ -489,13 +465,7 @@ sts_read_tuple(SharedTuplestoreAccessor *accessor, void *meta_data)
489465 this_chunk_size = Min (remaining_size ,
490466 BLCKSZ * STS_CHUNK_PAGES -
491467 STS_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 );
499469 accessor -> read_bytes += this_chunk_size ;
500470 remaining_size -= this_chunk_size ;
501471 destination += this_chunk_size ;
@@ -551,7 +521,6 @@ sts_parallel_scan_next(SharedTuplestoreAccessor *accessor, void *meta_data)
551521 if (!eof )
552522 {
553523 SharedTuplestoreChunk chunk_header ;
554- size_t nread ;
555524
556525 /* Make sure we have the file open. */
557526 if (accessor -> read_file == NULL )
@@ -570,13 +539,7 @@ sts_parallel_scan_next(SharedTuplestoreAccessor *accessor, void *meta_data)
570539 (errcode_for_file_access (),
571540 errmsg ("could not seek to block %u in shared tuplestore temporary file" ,
572541 read_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
0 commit comments