pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: andrew@pillette.com
Cc: pgsql-sql@postgresql.org
Subject: Re: CREATE RULE ignored, what did I do wrong
Date: Sat, 11 Sep 2004 02:42:23 -0400
Message-ID: <7805.1094884943@sss.pgh.pa.us> (raw)
In-Reply-To: <200409102136.i8ALajP19402@pillette.com>
References: <200409102136.i8ALajP19402@pillette.com>

andrew@pillette.com writes:
> Foreign-key constraints:
>     "$1" FOREIGN KEY (smoothing_id) REFERENCES smoothing_algorithm(smoothing_id) ON UPDATE CASCADE ON DELETE CASCADE
> Rules:
>     del_smoothed_rank_episode AS ON DELETE TO smoothed_rank_episode
> WHERE (NOT old.is_deleted) DO INSTEAD ...

The DELETE commands generated by the foreign key ON DELETE CASCADE will
get rewritten by your ON DELETE rule.  You probably do not want to do
this; or at least not make it an INSTEAD rule.

There has been some debate in the past about whether rules should be
able to break foreign-key constraints, but I tend to class it as a
"you should know what you're doing" feature.  Preventing this kind
of error would inevitably result in a serious reduction of the power
of the rule feature.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <7805.1094884943@sss.pgh.pa.us>
Permalink:  ../7805.1094884943@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7805.1094884943@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew@pillette.com
  Subject: Re: CREATE RULE ignored, what did I do wrong
  In-Reply-To: <7805.1094884943@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox