Re: SAVEPOINT SQL conformance

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: SAVEPOINT SQL conformance
Дата
Msg-id 414CAB84.2090102@opencloud.com
обсуждение исходный текст
Ответ на SAVEPOINT SQL conformance  ("Michael Paesold" <mpaesold@gmx.at>)
Список pgsql-hackers
Michael Paesold wrote:

> BEGIN;
> SAVEPOINT a;
> INSERT INTO ...
> SAVEPOINT a;
> INSERT INTO ...
> SAVEPOINT a;
> ...
> (encountering an error it would just ROLLBACK TO a;)
> 
> According to the standard this is exactly the same as:
> 
> BEGIN;
> SAVEPOINT a;
> INSERT INTO ...
> RELEASE SAVEPOINT a;
> SAVEPOINT a;
> INSERT INTO ...

While that's true in this particular case, you can't do that 
transformation in the general case. Consider:

BEGIN
SAVEPOINT a -- work
SAVEPOINT b -- work
SAVEPOINT a -- work
ROLLBACK TO b -- work

This is valid: the standard says that the second "SAVEPOINT a" destroys 
and recreates the savepoint "a", but doesn't say that it destroys 
intervening savepoints. In contrast, RELEASE SAVEPOINT explicitly says 
that it destroys the specified savepoint and all savepoints established 
since the specified savepoint.

If you converted the second "SAVEPOINT a" into "RELEASE SAVEPOINT a; 
SAVEPOINT a" then savepoint "b" would be incorrectly destroyed.

It'd work for the (common?) case where there are no intervening 
savepoints, though.

-O


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: SAVEPOINT SQL conformance
Следующее
От: "Michael Paesold"
Дата:
Сообщение: Re: SAVEPOINT SQL conformance