Cleaning up missing ERRCODE assignments

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Cleaning up missing ERRCODE assignments
Date: 2015-08-01 15:39:01
Message-ID: 32182.1438443541@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I believe we have a project policy that all user-facing error reports
should go through ereport not elog (so that they're translatable) and
should not have ERRCODE_INTERNAL_ERROR as SQLSTATE. It's sometimes
debatable where the line is between user-facing and not, but surely any
error that is triggered by the standard regression tests has to be
considered user-facing. Yet running the tests with log_error_verbosity
set to verbose turns up quite a few XX000 log entries.

The attached patch fixes all the cases exposed by the regression tests.
I also went through each affected file and adjusted any other elog or
ereport calls that seemed to need it, on the theory that such oversights
probably travel in herds. I don't pretend that this is a complete fix,
but it's at least a down payment on the problem.

Probably the main thing that's worth discussing here is what to do in
plperl/plpython/pltcl when reporting an error thrown from the respective
language interpreter; in most cases we don't have a clear idea what
SQLSTATE should be used, but that doesn't make ERRCODE_INTERNAL_ERROR an
acceptable choice. I used ERRCODE_EXTERNAL_ROUTINE_EXCEPTION where there
was not an obviously better candidate, but I wonder if anyone has a
different idea?

I propose to back-patch this into 9.5, but not further; it's not an
important enough issue to justify changing SQLSTATE behavior in stable
branches.

regards, tom lane

Attachment Content-Type Size
errcode-cleanups-1.patch text/x-diff 43.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-08-01 15:59:17 Re: [sqlsmith] Failed assertion in joinrels.c
Previous Message Andres Freund 2015-08-01 15:14:10 No more libedit?! - openssl plans to switch to APL2