Re: fix "Success" error messages

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Shawn Debnath <sdn@amazon.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-06-19T02:51:55Z
Lists: pgsql-hackers
On Tue, Jun 18, 2019 at 09:13:19AM -0700, Shawn Debnath wrote:
>>  		case SLRU_WRITE_FAILED:
>>  			ereport(ERROR,
>>  					(errcode_for_file_access(),
>>  					 errmsg("could not access status of transaction %u", xid),
>> -					 errdetail("Could not write to file \"%s\" at offset %u: %m.",
>> -							   path, offset)));
>> +					 errno == 0
>> +					 ? errdetail("Short write to file \"%s\" at offset %u.", path, offset)
>> +					 : errdetail("Could not write to file \"%s\" at offset %u: %m.",
>> +								 path, offset)));

There is no point to call errcode_for_file_access() if we know that
errno is 0.  Not a big deal, still..  The last time I looked at that,
the best way I could think of would be to replace slru_errcause with a
proper error string generated at error time.  Perhaps the partial
read/write case does not justify this extra facility.  I don't know.
At least that would be more flexible.

> Similarly, "Encountered partial write to file ..." would be better? Not 
> a 100% on using "Encountered" but "partial" seems to be the right word 
> to use here.

811b6e36 has done some work so as we have more consistency in the
error messages and I don't think we should introduce more flavors of
this stuff as that makes the life of translators harder.

-   if (CloseTransientFile(fd))
+   if (CloseTransientFile(fd) < 0)
Some spots are missing:
$ git grep "CloseTransientFile" | grep "))" | wc -l
30
--
Michael

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Better error messages for short reads/writes in SLRU

  2. pg_checksums: Handle read and write returns correctly

  3. Use consistent style for checking return from system calls