Re: Rules: passing new/old to functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gunter Diehl <gdid(at)gmx(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Rules: passing new/old to functions
Date: 2003-06-27 03:49:22
Message-ID: 24557.1056685762@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Gunter Diehl <gdid(at)gmx(dot)de> writes:
> create funtion f1(v, v) returns void as '...'
> create rule vupt as on update to v do instead select f1(new, old)
> While accepting this definitions, pg says it can not handle "whole-tuple
> references" at runtime.

FWIW, the "old" case works fine. "new" doesn't work so well because the
new row hasn't been formed into a tuple at the point where the rule
runs; it only exists as a list of variables. (This is a rather handwavy
explanation, but I think it captures the key point.) While this could
probably be fixed with some effort, I doubt it's going to happen soon.
Is there any chance of doing what you want with a trigger instead of a
rule?

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Nicolas JOUANIN 2003-06-27 06:45:52 Re: TR: Like and =
Previous Message Ian Barwick 2003-06-26 21:11:10 Re: UPDATE table SET col = (SELECT ...)