From: | "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Automatically deleting dangling large object references. |
Date: | 2000-05-02 22:17:36 |
Message-ID: | 00050221593703.00670@comptechnews |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I was thinking of trying something like the following to automatically delete
rows from tables that reference large objects when the large object is
unlinked. It would depend on pg_class having a PRIMARY key (on the hidden
'oid' column in this possible example):
-- this is a generic table to just hold large objects
CREATE TABLE lobjs (
id SERIAL CONSTRAINT lobjs_id_con
PRIMARY KEY,
-- other tables referencing this would also react.
lo_oid OID CONSTRAINT lobjs_lo_oid_con NOT NULL,
-- holds an actual large object id.
lo_ref_oid OID CONSTRAINT lobjs_lo_ref_oid_con
REFERENCES pg_class
ON UPDATE CASCADE
ON DELETE CASCADE
INITIALLY DEFERRED
);
CREATE RULE set_lo_ref_oid AS
ON INSERT TO lobjs
DO
UPDATE lobjs
SET lo_ref_oid = pg_class.oid
FROM pg_class
WHERE pg_class.relname = "xinx" || new.lo_oid;
Something like that (I'd have to check this sql to make sure its right). I don't
think there is a primary key on the system tables. I wonder if it would cause
problems if there where?
Anyway, does anyone know of a way to accomplish something like what I am trying
to do with the large objects?
--
Robert B. Easter
reaster(at)comptechnews(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Alfred Perlstein | 2000-05-02 23:15:31 | Re: Return from timestamp column |
Previous Message | Jack Zhu | 2000-05-02 21:59:56 | Return from timestamp column |