Re: Adjust errorcode in background worker code - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Adjust errorcode in background worker code
Date
Msg-id CA+TgmoaNUubEhZq3=TcwHbF+UZOsp-Z2Ko5+Dv=AFe87WXVcTg@mail.gmail.com
Whole thread Raw
In response to Re: Adjust errorcode in background worker code  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Responses Re: Adjust errorcode in background worker code  (Craig Ringer <craig@2ndquadrant.com>)
Re: Adjust errorcode in background worker code  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
List pgsql-hackers
On Sun, Jun 28, 2015 at 10:43 PM, Amit Langote
<Langote_Amit_f8@lab.ntt.co.jp> wrote:
> On 2015-06-29 AM 11:36, Amit Langote wrote:
>> Hi,
>>
>> How about the attached that adjusts errorcode for the error related to
>> checking the flag bgw_flags in BackgroundWorkerInitializeConnection*()
>> functions so that it matches the treatment in SanityCheckBackgroundWorker()?
>>
>> s/ERRCODE_PROGRAM_LIMIT_EXCEEDED/ERRCODE_INVALID_PARAMETER_VALUE/g
>>
>> There is already a "/* XXX is this the right errcode? */" there.
>
> Oops, a wrong thing got attached.
>
> Please find correct one attached this time.

Well, I'm just catching up on some old email and saw this thread.  I
like the idea of trying to use the best possible error code, but I'm
not so sure this is an improvement.  One problem is that
ERRCODE_INVALID_PARAMETER_VALUE is that we use it, uh, a lot:

[rhaas pgsql]$ git grep ERRCODE_ | sed 's/.*ERRCODE_/ERRCODE_/;
s/[^A-Z0-9_].*//;' | sort  | uniq -c | sort -n -r | head540 ERRCODE_FEATURE_NOT_SUPPORTED442
ERRCODE_INVALID_PARAMETER_VALUE380ERRCODE_SYNTAX_ERROR194 ERRCODE_WRONG_OBJECT_TYPE194 ERRCODE_UNDEFINED_OBJECT181
ERRCODE_DATATYPE_MISMATCH180ERRCODE_INSUFFICIENT_PRIVILEGE150 ERRCODE_INVALID_TEXT_REPRESENTATION137
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE123ERRCODE_PROGRAM_LIMIT_EXCEEDED
 

I wonder if we need to think about inventing some new error codes.  I
can sort of understand that "feature not supported" is something that
can come in a large number of different contexts and mean pretty much
the same all the time, but I'm betting that things like "invalid
parameter value" and "invalid text representation" and "object not in
prerequisite state" cover an amazing breadth of errors that may not
actually be that similar to each other.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Transactions involving multiple postgres foreign servers
Next
From: Kevin Grittner
Date:
Subject: Re: Getting sorted data from foreign server for merge join