@@ -1071,7 +1071,7 @@ apply_handle_stream_commit(StringInfo s)
1071
1071
nchanges = 0 ;
1072
1072
while (true)
1073
1073
{
1074
- int nbytes ;
1074
+ size_t nbytes ;
1075
1075
int len ;
1076
1076
1077
1077
CHECK_FOR_INTERRUPTS ();
@@ -1087,8 +1087,8 @@ apply_handle_stream_commit(StringInfo s)
1087
1087
if (nbytes != sizeof (len ))
1088
1088
ereport (ERROR ,
1089
1089
(errcode_for_file_access (),
1090
- errmsg ("could not read from streaming transaction's changes file \"%s\": %m " ,
1091
- path )));
1090
+ errmsg ("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes " ,
1091
+ path , nbytes , sizeof ( len ) )));
1092
1092
1093
1093
if (len <= 0 )
1094
1094
elog (ERROR , "incorrect length %d in streaming transaction's changes file \"%s\"" ,
@@ -1098,11 +1098,12 @@ apply_handle_stream_commit(StringInfo s)
1098
1098
buffer = repalloc (buffer , len );
1099
1099
1100
1100
/* and finally read the data into the buffer */
1101
- if (BufFileRead (fd , buffer , len ) != len )
1101
+ nbytes = BufFileRead (fd , buffer , len );
1102
+ if (nbytes != len )
1102
1103
ereport (ERROR ,
1103
1104
(errcode_for_file_access (),
1104
- errmsg ("could not read from streaming transaction's changes file \"%s\": %m " ,
1105
- path )));
1105
+ errmsg ("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes " ,
1106
+ path , nbytes , ( size_t ) len )));
1106
1107
1107
1108
/* copy the buffer to the stringinfo and call apply_dispatch */
1108
1109
resetStringInfo (& s2 );
@@ -2710,6 +2711,7 @@ static void
2710
2711
subxact_info_read (Oid subid , TransactionId xid )
2711
2712
{
2712
2713
char path [MAXPGPATH ];
2714
+ size_t nread ;
2713
2715
Size len ;
2714
2716
BufFile * fd ;
2715
2717
StreamXidHash * ent ;
@@ -2742,13 +2744,12 @@ subxact_info_read(Oid subid, TransactionId xid)
2742
2744
fd = BufFileOpenShared (ent -> subxact_fileset , path , O_RDONLY );
2743
2745
2744
2746
/* read number of subxact items */
2745
- if (BufFileRead (fd , & subxact_data .nsubxacts ,
2746
- sizeof (subxact_data .nsubxacts )) !=
2747
- sizeof (subxact_data .nsubxacts ))
2747
+ nread = BufFileRead (fd , & subxact_data .nsubxacts , sizeof (subxact_data .nsubxacts ));
2748
+ if (nread != sizeof (subxact_data .nsubxacts ))
2748
2749
ereport (ERROR ,
2749
2750
(errcode_for_file_access (),
2750
- errmsg ("could not read from streaming transaction's subxact file \"%s\": %m " ,
2751
- path )));
2751
+ errmsg ("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes " ,
2752
+ path , nread , sizeof ( subxact_data . nsubxacts ) )));
2752
2753
2753
2754
len = sizeof (SubXactInfo ) * subxact_data .nsubxacts ;
2754
2755
@@ -2766,11 +2767,15 @@ subxact_info_read(Oid subid, TransactionId xid)
2766
2767
sizeof (SubXactInfo ));
2767
2768
MemoryContextSwitchTo (oldctx );
2768
2769
2769
- if ((len > 0 ) && ((BufFileRead (fd , subxact_data .subxacts , len )) != len ))
2770
+ if (len > 0 )
2771
+ {
2772
+ nread = BufFileRead (fd , subxact_data .subxacts , len );
2773
+ if (nread != len )
2770
2774
ereport (ERROR ,
2771
2775
(errcode_for_file_access (),
2772
- errmsg ("could not read from streaming transaction's subxact file \"%s\": %m" ,
2773
- path )));
2776
+ errmsg ("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes" ,
2777
+ path , nread , len )));
2778
+ }
2774
2779
2775
2780
BufFileClose (fd );
2776
2781
}
0 commit comments