First of all, kudos on postgreSQL. That being said,
am having a slight problem with it, namely, System tables
appear to be 'special tables' and disallow triggers. Perhaps
its jst the way i am doing it, however, here is a rather
trite example to illustrate (file called system.trig):

        CREATE OR REPLACE FUNCTION action_upd() RETURNS opaque AS '
                RAISE NOTICE ''User % added/updated'',NEW.usename;
                RETURN new;
        END;' LANGUAGE 'plpgsql';

        CREATE TRIGGER mysys_trig
        AFTER INSERT OR UPDATE on pg_shadow
        FOR EACH ROW
        EXECUTE PROCEDURE action_upd();

test1=# \i /data_raid/stefs_home/postgres/system.trig
psql:/data_raid/stefshome/postgres/system.trig:10: ERROR: 
CreateTrigger: can't create trigger for system relation pg_shadow

        Now, i know that this is largely a useless example,
however the theory was that if this -was- possible, then it
would be child's play to create a session table for each user.
This would allow the system to store values which would make
things easier for the rest of the database and apache system
i am using (it would allow me to improve and normalise my
schema somewhat). I can also see the above being useful for
when you have more than one DBA and would like to log user
creation (actually, am thinking more of using pl/perl here
and then emailing out each user/modification to all admins)

        Last time this was tried (around 7.2) it allowed triggers
on system tables, but pg_user and pg_shadow and most other tables
would have values inserted in outside of the 'INSERT' logic. I can
understand that this is great for speed, but it seriously hampers
the usefulness of triggers (they wouldnt fire :)

        This would seem to be a step backwards to me though, as
now we cant even put triggers on the system tables. Is there any
chance of this being lifted ? (actually, can understand not
allowing pg_trigger mainly because it could end up a cyclic
trigger very easily :)

        Thanks and hope this makes some sort of sense :)

Stef Telford <[EMAIL PROTECTED]>

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to