Re: Rules: A Modest Proposal

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Rules: A Modest Proposal
Date: 2009-10-05 14:32:53
Message-ID: 7241.1254753173@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> ISTM it may be possible to use the new WITH construct here. So the rule
> evaluation for the following

>> create table t (a integer);
>> create table t_log (a integer);
>> create rule t_ins AS ON insert TO t do also insert into t_log values (NEW.a);
>> insert into t values (floor(random()*1000)::integer);

> becomes something like:

> WITH NEW AS (
> insert into t values (floor(random()*1000)::integer);
> RETURNING *
> )
> insert into t_log values (NEW.a);

> Would this not have the required semantics?

Interesting idea, but it's not clear how to make it work with multiple
DO ALSO rules, nor with conditional DO INSTEAD rules.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2009-10-05 14:51:20 Re: Rules: A Modest Proposal
Previous Message Simon Riggs 2009-10-05 14:31:45 Re: Privileges and inheritance