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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Proposal "stack trace" like debugging option in PostgreSQL
Дата
Msg-id 13257.1470003345@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Proposal "stack trace" like debugging option in PostgreSQL  (Edson Richter <edsonrichter@hotmail.com>)
Ответы Re: Proposal "stack trace" like debugging option in PostgreSQL  (Charles Clavadetscher <clavadetscher@swisspug.org>)
Список 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 по дате отправления:

Предыдущее
От: Patrick B
Дата:
Сообщение: pg_archivecleanup standalone bash script
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: pg_archivecleanup standalone bash script