Lists: | pgsql-general |
---|
From: | "Karl O(dot) Pinc" <kop(at)meme(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | New.* and old.* as function arguments within rules |
Date: | 2005-12-02 21:48:09 |
Message-ID: | 1133560089l.9565l.5l@mofo |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hi,
I'm trying to make sure I understand what I'm doing.
Where is new.* and old.* documented, as regards
using them as arguments to functions called from
rules? If it's not documented then can I rely
on this syntax continuing to work?
(It's tough searching on these strings. :-)
TIA
Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: New.* and old.* as function arguments within rules |
Date: | 2005-12-03 07:43:38 |
Message-ID: | 20051203074338.GA1297@kaufbach.delug.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Karl O. Pinc <kop(at)meme(dot)com> schrieb:
> Hi,
>
> I'm trying to make sure I understand what I'm doing.
>
> Where is new.* and old.* documented, as regards
> using them as arguments to functions called from
> rules? If it's not documented then can I rely
http://www.postgresql.org/docs/8.1/interactive/triggers.html
HTH Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
From: | "Karl O(dot) Pinc" <kop(at)meme(dot)com> |
---|---|
To: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: New.* and old.* as function arguments within rules |
Date: | 2005-12-03 17:15:52 |
Message-ID: | 1133630152l.28211l.0l@mofo |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On 12/03/2005 01:43:38 AM, Andreas Kretschmer wrote:
> Karl O. Pinc <kop(at)meme(dot)com> schrieb:
>
> > Hi,
> >
> > I'm trying to make sure I understand what I'm doing.
> >
> > Where is new.* and old.* documented, as regards
> > using them as arguments to functions called from
> > rules? If it's not documented then can I rely
on the behavior?
>
> http://www.postgresql.org/docs/8.1/interactive/triggers.html
Thanks for the reply but I've obviously got some big
misunderstanding here.
1st, the docs above refer to triggers, not rules. AFIK
rules are a completely different animal.
2nd, nowhere have I found a NEW.* syntax (as written).
NEW (or OLD) seems to be a complete rowtype (or maybe
recordtype), as far as triggers go anyway, and there's
no explaination of what .* might mean in the context
of a rowtype.
Finally, the syntax seems to have something to do
with calling functions.
See: http://archives.postgresql.org/pgsql-general/2005-08/msg00653.php
Which is what I found searching the archives trying to
figure out the best way to pass data in NEW and OLD
to functions called from within rules.
Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Karl O(dot) Pinc" <kop(at)meme(dot)com> |
Cc: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: New.* and old.* as function arguments within rules |
Date: | 2005-12-04 04:29:43 |
Message-ID: | 5111.1133670583@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
"Karl O. Pinc" <kop(at)meme(dot)com> writes:
> 2nd, nowhere have I found a NEW.* syntax (as written).
This could certainly stand to be better documented, but there is an
example for instance here:
http://developer.postgresql.org/docs/postgres/xfunc-sql.html#AEN31568
In general, "foo.*" where foo is a visible table alias is meaningful
anywhere that a rowtype value would be accepted. There is a special
case at the top level of a SELECT result list, where it will be broken
apart into a list of foo's component fields because the SQL spec says
so.
At one time you could just write "foo" instead of "foo.*", but that's
deprecated because it's ambiguous against the case of a simple column
"foo". I'm not sure to what extent it still works at all, and it
probably will stop working in any remaining cases someday.
NEW/OLD are not different from other table aliases as far as these
matters go.
regards, tom lane
From: | "Karl O(dot) Pinc" <kop(at)meme(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: New.* and old.* as function arguments within rules |
Date: | 2005-12-04 05:28:41 |
Message-ID: | 1133674121l.28211l.6l@mofo |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On 12/03/2005 10:29:43 PM, Tom Lane wrote:
> "Karl O. Pinc" <kop(at)meme(dot)com> writes:
> > 2nd, nowhere have I found a NEW.* syntax (as written).
> In general, "foo.*" where foo is a visible table alias is meaningful
> anywhere that a rowtype value would be accepted. There is a special
> case at the top level of a SELECT result list, where it will be broken
> apart into a list of foo's component fields because the SQL spec says
> so.
Thanks very much. I had just started writing 'foo' because I didn't
know about 'foo.*' and it's been working so far (8.0.3) but
would _hate_ to have it break on upgrade.
This is the first time I've found the Postgres documentation to be
really lacking. I suppose there has to be a first.
(Very sorry, _wway_ to busy to write a doc patch.)
Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein