Re: rollback in C functions

From: Juan Pablo L <jpablolorenzetti(at)gmail(dot)com>
To: Chris Mair <chris(at)1006(dot)org>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: rollback in C functions
Date: 2015-02-19 21:14:06
Message-ID: CABSYDaZt+FLhkc1XN-ZnSKJ2-XqrHaBft1jCMRvKR+DVXmGUPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Thanks Chris, yes i have already tested ereport and even made up my own
sql state to report and error but from the application i can not access
this error code directly (through the PQexec,PQresultErrorField,etc
functions because the PGresult returns NULL) but i have to register a
callback function that will be called with this error code with the idea to
format the error message so i could intercept this and do something, but
this does not allow me to have direct access to the flow where this is all
happening .. i hope it is clear ...

On 19 February 2015 at 15:02, Chris Mair <chris(at)1006(dot)org> wrote:

> > The function is to execute updates on each ID assigning the value, but if
> > one of these operation fails (does not meet certain criteria)
> > inside the function i would like to rollback and leave everything
> > untouched, in case other ID;s were already updated previously,
> > and come back to the caller and infor
>
> Hi,
>
> I think you want ereport(), here is an example:
> http://www.postgresql.org/docs/9.3/static/xfunc-c.html
>
> Bye,
> Chris.
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2015-02-19 21:14:50 Re: select where true, or select where input = '$var'
Previous Message Chris Mair 2015-02-19 21:02:38 Re: rollback in C functions