Re: [GENERAL] rules: evaluate inputs in advance

2006-05-14 Thread Tom Lane
Martijn van Oosterhout writes: > Well, I notice that the SQL standard defines something called WITH, so > what you want is something like: > WITH OLD AS ( SELECT blah ) > DO > ( UPDATE > ; DELETE ) I think it'd be a mistake to assume that WITH would fix Markus' complaint. I haven't studied th

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-14 Thread Martijn van Oosterhout
On Sun, May 14, 2006 at 08:01:39AM +0200, Markus Schiltknecht wrote: > > What you probably want is a function that is given the row and then > > executes the two statements on a per row basis. This has the effect you > > want but gives up the major benefit of rules, wholesale query > > restructurin

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-13 Thread Markus Schiltknecht
Hi Martijn, On Fri, 2006-05-12 at 18:05 +0200, Martijn van Oosterhout wrote: > But it can't really. In the example that started this thread, there are > two seperate rules and after rewriting the executor will be presented > two seperate queries. Ah, thank you, that explains the difficulties with

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Martijn van Oosterhout
On Fri, May 12, 2006 at 04:22:00PM +0200, Markus Schiltknecht wrote: > > There have been discussions about the problems > > Do you have some pointers here? I did not find relevant discussions in > the archives (of gmane.org) Hmm, maybe not so much discussions as comments from developers when the

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Richard Broersma Jr
> Well, triggers cannot be used to create writeable views, can they? The documentation says that triggers can be used on views but only for Inserts; not updates or deletes. http://www.postgresql.org/docs/8.1/interactive/rules-triggers.html Regards, Richard ---(end of b

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Markus Schiltknecht
On Fri, 2006-05-12 at 15:57 +0200, Martijn van Oosterhout wrote: > It's a known problem. It's also one of the reasons why triggers are > recommended over rules. And it's not desirable behaviour. Well, triggers cannot be used to create writeable views, can they? > There have been discussions about

Re: [GENERAL] rules: evaluate inputs in advance

2006-05-12 Thread Martijn van Oosterhout
On Fri, May 12, 2006 at 03:51:18PM +0200, Markus Schiltknecht wrote: > Hi, > > I was trying to create an updateable view. Suddenly I got foreign key > violations when using nextval('myseq'). > > As I understand, the rewriter does something similar to a simple text > replacement (I guess copying t