On Mon, Oct 05, 2009 at 02:53:56PM +0100, Andrew Gierth wrote:
> Here are a couple of the more common ones:
> 
> 1) any reference in an insert rule to NEW.col where col has a volatile
>    default, or the expression in the insert statement was volatile, or
>    the expression's value is changed by the insert, will do the wrong
>    thing:

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?

Have a nice day,
-- 
Martijn van Oosterhout   <klep...@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.

Attachment: signature.asc
Description: Digital signature

Reply via email to