pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
SQL statement in an error report for deferred constraint violation. 2+ messages / 2 participants [nested] [flat]
* SQL statement in an error report for deferred constraint violation. @ 2018-04-05 00:04 Konrad Witaszczyk <def@FreeBSD.org> 2018-04-16 09:32 ` Re: SQL statement in an error report for deferred constraint violation. Jack Gao <jackgo73@outlook.com> 0 siblings, 1 reply; 2+ messages in thread From: Konrad Witaszczyk @ 2018-04-05 00:04 UTC (permalink / raw) To: pgsql-general@lists.postgresql.org 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 Attachments: signature.asc (application/pgp-signature, 962B) download ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: SQL statement in an error report for deferred constraint violation. 2018-04-05 00:04 SQL statement in an error report for deferred constraint violation. Konrad Witaszczyk <def@FreeBSD.org> @ 2018-04-16 09:32 ` Jack Gao <jackgo73@outlook.com> 0 siblings, 0 replies; 2+ messages in thread From: Jack Gao @ 2018-04-16 09:32 UTC (permalink / raw) To: 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) > <http://www.postgresql-archive.org/attachment/6015088/0/signature.asc> 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-04-16 09:32 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-04-05 00:04 SQL statement in an error report for deferred constraint violation. Konrad Witaszczyk <def@FreeBSD.org> 2018-04-16 09:32 ` Jack Gao <jackgo73@outlook.com>
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