Thread: pgsql: Provide database object names as separate fields in error messag

pgsql: Provide database object names as separate fields in error messag

From
Tom Lane
Date:
Provide database object names as separate fields in error messages.

This patch addresses the problem that applications currently have to
extract object names from possibly-localized textual error messages,
if they want to know for example which index caused a UNIQUE_VIOLATION
failure.  It adds new error message fields to the wire protocol, which
can carry the name of a table, table column, data type, or constraint
associated with the error.  (Since the protocol spec has always instructed
clients to ignore unrecognized field types, this should not create any
compatibility problem.)

Support for providing these new fields has been added to just a limited set
of error reports (mainly, those in the "integrity constraint violation"
SQLSTATE class), but we will doubtless add them to more calls in future.

Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with
additional hacking by Tom Lane.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/991f3e5ab3f8196d18d5b313c81a5f744f3baaea

Modified Files
--------------
doc/src/sgml/errcodes.sgml            |   16 ++++-
doc/src/sgml/libpq.sgml               |   64 +++++++++++++++++
doc/src/sgml/protocol.sgml            |   74 +++++++++++++++++++
doc/src/sgml/sources.sgml             |   56 +++++++++++++++
src/backend/access/hash/hash.c        |    2 +-
src/backend/access/hash/hashsort.c    |    5 +-
src/backend/access/nbtree/nbtinsert.c |   14 +++-
src/backend/access/nbtree/nbtree.c    |    4 +-
src/backend/access/nbtree/nbtsort.c   |   12 +++-
src/backend/commands/tablecmds.c      |    9 ++-
src/backend/commands/typecmds.c       |   28 +++++++-
src/backend/executor/execMain.c       |    8 ++-
src/backend/executor/execQual.c       |    7 ++-
src/backend/executor/execUtils.c      |    8 ++-
src/backend/utils/adt/domains.c       |   50 ++++++++++++-
src/backend/utils/adt/ri_triggers.c   |   16 +++--
src/backend/utils/cache/relcache.c    |   76 ++++++++++++++++++++
src/backend/utils/error/elog.c        |  124 +++++++++++++++++++++++++++++++++
src/backend/utils/sort/tuplesort.c    |   13 +++-
src/include/access/hash.h             |    2 +-
src/include/access/nbtree.h           |    3 +-
src/include/postgres_ext.h            |    5 ++
src/include/utils/builtins.h          |    5 +-
src/include/utils/elog.h              |    7 ++
src/include/utils/relcache.h          |    8 ++
src/include/utils/tuplesort.h         |    6 +-
src/interfaces/libpq/fe-protocol3.c   |   23 ++++++
27 files changed, 604 insertions(+), 41 deletions(-)