Re: How to delete Large Object from Database?

From: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: Premsun Choltanwanich <Premsun(at)nsasia(dot)co(dot)th>, pgsql-sql(at)postgresql(dot)org
Subject: Re: How to delete Large Object from Database?
Date: 2005-10-08 11:20:05
Message-ID: 7104a7370510080420qca482a5r23ce3fdff80d25e1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

On 10/7/05, Richard Huxton <dev(at)archonet(dot)com> wrote:
> Deleting the OID does not remove the object itself - see details of
> lo_unlink() in Chapter 28 of the manuals.
>
> I seem to recall some other utilities in the contrib/ directory of the
> source distribution too.

Could it be `contrib/lo'? Here's some snippet from contrib/lo/README.lo:

[Snippet]
One of the problems with the JDBC driver (and this affects the ODBC driver
also), is that the specification assumes that references to BLOBS (Binary
Large OBjectS) are stored within a table, and if that entry is changed, the
associated BLOB is deleted from the database.

As PostgreSQL stands, this doesn't occur. Large objects are treated as
objects in their own right; a table entry can reference a large object by
OID, but there can be multiple table entries referencing the same large
object OID, so the system doesn't delete the large object just because you
change or remove one such entry.

[...]

I've fixed this by creating a new data type 'lo', some support functions, and
a Trigger which handles the orphaning problem. The trigger essentially just
does a 'lo_unlink' whenever you delete or modify a value referencing a large
object. When you use this trigger, you are assuming that there is only one
database reference to any large object that is referenced in a
trigger-controlled column!
[/Snippet]

Regards.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Simon Law 2005-10-09 23:20:53 convert time
Previous Message solarsail 2005-10-07 19:54:59 Re: using pg_tables and tablename in queries