Auto-delete large objects when referencing row is deleted

From: higepon <higepon(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Auto-delete large objects when referencing row is deleted
Date: 2009-04-06 06:52:35
Message-ID: f07386410904052352h403e7a6et4452a041df8afb9d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.
I found a TODO item "pg_dump Add dumping of comments on index columns"
for large objects.
and want to write a patch for it.

I examined contrib/lo which offers this functionality.

I have two plans, can anybody give me some advice on these?

Plan A:

(1) Define a new type for large object
PostgreSQL stores blob columns as Oid type.
But to delete large objects,
we have to distinguish large objects as being different from Oid
type objects.

So a new type for large object, say "lo type" should be defined on
pg_type.h .

For compatibility with Oid values, we may add some code to pg_cast.h .

(2) Define a trigger on create table
When "create table" has large object type columns,
PostgreSQL define a tirgger which delete large object on
update/delete the row.
We can use the trigger defined contrib/lo for this purpose.

We may add hook code on "create table" at
/src/backend/commands/tablecmds.c .

(3) truncate/drop table
On truncate table or drop table, the trigger can't be used.
We have to handle this case.

Plan B:

This plan is quite simple.
Merge contrib/vacumelo to VACUUM.

(1) Define a new type for large object
Same as Plan A. (unnecessary ?)

(2) Delete on VACUUM
On VACUUM, we check all tables which have "lo type",
and delete un-referenced large objects.
We may add a option "deleting large objects automatically" on VACUUM.

Best regards,

-----
Taro Minowa(Higepon)

Cybozu Labs, Inc.

http://www.monaos.org/
http://code.google.com/p/mosh-scheme/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2009-04-06 07:52:59 Re: EXPLAIN WITH
Previous Message Zdenek Kotala 2009-04-06 06:28:56 Re: Solaris getopt_long and PostgreSQL