Re: Proposal "stack trace" like debugging option in PostgreSQL - Mailing list pgsql-general

From Tom Lane
Subject Re: Proposal "stack trace" like debugging option in PostgreSQL
Date
Msg-id 13257.1470003345@sss.pgh.pa.us
Whole thread Raw
In response to Re: Proposal "stack trace" like debugging option in PostgreSQL  (Edson Richter <edsonrichter@hotmail.com>)
Responses Re: Proposal "stack trace" like debugging option in PostgreSQL  (Charles Clavadetscher <clavadetscher@swisspug.org>)
List pgsql-general
Edson Richter <edsonrichter@hotmail.com> writes:
>> From: tgl@sss.pgh.pa.us
>> Uh, doesn't the CONTEXT field of error messages give you that already?

> Would you give me an example where I can get the info you mention above? Do I need to enable some kind of parameter
toget this context field? 

Well, you have not mentioned what sort of client environment you are
using, but the server certainly sends that information.  In psql,
for example, I can do this:

regression=# create table foo (f1 int primary key, f2 text);
CREATE TABLE
regression=# create function ifoo(int, text) returns void as
$$ begin insert into foo values($1,$2); end $$ language plpgsql;
CREATE FUNCTION
regression=# create function ifoo2(int, text) returns void as
$$ begin perform ifoo($1,$2); end $$ language plpgsql;
CREATE FUNCTION
regression=# select ifoo2(1,'foo');
 ifoo2
-------

(1 row)

regression=# select ifoo2(1,'foo');
ERROR:  duplicate key value violates unique constraint "foo_pkey"
DETAIL:  Key (f1)=(1) already exists.
CONTEXT:  SQL statement "insert into foo values($1,$2)"
PL/pgSQL function ifoo(integer,text) line 1 at SQL statement
SQL statement "SELECT ifoo($1,$2)"
PL/pgSQL function ifoo2(integer,text) line 1 at PERFORM

If you're using a misdesigned client that will not show these auxiliary
error fields, you could try looking in the server log --- at default
log verbosity, it will contain that info too.  The above test case
gave me this log entry:

ERROR:  duplicate key value violates unique constraint "foo_pkey"
DETAIL:  Key (f1)=(1) already exists.
CONTEXT:  SQL statement "insert into foo values($1,$2)"
        PL/pgSQL function ifoo(integer,text) line 1 at SQL statement
        SQL statement "SELECT ifoo($1,$2)"
        PL/pgSQL function ifoo2(integer,text) line 1 at PERFORM
STATEMENT:  select ifoo2(1,'foo');

            regards, tom lane


pgsql-general by date:

Previous
From: Patrick B
Date:
Subject: pg_archivecleanup standalone bash script
Next
From: "David G. Johnston"
Date:
Subject: Re: pg_archivecleanup standalone bash script