Re: multiple statement 'instead of' rule

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: multiple statement 'instead of' rule
Date: 2006-06-21 17:41:21
Message-ID: b42b73150606211041y1d3f108re8ed8b8d65076047@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/20/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Merlin Moncure" <mmoncure(at)gmail(dot)com> writes:
> > create or replace rule insert_fsv as on insert to frequency_service_view
> > do instead
> > (
> > insert into frequency_operation
> > select new.table_name, new.frequency, old.code where new.set =
> > true and old.set = false;
> > delete from frequency_operation
> > where table_name = old.table_name and frequency_operation.code =
> > old.code and
> > frequency_operation.frequency = new.frequency and new.set = false;
> > update operation
> > set code = new.code where code = old.code and old.code != new.code;
> > );
>
> What is frequency_service_view? Is it by any chance dependent on
> frequency_operation? If so, your changes to frequency_operation will
> affect the behavior of OLD references.

right, actually that was a typo, was supposed to be 'create or replace
rule insert_fov as on insert to frequency_operation_view'. I was
considering that old/new are invalid which is fine, but the problem is
in some cases the third (and sometimes second query) never fires at
all with any arguments. I confirmed this by inserting into a log
table in between the rule queries (they never fired either).

I can prepare a test case if you think it's worth it.

Merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2006-06-21 17:50:47 Re: Dynamic loading of C functions: Badly stuck
Previous Message Ricardo Vaz 2006-06-21 17:08:49 Copy from text file