Re: Am I in the same transaction block in complex PLPGSQL?
| От | Tom Lane |
|---|---|
| Тема | Re: Am I in the same transaction block in complex PLPGSQL? |
| Дата | |
| Msg-id | 830175.1647010872@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Am I in the same transaction block in complex PLPGSQL? (Durumdara <durumdara@gmail.com>) |
| Ответы |
Re: Am I in the same transaction block in complex PLPGSQL?
|
| Список | pgsql-general |
Durumdara <durumdara@gmail.com> writes:
> In autocommit mode, when I start a simple update or select, it is one
> transaction, so if something fails, the whole modification is rolled back
> (there is no "half update", or "only first record updated").
> What will happen with complex statements, like PLPGSQL stored procedure, or
> trigger?
It's one transaction unless you take steps to make it something else.
In plpgsql, you can make "sub transactions" with BEGIN/EXCEPTION blocks
(an exception rolls back only side-effects that happened since BEGIN).
Or, if it's a procedure not a function, you can explicitly COMMIT
what's been done so far, and then your next action starts a new
transaction. But without such measures, all actions executed by
a function are part of the same transaction as the calling statement.
regards, tom lane
В списке pgsql-general по дате отправления: