| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
|---|---|
| To: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Does RAISE EXCEPTION rollback previous commands in a stored function? |
| Date: | 2016-03-01 19:01:26 |
| Message-ID: | CAFj8pRC8GA6ZYRn=4TdZto4mC33zm6LHQXs7JAZ-R+rOFzM+8A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi
2016-03-01 19:41 GMT+01:00 Alexander Farber <alexander(dot)farber(at)gmail(dot)com>:
> Good evening,
>
> in PostgreSQL 9.5 does RAISE EXCEPTION reliably rollback all previous
> commands in a stored function?
>
> I have a stored function (the code is at the bottom), which takes a JSON
> array of objects as arguments.
>
> First it prepares some data and then loops through the JSON array and
> upserts the objects into a table.
>
> However if any of the objects fails an authenticity check (using md5 +
> some secret string) - I would like to rollback everything.
>
> Since I can not use START TRANSACTION in a stored function, I wonder if
> another loop should be added at the very beginning - or if I can just use
> the one I already have at the end.
>
transaction is started implicitly when you start SQL statement.
Pavel
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Igor Neyman | 2016-03-01 19:02:33 | Re: multiple UNIQUE indices for FK |
| Previous Message | Andreas Kretschmer | 2016-03-01 18:48:42 | Re: Does RAISE EXCEPTION rollback previous commands in a stored function? |