Re: BUG #6300: duplicate key value violates unique constraint

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tomas Vondra <tv(at)fuzzy(dot)cz>, tigran(dot)mkrtchyan(at)desy(dot)de, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6300: duplicate key value violates unique constraint
Date: 2011-11-23 12:19:33
Message-ID: CAEYLb_XdgKec2rNBhbj4HxU5PZ4UBZ75fp-D92+4BLqhAkNSUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 23 November 2011 02:49, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> There is no sort of systematic labeling of error messages in the log
> to enable the DBA to figure out that the first error message is likely
> nothing more serious than an integrity constraint doing its bit to
> preserve data integrity, while the second is likely a sign of
> impending disaster.

+1

I suggested that there be an INTERNAL_ERROR severity level before on
this list, in response to an opaque internal error that was raised in
the planner due to a bug in master (it was a simple elog() call that
raised the error), and the idea was not well received. Tom said that
"Well, the SQLSTATE for this sort of thing is already
ERRCODE_INTERNAL_ERROR". A quick search of that shows that it only
appears in the following places:

src/pl/plpgsql/src/plerrcodes.h
876: "internal_error", ERRCODE_INTERNAL_ERROR

src/backend/access/gist/gistsplit.c
374: (errcode(ERRCODE_INTERNAL_ERROR),

src/backend/access/nbtree/nbtinsert.c
455: (errcode(ERRCODE_INTERNAL_ERROR),

src/backend/utils/misc/guc.c
6369: (errcode(ERRCODE_INTERNAL_ERROR),

src/backend/utils/adt/xml.c
259: xml_ereport_by_code(WARNING, ERRCODE_INTERNAL_ERROR,
3787: xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,
3816: xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,
3828: xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,

src/backend/utils/adt/ri_triggers.c
3501: (errcode(ERRCODE_INTERNAL_ERROR),

src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
125: (errcode(ERRCODE_INTERNAL_ERROR),
152: (errcode(ERRCODE_INTERNAL_ERROR),

src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
135: (errcode(ERRCODE_INTERNAL_ERROR),
162: (errcode(ERRCODE_INTERNAL_ERROR),

src/backend/utils/error/elog.c
353: edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
612: edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
648: edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;

src/backend/utils/errcodes.h
322:#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X','0','0','0')

src/backend/postmaster/pgstat.c
493: (errcode(ERRCODE_INTERNAL_ERROR),

src/include/utils/elog.h
93: * ERRCODE_INTERNAL_ERROR if elevel is ERROR or more, ERRCODE_WARNING

contrib/sepgsql/uavc.c
184: (errcode(ERRCODE_INTERNAL_ERROR),
521: (errcode(ERRCODE_INTERNAL_ERROR),

contrib/sepgsql/hooks.c
94: (errcode(ERRCODE_INTERNAL_ERROR),
426: (errcode(ERRCODE_INTERNAL_ERROR),

contrib/sepgsql/selinux.c
768: (errcode(ERRCODE_INTERNAL_ERROR),
854: (errcode(ERRCODE_INTERNAL_ERROR),

contrib/sepgsql/label.c
84: (errcode(ERRCODE_INTERNAL_ERROR),
194: (errcode(ERRCODE_INTERNAL_ERROR),
234: (errcode(ERRCODE_INTERNAL_ERROR),
464: (errcode(ERRCODE_INTERNAL_ERROR),
526: (errcode(ERRCODE_INTERNAL_ERROR),

A new severity level is called for. In addition, if we had a new
severity level, the footprint wouldn't be too bad on all those legacy
elog() calls as compared to using errcode(ERRCODE_INTERNAL_ERROR).

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrea Suisani 2011-11-23 14:58:28 Re: BUG #6303: ROW_NUMBER()
Previous Message Marco Bernasocchi 2011-11-23 11:07:05 libpq in android