From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | SF Postgres <sfpug(at)postgresql(dot)org> |
Subject: | Re: [transactions] soldier on anyway? |
Date: | 2003-11-14 03:48:33 |
Message-ID: | 20031114034833.GD4807@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
On Thu, Nov 13, 2003 at 07:35:38PM -0800, Josh Berkus wrote:
> David,
> > I've got a transaction that does a few inserts, but it's OK for
> > one specific one to fail in a specific way (adding a field that's
> > already there).
> > What's going on here, and how do I fix it?
> In a short answer: you can't. Postgresql does not allow trapping of
> exceptions; an exception will abort the transaction.
Hmm. Perhaps I can write a PL/PgSQL function that checks for the
acceptable error condition, then returns success if it found it, or
tries to do the insert if it didn't.
> Your only reasonable option is to test for the failure condition in
> some way to prevent an exception being raised.
Ouch. I can do that, and it's less pain than...
> (Your unreasonable option is to hack exception-handling for
> postgresql transactions ...)
My current C skills allow me to write, compile and run "hello, world"
with occasional success, and I'm still fuzzy about "int main(void)" ;)
Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
From | Date | Subject | |
---|---|---|---|
Next Message | Dror Matalon | 2003-11-14 04:33:39 | Re: [transactions] soldier on anyway? |
Previous Message | Josh Berkus | 2003-11-14 03:35:38 | Re: [transactions] soldier on anyway? |