Hi Jason,

On Saturday 04 October 2008 20:47:28 Jason Yap wrote:
> Naa koy problem regarding with database. Lately, I've been working with
> database particularly postgresql. I want to have a trigger function that
> will be invoked before a table is drop.

did you figure this out?

i haven't been working with postgresql lately, but from what i recall
from following the postgresql mailing list, you can't have triggers on
system tables (e.g., pg_class) or, more generally, you can't have triggers
that detect schema changes.  this is, for instance, why slony-1 does
not support auto-synchronizing things like adding or dropping a column
or adding or dropping a table.  you need to use slony scripts to have the
slaves catchup to the master whenever you do schema changes.

> How do I do this? The documentation of postgresql says triggers can only 
> be triggered when inserting, updating and deleting records. I'm still
> searching for solutions in the net at the moment. Pero mangutana na pud 
> ko diri in case someone knows a solution to 
> the problem.

if you want to, you can either figure out how the pg_* schema tables are
organized or you can cheat and use psql -E and then, in psql, \d [tablename]
to see how psql looks up the table in pg_class, and how it looks up the
columns in pg_attribute, etc.  that'll tell you where postgres stores
information about tables and columns (and indexes and rules, and triggers,
etc).

then you can *try* to set a trigger on pg_class that will do something
when a table is created, dropped, modified, etc.  i don't have enough
motivation to test it out here (given what i've read about it on slony
and pgsql-general mailing lists), but if you find a way to do it, tell
the world.

good luck.

tiger

-- 
Gerald Timothy Quimpo   [EMAIL PROTECTED]
http://bopolissimus*blogspot*com http://monotrematica*blogspot*com
   The direct use of force is such a poor solution to any problem, it
    is generally employed only by small children and large states.
       -- David Friedman
_________________________________________________
Kagay-Anon Linux Users' Group (KLUG) Mailing List
[email protected] (http://lists.linux.org.ph/mailman/listinfo/klug)
Searchable Archives: http://archives.free.net.ph

Reply via email to