Re: SQL statement in an error report for deferred constraint violation.

From: Jack Gao <jackgo73(at)outlook(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL statement in an error report for deferred constraint violation.
Date: 2018-04-16 09:32:09
Message-ID: 1523871129422-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Konrad Witaszczyk wrote
> Hi,
>
> While PQresultErrorField() from libpq allows to get context in which an
> error

> occurred for immediate constraints, and thus an SQL statement which caused
> the
> constraint violation, I cannot see any way to find out which SQL statement
> caused an error in case of deferred constraints, in particular deferred
> foreign
> key constraints.
>
> Is there any way to check which SQL statement or at least which row
> violated a
> constraint when it's deferred? If not does anyone know why there is such
> restriction?
>
>
> Konrad
>
>
>
> signature.asc (981 bytes)
> &lt;http://www.postgresql-archive.org/attachment/6015088/0/signature.asc&gt;

First of all, you need to locate the problem SQL by modifying log
parameters.

sed -ir "s/#*logging_collector.*/logging_collector= on/"
$PGDATA/postgresql.conf
sed -ir "s/#*log_directory.*/log_directory = 'pg_log'/"
$PGDATA/postgresql.conf
sed -ir "s/#*log_statement.*/log_statement= 'all'/" $PGDATA/postgresql.conf

Execute this SQL and send error message in the log.

regards

Jack Gao

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Keith Fiske 2018-04-16 15:16:40 client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade
Previous Message Gunnar "Nick" Bluth 2018-04-16 08:09:08 Re: Data migration from postgres 8.4 to 9.4