Re: [RFC] Should I embed or parameterize syscall/Win32 function names from error messages?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [RFC] Should I embed or parameterize syscall/Win32 function names from error messages?
Date: 2017-02-06 06:33:04
Message-ID: 11623.1486362784@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com> writes:
> I added a few ereport() calls that emit the same message except for the Win32 API name. Which of the following do you think is the best? I'd like to follow the majority.

> [Option 1]
> ereport(elevel,
> (errmsg("could not enable Lock pages in memory user right"),
> errdetail("Failed system call was %s, error code %lu", "OpenProcessToken", GetLastError())));

> [Option 2]
> ereport(elevel,
> (errmsg("could not enable Lock Pages in Memory user right: error code %lu", GetLastError()),
> errdetail("Failed system call was OpenProcessToken.")));

TBH, I think you are worried about the wrong thing here. You could drop
both of those errdetail calls altogether and be little worse off. In the
places where we have errdetail calls like "failed system call was xxx",
the main point is to show the exact parameters that were given to the
system call, and neither of these do that. These errdetail messages
would only be useful if the identical ereport errmsg might be issued
for failures from different underlying Windows calls --- but I doubt
that's what you're intending here.

My problem with these messages is I am not sure what "memory user right"
means. Probably that just needs a bit of editing. But I'd go for
something like "could not do xxx: error code %lu", and not bother
mentioning the system call name, unless failing to do so has some
impact on whether we could understand what happened from a field
report of this error message.

(See the "Function Names" item in our message style guidelines
for more about this issue. Maybe we need to expand that item
some more.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Claudio Freire 2017-02-06 06:36:39 Re: ParallelFinish-hook of FDW/CSP (Re: Steps inside ExecEndGather)
Previous Message Tsunakawa, Takayuki 2017-02-06 06:31:45 Re: [RFC] Should I embed or parameterize syscall/Win32 function names from error messages?