Re: strange commit behavior

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Flavio Palumbo <f(dot)palumbo(at)silmasoftware(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: strange commit behavior
Date: 2008-11-18 13:25:30
Message-ID: 4922C24A.8090409@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Flavio Palumbo wrote:

> Unfortunately postgres seems to work in a different way, cause if there is
> just one error while the transaction is active I'm not able to commit the
> well formed data in the db, no matter if the good records were inserted
> sooner or later the error.

Yes, that's right. As soon as something goes wrong in the transaction
it's assumed that, unless you handle the error, the transaction is bad
and shouldn't be committed.

You can use savepoints (see the manual) to recover from errors, though
they have some issues if you use hundreds of thousands of savepoints in
a single transaction. It's much better to check the data on INSERT to
make sure it's OK. You can do this with an INSERT ... SELECT (and check
the rowcount), with a PL/PgSQL function that returns a result value, do
it client-side, etc.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2008-11-18 13:33:12 Re: Urgent - Grant
Previous Message Christiaan Willemsen 2008-11-18 13:05:59 Re: FreeBSD 7 needing to allocate lots of shared memory