Search Postgresql Archives

Re: PostgreSQL transaction aborted on SQL error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Urko Lekuona schrieb am 04.08.2020 um 10:44:
> First time writing here, I hope this is the right place to ask this
> kind of question. I've been working with PostgreSQL for a while now
> but i've just found out that PostgreSQL marks my transaction for
> ROLLBACK and even stops the execution of the transaction if an error
> occurs.

Which is exactly how a transaction is defined:

Either all statements are successful or none.


> If you run it, you'd see that when the unique key constraint is
> violated, my transaction is stopped

You can use INSERT ON CONFLICT DOT NOTHING to avoid that.


> make it work like other RDBMS do, where if a statement failed, the
> transaction could continue

Which completely violates the idea of a transaction.

The choices you have are:

* use auto-commit
* make sure your inserts don't throw an error
* use manual savepoints around each statement (don't forget DDL statements!)

Thomas






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux