Savepoint weirdness

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Savepoint weirdness
Date: 2004-08-15 07:43:44
Message-ID: Pine.LNX.4.58.0408151722190.2047@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Jason Godden pointed out some weird savepoint behaviour on IRC and i've
narrowed this down to a simpler case.

We see the following behaviour against HEAD:

template1=# create table foo(i int, j text);
CREATE TABLE
template1=# create unique index foo_idx on foo(i); -- not, creation of idx
CREATE INDEX
template1=# begin;
BEGIN
template1=# insert into foo values(1, 'one');
INSERT 584714 1
template1=# select * from foo;
i | j
---+-----
1 | one
(1 row)

template1=# savepoint sp1;
SAVEPOINT
template1=# insert into foo values(2, 'two');
INSERT 584715 1
template1=# insert into foo values(3, 'three');
INSERT 584716 1
template1=# select * from foo;
i | j
---+-------
1 | one
2 | two
3 | three
(3 rows)

template1=# savepoint sp2;
SAVEPOINT
template1=# update foo set j = upper(j);
UPDATE 3
template1=# select * from foo;
i | j
---+-------
1 | ONE
2 | TWO
3 | THREE
(3 rows)

template1=# rollback to sp2;
ROLLBACK
template1=# select * from foo;
i | j
---+---
(0 rows)

The rollback to sp2 should have taken us to a point where foo looked like:

i | j
---+-------
1 | one
2 | two
3 | three
(3 rows)

And, indeed, without an index on i, that's what we get. I've attached
output of when the index is around and not around. I've also confirmed
that other DELETE and INSERT (instead of UPDATE) after savepoint sp2 do
not cause this weirdness.

Gavin

Attachment Content-Type Size
savepoint.txt text/plain 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2004-08-15 10:18:46 Re: [Fwd: Re: [pgsql-hackers-win32] Import from Linux to
Previous Message Philip Warner 2004-08-15 07:00:02 Re: pg_dump 'die_on_errors'