Обсуждение: pgsql: Improve error messages for bytea decoding failures.
Improve error messages for bytea decoding failures. Craig Ringer Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/f73474382cb304b4f043e5de89c28b0365c04156 Modified Files -------------- src/backend/utils/adt/encode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Robert Haas <rhaas@postgresql.org> writes:
> Improve error messages for bytea decoding failures.
Per style guide, errhints should be capitalized full sentences, ie
- errhint("input data is missing padding, truncated, or otherwise corrupted")));
+ errhint("Input data is missing padding, truncated, or otherwise corrupted.")));
Also, it's unwise to use %c on a value you aren't sure is an ASCII
character; that's likely to produce an invalidly-encoded error message,
which will *not* be an improvement of the user experience.
regards, tom lane
On Wed, Jul 9, 2014 at 11:14 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <rhaas@postgresql.org> writes:
>> Improve error messages for bytea decoding failures.
>
> Per style guide, errhints should be capitalized full sentences, ie
>
> - errhint("input data is missing padding, truncated, or otherwise corrupted")));
> + errhint("Input data is missing padding, truncated, or otherwise corrupted.")));
Oops.
> Also, it's unwise to use %c on a value you aren't sure is an ASCII
> character; that's likely to produce an invalidly-encoded error message,
> which will *not* be an improvement of the user experience.
Yeah, I was a little worried about that. But I noticed that in the
same file we already had this:
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid hexadecimal digit: \"%c\"", c)));
So I figured it must be OK. If it's not, we should fix both places.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company