@@ -2063,7 +2063,7 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
2063
2063
nchanges = 0 ;
2064
2064
while (true)
2065
2065
{
2066
- int nbytes ;
2066
+ size_t nbytes ;
2067
2067
int len ;
2068
2068
2069
2069
CHECK_FOR_INTERRUPTS ();
@@ -2079,8 +2079,8 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
2079
2079
if (nbytes != sizeof (len ))
2080
2080
ereport (ERROR ,
2081
2081
(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 ) )));
2084
2084
2085
2085
if (len <= 0 )
2086
2086
elog (ERROR , "incorrect length %d in streaming transaction's changes file \"%s\"" ,
@@ -2090,11 +2090,12 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
2090
2090
buffer = repalloc (buffer , len );
2091
2091
2092
2092
/* 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 )
2094
2095
ereport (ERROR ,
2095
2096
(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 )));
2098
2099
2099
2100
BufFileTell (stream_fd , & fileno , & offset );
2100
2101
@@ -3992,6 +3993,7 @@ static void
3992
3993
subxact_info_read (Oid subid , TransactionId xid )
3993
3994
{
3994
3995
char path [MAXPGPATH ];
3996
+ size_t nread ;
3995
3997
Size len ;
3996
3998
BufFile * fd ;
3997
3999
MemoryContext oldctx ;
@@ -4011,13 +4013,12 @@ subxact_info_read(Oid subid, TransactionId xid)
4011
4013
return ;
4012
4014
4013
4015
/* 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 ))
4017
4018
ereport (ERROR ,
4018
4019
(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 ) )));
4021
4022
4022
4023
len = sizeof (SubXactInfo ) * subxact_data .nsubxacts ;
4023
4024
@@ -4035,11 +4036,15 @@ subxact_info_read(Oid subid, TransactionId xid)
4035
4036
sizeof (SubXactInfo ));
4036
4037
MemoryContextSwitchTo (oldctx );
4037
4038
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 )
4039
4043
ereport (ERROR ,
4040
4044
(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
+ }
4043
4048
4044
4049
BufFileClose (fd );
4045
4050
}
0 commit comments