Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRHky-0006bP-38 for pgsql-general@arkaria.postgresql.org; Mon, 07 Mar 2022 18:06:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nRHkw-0005bO-Ft for pgsql-general@arkaria.postgresql.org; Mon, 07 Mar 2022 18:06:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRHkw-0005bE-5N for pgsql-general@lists.postgresql.org; Mon, 07 Mar 2022 18:06:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRHkp-0003VR-LS for pgsql-general@lists.postgresql.org; Mon, 07 Mar 2022 18:06:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 227I6for206446; Mon, 7 Mar 2022 13:06:41 -0500 From: Tom Lane To: Jeff Ross cc: pgsql-general@lists.postgresql.org Subject: Re: Getting more detail in plpython error messages In-reply-to: <55b1d962-ee85-6fa7-d594-cdd905eb6640@openvistas.net> References: <55b1d962-ee85-6fa7-d594-cdd905eb6640@openvistas.net> Comments: In-reply-to Jeff Ross message dated "Mon, 07 Mar 2022 10:46:03 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <206444.1646676401.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 07 Mar 2022 13:06:41 -0500 Message-ID: <206445.1646676401@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeff Ross writes: > With plpython (both u and 3u) all I see printed is the ERROR part. > =C2=A0=C2=A0=C2=A0 try: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 check =3D plpy.execute("dele= te from inspection where bundle_id in = > (select id from test_archive_20170401.load order by id)") > =C2=A0=C2=A0=C2=A0 except plpy.SPIError as e: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 plpy.notice("Error!", e) > postgres@testdb# select * from test_delete(); > NOTICE:=C2=A0 ('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