Skip site navigation (1) Skip section navigation (2)

subtransactions -- storage manager

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: subtransactions -- storage manager
Date: 2004-04-25 18:06:36
Message-ID: 20040425180636.GA17886@dcc.uchile.cl (view raw or flat)
Thread:
Lists: pgsql-patches
Hackers,

This patch adds subtransaction support into the storage manager.  Files
created or dropped inside a subtransaction are correctly dealt with at
subtransaction commit or abort.

This works:
create table foo (a int);
create table foo2 (a int);
begin;
	begin;
		create table bar (a int);
		select relfilenode, relname from pg_class where relname in ('foo', 'bar');
		drop table foo2;
	rollback;
	drop table foo;
	create table baz (a int);
	select relfilenode, relname from pg_class where relname='baz';
commit;

At this point, the files for "bar" and "foo" have disappeared, while
"foo2" and "baz" remain.  (Note however that the catalog entries are not
correct -- this is because we don't have correctly recorded results in
pg_clog.)

While making this I realized I had made a mistake regarding portal
memory, so I also correct it with this patch.  As a side effect, the
following works;

begin;
	begin;
		declare foo cursor for select 1;
	commit;
	begin;
		declare bar cursor for select 1;
	rollback;
	fetch all from foo;		-- returns 1 row
	fetch all from bar;		-- no such cursor
rollback;

(This patch will only apply cleanly with the previous patch applied.)



Still missing:

- support for prepared statements, async notifies.  Easy.
- support for on commit actions.  Not sure.
- support for deferred triggers.  Not so easy, maybe hard.
- correct LWLock handling.  Should be easy (release them all on abort)
- correct regular lock handling.  Not so easy.
- pg_clog/pg_subtrans.  Need a solution.


PS: somehow I managed to get tired of the phrase "nested transactions"
and I'm using the term "subtransactions" instead.  In my head they are
the same thing ...

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Hi! I'm a .signature virus!
cp me into your .signature file to help me spread!

Responses

pgsql-patches by date

Next:From: Neil ConwayDate: 2004-04-25 18:41:14
Subject: Re: Remove traces of xfunc
Previous:From: Alvaro HerreraDate: 2004-04-25 04:43:38
Subject: Re: Remove traces of xfunc

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group