Getting more detail in plpython error messages

From: Jeff Ross <jross(at)openvistas(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Getting more detail in plpython error messages
Date: 2022-03-07 17:46:03
Message-ID: 55b1d962-ee85-6fa7-d594-cdd905eb6640@openvistas.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

In psql a database error will print both ERROR: and DETAIL: lines.

postgres(at)testdb# delete from inspection where bundle_id in (select id
from test_archive_20170401.load order by id);
ERROR:  update or delete on table "inspection" violates foreign key
constraint "inspection_weather_inspection_id_inspection_id_fk" on table
"inspection_weather"
DETAIL:  Key (id)=(158967) is still referenced from table
"inspection_weather".

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(at)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?

Thanks,

Jeff

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andres Freund 2022-03-07 17:54:22 Re: Interesting fail when migrating Pg from Ubuntu Bionic to Focal
Previous Message Tom Lane 2022-03-07 17:22:26 Re: Interesting fail when migrating Pg from Ubuntu Bionic to Focal