pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeffrey Brendecke <yakhki@yahoo.de>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Retrieving multiple error messages via libpq
Date: Sun, 25 Nov 2007 21:55:57 -0500
Message-ID: <26526.1196045757@sss.pgh.pa.us> (raw)
In-Reply-To: <798544.38898.qm@web26905.mail.ukl.yahoo.com>
References: <798544.38898.qm@web26905.mail.ukl.yahoo.com>

Jeffrey Brendecke <yakhki@yahoo.de> writes:
> When I submit the following SQL statement for execution via the psql client:

> 'BEGIN TRANSACTION; INSERT INTO IdOnly (id) VALUES (40); INSERT INTO IdOnly (id) VALUES (21); INSERT INTO IdOnly (id) VALUES (42); COMMIT TRANSACTION;'

> I get the following error messages (this failure is expected):

> ERROR:  duplicate key violates unique constraint "idonly_pkey"
> ERROR:  current transaction is aborted, commands ignored until end of transaction block

> However, when retreiving the error message via PQresultErrorMessage(), I get:
> ERROR:  duplicate key violates unique constraint "idonly_pkey"

> How is the additional error message retrieved?

It isn't, because there isn't any additional message.  When you submit
multiple commands in a single PQexec string (as I suspect you did),
the backend abandons processing the string as soon as there's one error.
psql, however, chops up its input at semicolons and submits each command
as a separate PQexec.

			regards, tom lane



view thread (2+ messages)

Message-ID: <26526.1196045757@sss.pgh.pa.us>
Permalink:  ../26526.1196045757@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26526.1196045757@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: tgl@sss.pgh.pa.us, yakhki@yahoo.de
  Subject: Re: Retrieving multiple error messages via libpq
  In-Reply-To: <26526.1196045757@sss.pgh.pa.us>

* 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