Search Postgresql Archives

Re: Proposal "stack trace" like debugging option in PostgreSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Edson Richter <edsonrichter@xxxxxxxxxxx> writes:
>> From: tgl@xxxxxxxxxxxxx
>> 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 to get 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux