Skip site navigation (1) Skip section navigation (2)

Re: Shortcut for defining triggers

From: David Fetter <david(at)fetter(dot)org>
To: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Shortcut for defining triggers
Date: 2005-01-24 16:12:49
Message-ID: 20050124161249.GD17204@fetter.org (view raw or flat)
Thread:
Lists: pgsql-hackers
On Sun, Jan 23, 2005 at 03:49:22PM -0600, Jim C. Nasby wrote:
> Sorry if this is old, but I couldn't find it in the archives...
> 
> How difficult would it be to provide a means to define a trigger in
> one statement? Something like a combination of CREATE TRIGGER and
> CREATE FUNCTION? Being able to define them seperately is awesome for
> generic cases where you can use one function for a bunch of
> different tables, but it's a pain in the cases where you need a
> unique trigger for one table.

What would you want the function name to default to?  What language,
or would you want to specify that somehow?

Here's a sketch of what such an API might look like:

CREATE TRIGGER foo_trg
    BEFORE INSERT OR UPDATE ON foo_tab
    FOR EACH ROW EXECUTE PROCEDURE
    LANGUAGE PLPGSQL (/* params would go here if any */) $$
/* body here */
$$;

This would cause a foo_tab_b4_iu_func (how to address namespace
collisions?) to be created in the appropriate language with
appropriate params, then the foo_trg on the table.

Does SQL:2003 have anything to say about this?  Also, what kind of
development effort would be involved with an implementation, assuming
SQL:2003 doesn't forbid?

Cheers,
D
-- 
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

In response to

Responses

pgsql-hackers by date

Next:From: Peter EisentrautDate: 2005-01-24 16:24:59
Subject: Re: [PATCHES] Merge pg_shadow && pg_group -- UNTESTED
Previous:From: Jonah H. HarrisDate: 2005-01-24 15:35:40
Subject: Re: Concurrent free-lock

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group