Re: rules, triggers and views

From: elein <elein(at)varlena(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: elein <elein(at)varlena(dot)com>, pgsql-hackers(at)postgresql(dot)org, David Fetter <david(at)fetter(dot)org>
Subject: Re: rules, triggers and views
Date: 2004-12-06 00:18:49
Message-ID: 20041205161849.A18284@cookie.varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We'd want the tuples to be produced by the select rule
and treated as if we didn't care where they came from.
Perhaps it doesn't work this way because of the way srfs
were integrated into the SQL execution? I dunno.

do instead triggers should be deemed safe on a view
for those brave enough to try.

The base problem still is having the iterations of OLD and
NEW available in rules--sort of the opposite problem of implementing
per statement triggers.

But we may have a solution still by having rules on the
view and triggers on a table and marrying them via the
update insert delete rules. We'll see how it goes.
This was suggested over on irc.

Thank you...More news as it happens.

--elein

On Sun, Dec 05, 2004 at 06:02:00PM -0500, Tom Lane wrote:
> elein <elein(at)varlena(dot)com> writes:
> > Also, what are the reasons for forbidding triggers on views?
>
> The fact that they'd never fire (or better never fire). A view does not
> actually store any tuples, so update and delete triggers on it are
> certainly useless. You could imagine allowing BEFORE INSERT triggers,
> with the understanding that nothing will be inserted no matter what the
> trigger returns ... but such a trigger is still useless unless we remove
> the safety restriction that says you can't INSERT into a view without
> having an ON INSERT DO INSTEAD rule.
>
> What you are probably wishing you had is some sort of ability to trigger
> on "virtual", pre-rewriter operations, but the executor and the trigger
> mechanism know nothing of this.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2004-12-06 00:42:07 Re: WIN1252 encoding - backend or not?
Previous Message Bruce Momjian 2004-12-06 00:18:22 Re: WIN1252 encoding - backend or not?