Re: rollback in C functions

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: rollback in C functions
Date: 2015-02-19 22:22:15
Message-ID: 54E66217.4000207@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/19/2015 2:02 PM, Juan Pablo L wrote:
> Thank you Alvaro, i m afraid ereport seems to be the way, that it is
> complicated to catch this error code in the code of the caller. cause
> you have to use a callback etc etc

a query that triggers ereport(ERROR,....) should return a PGresult* that
you pass to PQresultStatus(), which should indicate PGRES_FATAL_ERROR,
so you then call PQresultErrorField(PGresult, PG_DIAG_SQLSTATE) to get
back the SQLSTATE code.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Juan Pablo L 2015-02-19 22:27:21 Re: rollback in C functions
Previous Message Juan Pablo L 2015-02-19 22:02:55 Re: rollback in C functions