@@ -2063,7 +2063,7 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
20632063 nchanges = 0 ;
20642064 while (true)
20652065 {
2066- int nbytes ;
2066+ size_t nbytes ;
20672067 int len ;
20682068
20692069 CHECK_FOR_INTERRUPTS ();
@@ -2079,8 +2079,8 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
20792079 if (nbytes != sizeof (len ))
20802080 ereport (ERROR ,
20812081 (errcode_for_file_access (),
2082- errmsg ("could not read from streaming transaction's changes file \"%s\": %m " ,
2083- path )));
2082+ errmsg ("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes " ,
2083+ path , nbytes , sizeof ( len ) )));
20842084
20852085 if (len <= 0 )
20862086 elog (ERROR , "incorrect length %d in streaming transaction's changes file \"%s\"" ,
@@ -2090,11 +2090,12 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
20902090 buffer = repalloc (buffer , len );
20912091
20922092 /* and finally read the data into the buffer */
2093- if (BufFileRead (stream_fd , buffer , len ) != len )
2093+ nbytes = BufFileRead (stream_fd , buffer , len );
2094+ if (nbytes != len )
20942095 ereport (ERROR ,
20952096 (errcode_for_file_access (),
2096- errmsg ("could not read from streaming transaction's changes file \"%s\": %m " ,
2097- path )));
2097+ errmsg ("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes " ,
2098+ path , nbytes , ( size_t ) len )));
20982099
20992100 BufFileTell (stream_fd , & fileno , & offset );
21002101
@@ -3992,6 +3993,7 @@ static void
39923993subxact_info_read (Oid subid , TransactionId xid )
39933994{
39943995 char path [MAXPGPATH ];
3996+ size_t nread ;
39953997 Size len ;
39963998 BufFile * fd ;
39973999 MemoryContext oldctx ;
@@ -4011,13 +4013,12 @@ subxact_info_read(Oid subid, TransactionId xid)
40114013 return ;
40124014
40134015 /* read number of subxact items */
4014- if (BufFileRead (fd , & subxact_data .nsubxacts ,
4015- sizeof (subxact_data .nsubxacts )) !=
4016- sizeof (subxact_data .nsubxacts ))
4016+ nread = BufFileRead (fd , & subxact_data .nsubxacts , sizeof (subxact_data .nsubxacts ));
4017+ if (nread != sizeof (subxact_data .nsubxacts ))
40174018 ereport (ERROR ,
40184019 (errcode_for_file_access (),
4019- errmsg ("could not read from streaming transaction's subxact file \"%s\": %m " ,
4020- path )));
4020+ errmsg ("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes " ,
4021+ path , nread , sizeof ( subxact_data . nsubxacts ) )));
40214022
40224023 len = sizeof (SubXactInfo ) * subxact_data .nsubxacts ;
40234024
@@ -4035,11 +4036,15 @@ subxact_info_read(Oid subid, TransactionId xid)
40354036 sizeof (SubXactInfo ));
40364037 MemoryContextSwitchTo (oldctx );
40374038
4038- if ((len > 0 ) && ((BufFileRead (fd , subxact_data .subxacts , len )) != len ))
4039+ if (len > 0 )
4040+ {
4041+ nread = BufFileRead (fd , subxact_data .subxacts , len );
4042+ if (nread != len )
40394043 ereport (ERROR ,
40404044 (errcode_for_file_access (),
4041- errmsg ("could not read from streaming transaction's subxact file \"%s\": %m" ,
4042- path )));
4045+ errmsg ("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes" ,
4046+ path , nread , len )));
4047+ }
40434048
40444049 BufFileClose (fd );
40454050}
0 commit comments