pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Ross <jross@openvistas.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Getting more detail in plpython error messages
Date: Mon, 07 Mar 2022 13:06:41 -0500
Message-ID: <206445.1646676401@sss.pgh.pa.us> (raw)
In-Reply-To: <55b1d962-ee85-6fa7-d594-cdd905eb6640@openvistas.net>
References: <55b1d962-ee85-6fa7-d594-cdd905eb6640@openvistas.net>

Jeff Ross <jross@openvistas.net> writes:
> With plpython (both u and 3u) all I see printed is the ERROR part.

>      try:
>          check = plpy.execute("delete from inspection where bundle_id in 
> (select id from test_archive_20170401.load order by id)")
>      except plpy.SPIError as e:
>          plpy.notice("Error!", e)

> postgres@testdb# select * from test_delete();
> NOTICE:  ('Error!', ForeignKeyViolation('update or delete on table 
> "inspection" violates foreign key constraint 
> "inspection_weather_inspection_id_inspection_id_fk" on table 
> "inspection_weather"',))

> Is there a way to get the DETAIL part as well?

It's not very well documented AFAICS, but a SPIError object has a
"detail" attribute, so "e.detail" should help you.  It looks like
you might prefer to print "e.spidata", which seems to contain all
the available fields.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <206445.1646676401@sss.pgh.pa.us>
Permalink:  ../206445.1646676401@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/206445.1646676401@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jross@openvistas.net
  Subject: Re: Getting more detail in plpython error messages
  In-Reply-To: <206445.1646676401@sss.pgh.pa.us>
  References: <55b1d962-ee85-6fa7-d594-cdd905eb6640@openvistas.net> <206445.1646676401@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox