Re: Tuples inserted and deleted by the same transaction

Поиск
Список
Период
Сортировка
От Matthias van de Meent
Тема Re: Tuples inserted and deleted by the same transaction
Дата
Msg-id CAEze2Wi3XptG2UheAhRDMGAK7KCn-Nqed55xHCPtec1O9XVLrA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Tuples inserted and deleted by the same transaction  (Pantelis Theodosiou <ypercube@gmail.com>)
Список pgsql-hackers
On Tue, 13 Sept 2022 at 12:40, Pantelis Theodosiou <ypercube@gmail.com> wrote:
>
> Forgive me if this is not related but if there is a savepoint between
> the insertion and deletion, wouldn't it be possible for the
> transaction to recover the deleted tuples?

Savepoints result in changed TransactionIds (well, subtransactions
with their own ids), so if a tuple was created before a savepoint and
deleted after, the values in xmin and xmax would be different, as you
can see in the following:

matthias=> CREATE TABLE tst(i int);
matthias=> BEGIN; INSERT INTO tst VALUES (1); SAVEPOINT s1; DELETE
FROM tst; ROLLBACK TO SAVEPOINT s1;
CREATE TABLE
BEGIN
INSERT 0 1
SAVEPOINT
DELETE 1
ROLLBACK
matthias=*> SELECT xmin, xmax FROM tst;
 xmin  | xmax
-------+-------
 62468 | 62469
(1 row)

Note that this row has different xmin/xmax from being created and
deleted in different subtransactions. This means that this needs no
specific handling in the HTSVH code that Laurenz asked about.


Kind regards,

Matthias van de Meent



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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: pgsql: Doc: Explain about Column List feature.
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: ICU for global collation