pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jack Gao <jackgo73@outlook.com>
To: pgsql-general@postgresql.org
Subject: Re: SQL statement in an error report for deferred constraint violation.
Date: Mon, 16 Apr 2018 02:32:09 -0700 (MST)
Message-ID: <1523871129422-0.post@n3.nabble.com> (raw)
In-Reply-To: <b2c97292-d907-ba72-e25d-299e2b30f868@FreeBSD.org>
References: <b2c97292-d907-ba72-e25d-299e2b30f868@FreeBSD.org>

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




view thread (2+ messages)

Message-ID: <1523871129422-0.post@n3.nabble.com>
Permalink:  ../1523871129422-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1523871129422-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: jackgo73@outlook.com
  Subject: Re: SQL statement in an error report for deferred constraint violation.
  In-Reply-To: <1523871129422-0.post@n3.nabble.com>
  References: <b2c97292-d907-ba72-e25d-299e2b30f868@FreeBSD.org> <1523871129422-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox