Skip site navigation (1) Skip section navigation (2)

Re: Retrieving multiple error messages via libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeffrey Brendecke <yakhki(at)yahoo(dot)de>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Retrieving multiple error messages via libpq
Date: 2007-11-26 02:55:57
Message-ID: 26526.1196045757@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
Jeffrey Brendecke <yakhki(at)yahoo(dot)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

In response to

pgsql-interfaces by date

Next:From: Jeffrey BrendeckeDate: 2007-11-26 23:52:50
Subject: v8.1: Error severity on libpq PGconn*
Previous:From: Jeffrey BrendeckeDate: 2007-11-26 02:48:10
Subject: Retrieving multiple error messages via libpq

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group