Re: second "begin transaction" emits a warning

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: second "begin transaction" emits a warning
Дата
Msg-id 531.1134774690@sss.pgh.pa.us
обсуждение исходный текст
Ответ на second "begin transaction" emits a warning  (Jaime Casanova <systemguards@gmail.com>)
Список pgsql-hackers
Jaime Casanova <systemguards@gmail.com> writes:
> recently someone show us this code in the spanish list...

>> BEGIN WORK;
>> INSERT INTO mitabla VALUES (1);
>> BEGIN TRANSACTION;
>> INSERT INTO mitabla VALUES (2);
>> INSERT INTO mitabla VALUES (3);
>> COMMIT TRANSACTION;
>> INSERT INTO mitabla VALUES (4);
>> ROLLBACK WORK;

> he was expecting an empty table but instead he gets this:

> so, why BeginTransactionBlock emits just a warning and not an error?

I can't get real excited about this case.  If the second BEGIN had
errored out, he'd *still* not get an empty table: the COMMIT would
end the aborted transaction, then the last INSERT would succeed,
then the ROLLBACK would complain about "no transaction in progress".
Maybe there's an argument for turning the warning into an error,
but this example doesn't provide it.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Treat
Дата:
Сообщение: reducing bloat in pg_statistic
Следующее
От: Robert Treat
Дата:
Сообщение: Re: second "begin transaction" emits a warning