Automatically deleting dangling large object references.

Поиск
Список
Период
Сортировка
От Robert B. Easter
Тема Automatically deleting dangling large object references.
Дата
Msg-id 00050221593703.00670@comptechnews
обсуждение исходный текст
Ответы Re: Automatically deleting dangling large object references.  ("Robert B. Easter" <reaster@comptechnews.com>)
Список 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@comptechnews.com

В списке pgsql-general по дате отправления:

Предыдущее
От: "Robert B. Easter"
Дата:
Сообщение: Re: OID output problems
Следующее
От: "Robert B. Easter"
Дата:
Сообщение: Re: Enumerated data type