Thread: New.* and old.* as function arguments within rules
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@meme.com> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
Karl O. Pinc <kop@meme.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°
On 12/03/2005 01:43:38 AM, Andreas Kretschmer wrote: > Karl O. Pinc <kop@meme.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@meme.com> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
"Karl O. Pinc" <kop@meme.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
On 12/03/2005 10:29:43 PM, Tom Lane wrote: > "Karl O. Pinc" <kop@meme.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@meme.com> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein