@@ -1398,7 +1398,7 @@ apply_spooled_messages(TransactionId xid, XLogRecPtr lsn)
1398
1398
nchanges = 0 ;
1399
1399
while (true)
1400
1400
{
1401
- int nbytes ;
1401
+ size_t nbytes ;
1402
1402
int len ;
1403
1403
1404
1404
CHECK_FOR_INTERRUPTS ();
@@ -1414,8 +1414,8 @@ apply_spooled_messages(TransactionId xid, XLogRecPtr lsn)
1414
1414
if (nbytes != sizeof (len ))
1415
1415
ereport (ERROR ,
1416
1416
(errcode_for_file_access (),
1417
- errmsg ("could not read from streaming transaction's changes file \"%s\": %m " ,
1418
- path )));
1417
+ errmsg ("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes " ,
1418
+ path , nbytes , sizeof ( len ) )));
1419
1419
1420
1420
if (len <= 0 )
1421
1421
elog (ERROR , "incorrect length %d in streaming transaction's changes file \"%s\"" ,
@@ -1425,11 +1425,12 @@ apply_spooled_messages(TransactionId xid, XLogRecPtr lsn)
1425
1425
buffer = repalloc (buffer , len );
1426
1426
1427
1427
/* and finally read the data into the buffer */
1428
- if (BufFileRead (fd , buffer , len ) != len )
1428
+ nbytes = BufFileRead (fd , buffer , len );
1429
+ if (nbytes != len )
1429
1430
ereport (ERROR ,
1430
1431
(errcode_for_file_access (),
1431
- errmsg ("could not read from streaming transaction's changes file \"%s\": %m " ,
1432
- path )));
1432
+ errmsg ("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes " ,
1433
+ path , nbytes , ( size_t ) len )));
1433
1434
1434
1435
/* copy the buffer to the stringinfo and call apply_dispatch */
1435
1436
resetStringInfo (& s2 );
@@ -3192,6 +3193,7 @@ static void
3192
3193
subxact_info_read (Oid subid , TransactionId xid )
3193
3194
{
3194
3195
char path [MAXPGPATH ];
3196
+ size_t nread ;
3195
3197
Size len ;
3196
3198
BufFile * fd ;
3197
3199
MemoryContext oldctx ;
@@ -3211,13 +3213,12 @@ subxact_info_read(Oid subid, TransactionId xid)
3211
3213
return ;
3212
3214
3213
3215
/* read number of subxact items */
3214
- if (BufFileRead (fd , & subxact_data .nsubxacts ,
3215
- sizeof (subxact_data .nsubxacts )) !=
3216
- sizeof (subxact_data .nsubxacts ))
3216
+ nread = BufFileRead (fd , & subxact_data .nsubxacts , sizeof (subxact_data .nsubxacts ));
3217
+ if (nread != sizeof (subxact_data .nsubxacts ))
3217
3218
ereport (ERROR ,
3218
3219
(errcode_for_file_access (),
3219
- errmsg ("could not read from streaming transaction's subxact file \"%s\": %m " ,
3220
- path )));
3220
+ errmsg ("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes " ,
3221
+ path , nread , sizeof ( subxact_data . nsubxacts ) )));
3221
3222
3222
3223
len = sizeof (SubXactInfo ) * subxact_data .nsubxacts ;
3223
3224
@@ -3235,11 +3236,15 @@ subxact_info_read(Oid subid, TransactionId xid)
3235
3236
sizeof (SubXactInfo ));
3236
3237
MemoryContextSwitchTo (oldctx );
3237
3238
3238
- if ((len > 0 ) && ((BufFileRead (fd , subxact_data .subxacts , len )) != len ))
3239
+ if (len > 0 )
3240
+ {
3241
+ nread = BufFileRead (fd , subxact_data .subxacts , len );
3242
+ if (nread != len )
3239
3243
ereport (ERROR ,
3240
3244
(errcode_for_file_access (),
3241
- errmsg ("could not read from streaming transaction's subxact file \"%s\": %m" ,
3242
- path )));
3245
+ errmsg ("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes" ,
3246
+ path , nread , len )));
3247
+ }
3243
3248
3244
3249
BufFileClose (fd );
3245
3250
}
0 commit comments